Skip to content

fix(greenfield): seal candidates before review - #111

Merged
aryeko merged 20 commits into
mainfrom
codex/candidate-seal-reviewer-readonly
Jul 27, 2026
Merged

fix(greenfield): seal candidates before review#111
aryeko merged 20 commits into
mainfrom
codex/candidate-seal-reviewer-readonly

Conversation

@aryeko

@aryeko aryeko commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • makes independent reviewers semantic/evidence-only and explicitly prohibits local check reruns or repository mutations
  • seals exact candidates with base ancestry, candidate-bound whitespace validation, durable command logs, and clean-state evidence
  • executes verification in a clone-local exact-candidate subject, preserving workspace links inside clone bytes and rejecting unsafe links
  • adds fail-closed output containment for candidate roots, sibling worktrees, and shared Git metadata

Verification

  • pnpm candidate:seal:test — 12 focused boundary regressions passed
  • exact seal: candidate 1e994015cca98ea80e9e0f7607d02992b7894847, tree dc4bf68ceb2e9da2f4c574a5aafd79e49f27bff7
  • base origin/main / 4db373ec6067018e9724fcc51d29ee75044d212d; merge-base matched
  • external envelope /private/tmp/jig-candidate-seal-1e99401/envelope.json: candidate-bound diff and pnpm check exited 0; clone/original states clean; seal.valid: true

The reviewer packet and checklist preserve read-only semantic authority; missing or stale evidence remains a finding rather than a reason to rerun verification.

Summary by CodeRabbit

  • New Features
    • Added candidate-sealing verification that generates an external evidence envelope with commit identity/ancestry checks, cleanliness/tamper detection, and per-command execution results.
    • Added commands to create and test candidate seals.
    • Integrated candidate sealing into the standard validation (check) workflow.
  • Documentation
    • Updated greenfield delivery/reviewer procedures with stricter read-only evidence review, “seal envelope” requirements, and re-seal/re-review rules after relevant changes.
  • Tests
    • Expanded coverage for successful sealing and invalidation scenarios (worktree mutations, ancestry mismatches, command/timeout failures, and evidence/log recording).

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77ce27dc-6be0-44ce-8057-01e73607fa38

📥 Commits

Reviewing files that changed from the base of the PR and between de5953b and c160ce6.

📒 Files selected for processing (2)
  • scripts/seal-candidate.mjs
  • scripts/seal-candidate.test.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/seal-candidate.mjs

📝 Walkthrough

Walkthrough

The PR adds candidate-sealing automation, external evidence-envelope requirements, read-only reviewer procedures, lifecycle updates, repository script wiring, and comprehensive sealing tests.

Changes

Candidate sealing and evidence workflow

Layer / File(s) Summary
Delivery policy and lifecycle rules
docs/delivery/greenfield/delivery-policy.md
Defines immutable candidate tuples, sealing order, evidence bindings, reviewer boundaries, lifecycle transitions, and correction resealing.
Reviewer and verification contracts
docs/delivery/greenfield/reviewer/*, docs/delivery/greenfield/story-contract.md, docs/delivery/greenfield/verification.md
Specifies external seal-envelope contents, read-only evidence review, correction rechecks, CI responsibility, and exact candidate-to-base diff validation.
Candidate seal generation
scripts/seal-candidate.mjs
Validates repository boundaries and ancestry, creates a detached verification subject, runs commands, records state and logs, and writes envelope.json with seal validity.
Repository integration and sealing tests
package.json, scripts/check-active-repository.mjs, scripts/check-delivery-track.test.mjs, scripts/seal-candidate.test.mjs
Adds sealing commands to the check chain and repository fixtures, with coverage for successful seals, mutations, ancestry failures, path safety, symlinks, command failures, and large logs.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Owner
  participant SealScript
  participant VerificationSubject
  participant EvidenceEnvelope
  Owner->>SealScript: Provide candidate, base, output, and commands
  SealScript->>VerificationSubject: Create detached candidate clone
  VerificationSubject->>VerificationSubject: Run diff check and verification commands
  SealScript->>VerificationSubject: Inspect commit, tree, and cleanliness state
  SealScript->>EvidenceEnvelope: Write observations and seal validity
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: sealing candidates before independent review.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/candidate-seal-reviewer-readonly

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e994015cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/seal-candidate.mjs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
scripts/seal-candidate.mjs (1)

31-41: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add timeouts to spawnSync invocations.

None of the git, gitOutput, or runCommand spawnSync calls set a timeout. A hung git operation or, more importantly, a hung caller-supplied verification command (Line 126-131) will block the seal process indefinitely with no recovery, defeating the goal of a reliable, automatable evidence-generation step run as part of pnpm check.

♻️ Suggested fix
 function git(repository, ...args) {
-  const result = spawnSync('git', args, { cwd: repository, encoding: 'utf8' });
+  const result = spawnSync('git', args, { cwd: repository, encoding: 'utf8', timeout: 30_000 });
   if (result.status !== 0) fail(`git ${args.join(' ')} failed: ${result.stderr.trim()}`);
   return result.stdout.trim();
 }
     result = spawnSync(command, {
       cwd: repository,
       encoding: 'utf8',
       shell: true,
+      timeout: <appropriate-bound>,
       stdio: ['ignore', logFile, logFile],
     });

Also applies to: 121-145

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/seal-candidate.mjs` around lines 31 - 41, Configure a finite timeout
on every spawnSync invocation used by git, gitOutput, and runCommand, including
caller-supplied verification commands. Use the script’s existing timeout
configuration if available, ensure timed-out processes are detected and reported
through the existing failure path, and preserve current command output handling
for successful executions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/delivery/greenfield/delivery-policy.md`:
- Around line 85-89: Make the observed target base ref a first-class seal field,
pairing its exact ref with the resolved base commit and tree throughout the
sealing contract. Update Rule 11 and lifecycle step 5 in
docs/delivery/greenfield/delivery-policy.md, the external seal envelope in
docs/delivery/greenfield/reviewer/README.md, required seal fields in
docs/delivery/greenfield/reviewer/review-checklist.md, owner verification
evidence in docs/delivery/greenfield/story-contract.md, and mandatory
verification evidence in docs/delivery/greenfield/verification.md.

In `@scripts/seal-candidate.mjs`:
- Around line 202-237: Update the catch handling around the verification loop in
the candidate-sealing flow so every command after the last recorded observation
receives a skipped entry when a mid-loop exception occurs. Preserve existing
observations and their order, use the existing “verification subject setup
failed” reason for unattempted commands, and ensure the envelope still contains
one command record per command even when observations is partially populated.

In `@scripts/seal-candidate.test.mjs`:
- Around line 205-214: Update the test around seal to pass an options object
with withPnpmSeparator enabled instead of the primitive true, ensuring the
command exercises the pnpm forwarded -- separator path and still asserts
successful execution.

---

Nitpick comments:
In `@scripts/seal-candidate.mjs`:
- Around line 31-41: Configure a finite timeout on every spawnSync invocation
used by git, gitOutput, and runCommand, including caller-supplied verification
commands. Use the script’s existing timeout configuration if available, ensure
timed-out processes are detected and reported through the existing failure path,
and preserve current command output handling for successful executions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c6afb26-bc7e-4511-8a70-dd232ee00848

📥 Commits

Reviewing files that changed from the base of the PR and between 4db373e and 1e99401.

📒 Files selected for processing (10)
  • docs/delivery/greenfield/delivery-policy.md
  • docs/delivery/greenfield/reviewer/README.md
  • docs/delivery/greenfield/reviewer/review-checklist.md
  • docs/delivery/greenfield/story-contract.md
  • docs/delivery/greenfield/verification.md
  • package.json
  • scripts/check-active-repository.mjs
  • scripts/check-delivery-track.test.mjs
  • scripts/seal-candidate.mjs
  • scripts/seal-candidate.test.mjs

Comment thread docs/delivery/greenfield/delivery-policy.md
Comment thread scripts/seal-candidate.mjs Outdated
Comment thread scripts/seal-candidate.test.mjs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/delivery/greenfield/delivery-policy.md (1)

85-103: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Make evidence-output containment an explicit fail-closed seal invariant.

“External” output and a detached clone are not sufficient to prevent writes through candidate roots, sibling worktrees, shared Git metadata, or symlink/junction escapes. Require path resolution and rejection before commands run, with post-command verification covering all durable logs and evidence outputs.

Suggested policy clarification
+ Sealing fails closed unless every output, log, and evidence path resolves
+ outside the candidate root, all sibling worktrees, and shared Git metadata;
+ symlink/junction escapes are rejected before execution and rechecked afterward.

This is required by the PR objective for fail-closed output containment across candidate roots, sibling worktrees, and shared Git metadata.

Also applies to: 197-204

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/delivery/greenfield/delivery-policy.md` around lines 85 - 103, Update
the candidate-sealing requirements around “pnpm candidate:seal” to make
evidence-output containment fail closed: resolve and validate the external
output directory and all durable log/evidence paths before running commands,
rejecting paths that resolve inside candidate roots, sibling worktrees, shared
Git metadata, or symlink/junction escapes. Require post-command verification of
every durable log and evidence output, and invalidate the seal on any
containment violation or unexpected write.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@docs/delivery/greenfield/delivery-policy.md`:
- Around line 85-103: Update the candidate-sealing requirements around “pnpm
candidate:seal” to make evidence-output containment fail closed: resolve and
validate the external output directory and all durable log/evidence paths before
running commands, rejecting paths that resolve inside candidate roots, sibling
worktrees, shared Git metadata, or symlink/junction escapes. Require
post-command verification of every durable log and evidence output, and
invalidate the seal on any containment violation or unexpected write.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a90db493-e64c-4526-bdf2-9e213125a12c

📥 Commits

Reviewing files that changed from the base of the PR and between 1e99401 and de5953b.

📒 Files selected for processing (7)
  • docs/delivery/greenfield/delivery-policy.md
  • docs/delivery/greenfield/reviewer/README.md
  • docs/delivery/greenfield/reviewer/review-checklist.md
  • docs/delivery/greenfield/story-contract.md
  • docs/delivery/greenfield/verification.md
  • scripts/seal-candidate.mjs
  • scripts/seal-candidate.test.mjs
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/delivery/greenfield/reviewer/review-checklist.md
  • docs/delivery/greenfield/reviewer/README.md
  • docs/delivery/greenfield/verification.md
  • docs/delivery/greenfield/story-contract.md
  • scripts/seal-candidate.mjs
  • scripts/seal-candidate.test.mjs

@aryeko

aryeko commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Re the CodeRabbit outside-diff output-containment suggestion: no further change is warranted. isOutsideRepository canonicalizes the output parent and rejects destinations within the current candidate, every registered worktree, and the common Git directory before creating the fresh output directory; all durable setup/preflight/caller logs and the envelope are derived beneath that guarded root. The existing linked-worktree/common-Git and symlink-parent regressions cover those escapes. A post-command check cannot prove an arbitrary command did not transiently mutate and restore filesystem paths; that would overclaim beyond the explicit non-mutating-command contract. The final seal remains valid at de5953b (/private/tmp/jig-candidate-seal-de5953b/envelope.json).

@aryeko

aryeko commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de5953ba27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/seal-candidate.mjs Outdated
Comment thread scripts/seal-candidate.mjs
@aryeko
aryeko merged commit 4b067f4 into main Jul 27, 2026
2 checks passed
@aryeko
aryeko deleted the codex/candidate-seal-reviewer-readonly branch July 27, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant