Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
review:
needs: source
runs-on: ubuntu-24.04
timeout-minutes: 50 # Provider refresh eligibility can require up to 25 minutes before bounded inference.
timeout-minutes: 360 # GitHub-hosted platform ceiling; the trusted per-review timer normally stops at 30m.
environment: codexbot-${{ inputs.installation_id }}-${{ inputs.credential_owner }}
permissions:
contents: read
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Security and behavior changes

## Unreleased — targeted continuation and configurable review timeout

- Default to 30 minutes of isolated execution; support trusted `review.timeout_minutes` and an authorized `--timeout` override. Bound execution by GitHub's six-hour job limit, retaining setup/refresh/cleanup reserves and the existing global inference-request cap.
- Group changed JS/TS dependencies together within file, byte and changed-line bounds. Track per-file checkpoints, give every group a first pass before targeted continuation, reuse prior findings/evidence, and reserve time for final synthesis. Missing evidence or unfinished analysis still fails the job and cannot approve or merge.
- Serialize host-only OAuth rotation during long reviews and persist the encrypted new session before atomically updating the proxy's access-token file. Renew read-only GitHub context tokens through the same live OIDC/installation/actor/commit checks. The model receives no credentials.
- Align request expiry, concurrency and session leases with the selected timeout; preserve the separate one-hour merge-intent deadline and existing quotas.

## 0.1.2 — bounded context reuse and review efficiency

- Reuse verified source without spending another distinct-path lookup; separate 24 uncached snapshot/path lookups from a hard 100 total context-request cap. Preserve all GitHub API, byte, integrity, authorization and inference limits. Missing evidence and resource exhaustion remain non-approving, with fixed error reasons.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Use `--model MODEL_ID` (or `--model=MODEL_ID`) to override the repository's mode

Reviews use bounded groups of immutable changed-file evidence and a final cross-group synthesis in the same isolated Codex session. Unfinished analysis retains validated findings and its explanation as a non-approving COMMENT; it still fails the review check. Grouping does not reset usage budgets or authorize merging.

The execution timeout defaults to 30 minutes. Set `review.timeout_minutes` in `.codexbot.yml`, or use `@CBReview review --timeout 60` for one authorized request. Groups prioritize changed dependencies; continuations target pending files and reuse completed work. The single 100-request inference budget still applies. GitHub-hosted jobs have a six-hour platform limit; setup, refresh eligibility and cleanup reserve 30 minutes, leaving at most 330 minutes for inference. There is no separate 45-minute product limit.

Set `bot.trigger: "@CBReview"` to use the example above. The legacy default `@codexbot` remains supported; new setup chooses `@CBReview<repository_id>`. Use a name without “codex” when another Codex integration is installed. CodexBot cannot control that independent connector; see [trigger isolation and rollout](docs/review-rollout.md).

## Status
Expand Down
12 changes: 6 additions & 6 deletions docs/adaptive-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Bounded review orchestration

After collection passes, the trusted Actions host writes a private `review-plan.json` and immutable `review-units/` inputs. Changed paths are sorted to keep nearby code together, then grouped within 16 files / 2 MB per input, at most 32 groups. Inputs contain the actual textual patches and complete current/deleted changed-file text and hash receipts for every collected base/head file; modified old source remains read-only at its verified path instead of being retransmitted, or SHA-bound verified PNG metadata, plus applicable trusted instructions, the whole-PR path overview and an inventory of shared collected source. Every group keeps access to all original source, callers, dependencies, the file index and the same bounded context socket; grouping never removes cross-file context. Trusted instruction input is bounded to 1 MB; unrepresentable essential evidence fails before inference. Original Git/snapshot and binary verification remain required.
After collection passes, the trusted Actions host writes a private `review-plan.json` and immutable `review-units/` inputs. Changed paths are ordered with changed relative JS/TS dependencies nearby, then grouped within 16 files / 2 MB / 1,500 changed text lines per input, at most 32 groups. A single larger changed file stays intact within the file/byte bounds. Inputs contain the actual textual patches and complete current/deleted changed-file text and hash receipts for every collected base/head file; modified old source remains read-only at its verified path instead of being retransmitted, or SHA-bound verified PNG metadata, plus applicable trusted instructions, the whole-PR path overview and an inventory of shared collected source. Every group keeps access to all original source, callers, dependencies, the file index and the same bounded context socket; grouping never removes cross-file context. Trusted instruction input is bounded to 1 MB; unrepresentable essential evidence fails before inference. Original Git/snapshot and binary verification remain required.

The orchestrator is immutable application code, not a model-provided plan. It checks hashes of host-prepared inputs and referenced text/image files before delivery. The actual pinned app-server processes groups sequentially in one ephemeral thread, with one required successful inspection command per turn and matching thread/turn identity. It allows at most two targeted continuations **across the whole review**, including synthesis. Explicit missing mandatory or visual evidence cannot be cleared by a later model claim. For multiple groups, a separate final synthesis reconciles all unit results and cross-group behavior; it cannot waive unfinished units. A sole group instead receives an explicit final whole-PR/cross-file check in its own response, avoiding a redundant turn. Its verified evidence, inspection and completeness gates still apply. No model field such as “all groups inspected” controls scheduling or coverage.
The orchestrator is immutable application code, not a model-provided plan. It checks hashes of host-prepared inputs and referenced text/image files before delivery. The actual pinned app-server processes groups sequentially in one ephemeral thread, with one required successful inspection command per turn and matching thread/turn identity. It gives every group an initial pass before spending at most two targeted continuations **across the whole review**, including synthesis. Per-file checkpoints are constrained to assigned paths and independently hash-verified evidence; unfinished paths cannot be waived. Continuations receive pending paths, the previous validated review and the immutable evidence receipt rather than another full evidence payload. Shared manifest/user context is sent once to the same thread. Optional continuations stop when the synthesis reserve (up to three minutes) is reached; this does not guarantee a model finishes within the deadline. Explicit missing mandatory or visual evidence cannot be cleared by a later model claim. For multiple groups, a separate final synthesis reconciles all unit results and cross-group behavior; it cannot waive unfinished units. A sole group instead receives an explicit final whole-PR/cross-file check in its own response, avoiding a redundant turn. Its verified evidence, inspection and completeness gates still apply. No model field such as “all groups inspected” controls scheduling or coverage.

One credential proxy and one engine timer cover all turns: the existing 100 inference-request / 20-minute ceiling is not multiplied per group. The context socket allows 24 distinct uncached snapshot/path lookups and 100 total requests; the 768 GitHub-call, text/image-byte and model/effort limits remain in force. Protocol receipts and scope checks establish supplied evidence and completed scheduled responses, not proof of a model's semantic reasoning. More turns can change actual consumption within those ceilings; no real-provider cost or quality improvement is claimed from synthetic tests.
One credential proxy and one engine timer cover all turns: the existing 100 inference-request ceiling and selected execution timeout (default 30 minutes) is not multiplied per group. The context socket allows 24 distinct uncached snapshot/path lookups and 100 total requests; the 768 GitHub-call, text/image-byte and model/effort limits remain in force. Protocol receipts and scope checks establish supplied evidence and completed scheduled responses, not proof of a model's semantic reasoning. More turns can change actual consumption within those ceilings; no real-provider cost or quality improvement is claimed from synthetic tests.

Valid incomplete results return to the trusted runner as data. It independently checks every expected unit ID/hash, bounded attempts and synthesis status against its original plan, drains context lookups, and rechecks host and model completeness. Incomplete work fails the Actions review job and may publish only COMMENT, preserving validated summary and findings. Invalid or quarantined output remains rejected. Later execution failures preserve earlier safe findings and the primary execution diagnosis; generic workflow failure does not overwrite it. Findings are deduplicated by original path/side/line and normalized title; more than 40 findings or other output loss is explicitly incomplete. The model cannot delete earlier valid findings during synthesis.

Expand Down Expand Up @@ -56,7 +56,7 @@ Optional discovery never uses a model-supplied required/optional flag. The exist

## Runtime envelope and image retention

For G planned groups, successful baseline scheduling uses T = G + (G > 1 ? 1 : 0) turns. At most two targeted continuations are added globally. In native scripted inspection-then-report acceptance, each turn uses two provider requests. That observed minimum is not a prediction of real-model tool iterations, latency or tokens: all actual calls and retries still share the unchanged 100-request and 20-minute limits.
For G planned groups, successful baseline scheduling uses T = G + (G > 1 ? 1 : 0) turns. At most two targeted continuations are added globally. In native scripted inspection-then-report acceptance, each turn uses two provider requests. That observed minimum is not a prediction of real-model tool iterations, latency or tokens: all actual calls and retries still share the 100-request limit and selected execution timeout.

| Shape (byte limits can create more groups) | Groups | Baseline turns | Scripted requests | Turns / scripted requests with two continuations |
| --- | ---: | ---: | ---: | ---: |
Expand All @@ -65,14 +65,14 @@ For G planned groups, successful baseline scheduling uses T = G + (G > 1 ? 1 : 0
| 93-file/four-image fixture | 6 | 7 | 14 | 9 / 18 |
| Maximum plan | 32 | 33 | 66 | 35 / 70 |

The maximum plan leaves only 30 requests beyond that two-step/35-turn pattern and an arithmetic average of roughly 34 seconds per turn within 20 minutes, before startup overhead. There is no guaranteed large-PR completion or wall-clock/token cost estimate. Real models may need more inspection, compaction or reasoning; exhaustion produces a failed, non-approving partial review. Do not increase limits to hide this. A controlled rollout should first observe representative advisory/no-merge reviews and split work that does not fit the envelope.
The maximum plan leaves only 30 requests beyond that two-step/35-turn pattern and an arithmetic average of roughly 51 seconds per turn within the default 30 minutes, before startup overhead. There is no guaranteed large-PR completion or wall-clock/token cost estimate. Real models may need more inspection, compaction or reasoning; exhaustion produces a failed, non-approving partial review. Use representative acceptance; a longer configured timeout is not evidence of improved analysis. A controlled rollout should first observe representative advisory/no-merge reviews and split work that does not fit the envelope.

The native acceptance now creates four different PNG pixel patterns and verifies four distinct Git blob identities and four distinct encoded image inputs on every request across groups, continuation and final synthesis (16 requests in the large/one-continuation fixture). The first-turn-only attachment behavior is supported by the tested pinned app-server history; image loss was not reproduced. The proxy additionally binds fingerprints of the first trusted required visual inputs and rejects subsequent loss, repetition-as-replacement or substitution. Distinct Git images can have identical native encodings (for example after lossy conversion); the guard retains the minimum attachment count and the first trusted fingerprint set rather than inventing a one-to-one Git-to-encoding identity. Fingerprints and image bytes never enter public diagnostics. No images are blindly reattached per turn, which would inflate history. Native context compaction/re-encoding behavior at real large input sizes remains unmeasured; loss of required evidence fails closed rather than authorizing approval.

## Context reuse and terminal failures

Read already supplied source directly before using the context socket. A probe and subsequent content request for the same immutable snapshot/path consume one distinct-path slot. Repeated verified content requests use the existing mount and hash-verified cache, never another repository, ref or credential. Total requests stay separately bounded, including invalid bodies; crossing that bound cancels context retrieval and makes the host result non-approving. New essential paths cannot bypass the distinct-path or API/byte/type/integrity limits.

Missing required files return a fixed context_path_missing reason; infrastructure, integrity, object-type and size failures are distinct fixed errors, never invented absence or raw exception text. Primary execution failures retain safe host completion flags and bounded lookup counts/code. The 20-minute deadline is explicitly identified as execution-wide; it and the 100-provider-request budget are unchanged.
Missing required files return a fixed context_path_missing reason; infrastructure, integrity, object-type and size failures are distinct fixed errors, never invented absence or raw exception text. Primary execution failures retain safe host completion flags and bounded lookup counts/code. The selected deadline is explicitly identified as execution-wide (default 30 minutes); the global 100-provider-request budget is unchanged.

A unit reporting unavailable required/visual evidence or truncated output ends further inference immediately, preserving validated partial summaries/findings as COMMENT with a failed job. It cannot be repaired by a later model completeness claim. Soft unfinished analysis still uses the existing shared continuation allowance. Complete multi-group reviews still require all groups and final synthesis.
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The manifest distinguishes `diffComplete`, `requiredContextComplete` and supplem

## Isolated inference

Nonroot Docker containers use read-only root filesystems, resource caps, no capabilities, no-new-privileges and private temporary homes. The reviewer has network=none and only context/socket read-only mounts. It has no Docker socket, GitHub/OIDC token, API key, refresh token or vault key. A separate audited proxy owns the access credential, only permits stateless streaming Responses inference at one HTTPS route, rejects hosted network tools, pins model/effort/service-tier selection and replaces provider errors. Default inference limits are 100 provider requests and 20 minutes for the entire isolated execution, shared by all groups, continuations and synthesis. The host owns CLI-session refresh and all context GitHub access. Approved hosted-session refresh stays on the Worker behind OIDC and leases.
Nonroot Docker containers use read-only root filesystems, resource caps, no capabilities, no-new-privileges and private temporary homes. The reviewer has network=none and only context/socket read-only mounts. It has no Docker socket, GitHub/OIDC token, API key, refresh token or vault key. A separate audited proxy owns the access credential, only permits stateless streaming Responses inference at one HTTPS route, rejects hosted network tools, pins model/effort/service-tier selection and replaces provider errors. Default inference limits are 100 provider requests and a configurable execution timeout (default 30 minutes, authorized `--timeout` override) for the entire isolated execution, shared by all groups, continuations and synthesis. The host owns CLI-session refresh and all context GitHub access. Approved hosted-session refresh stays on the Worker behind OIDC and leases.

Codex 0.169.0 uses `approvalPolicy: never` for unattended inspection. The thread's read-only default remains, and each review turn explicitly selects `externalSandbox` with restricted network, relying on the unchanged Docker boundary. `never` is not a client approval grant: all server-initiated approval/tool/permission requests still receive JSON-RPC -32601 and cause the analysis to fail. Native declined commands also fail. At least one completed command with exit 0 is necessary before a turn can produce a review; this is execution evidence, not proof of full semantic coverage. Both the isolated entrypoint and trusted host validate completeness, exact head and changed-line references. Incomplete/quarantined/truncated/inconclusive output fails the review job; the protected publisher can still publish a non-approving fallback.

Expand Down
Loading