Skip to content

fix(headless): harden RSI full-run preflight and resume safety - #356

Merged
Astro-Han merged 6 commits into
mainfrom
codex/i311-rsi-r2-real-run-report
Jun 29, 2026
Merged

Astro-Han merged 6 commits into
mainfrom
codex/i311-rsi-r2-real-run-report

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR does not run or claim completion of the RSI R2 full run. It hardens the pre-run/runtime foundation that the failed full-run attempt exposed as missing: explicit runtime profile, manifest/fingerprint identity, baseline/sweep resume safety, and fail-fast boundaries where full whole-loop replay is not implemented.

Why

Refs #311

The attempted full run showed that "starting a full run" is not the same as having reliable evidence for #311 completion. Before spending another full-run budget, the runner needs explicit and auditable runtime settings, stable run identity, and safe resume semantics.

Scope

Changed:

  • Add prompt-optimization-manifest.json for prompt optimization runs and pass its fingerprint into WAL resume identity.
  • Make runtime profile explicit: task budget, Harbor timeout, command timeout, continuation, and active tool result pruning.
  • Use task metadata plus run caps for per-task MAKA_CELL_TIMEOUT_SEC.
  • Let Bash defer default timeouts to the isolated executor and make bounded-tail Bash respect MAKA_CELL_COMMAND_TIMEOUT_MS.
  • Fingerprint real task source content, clean subject checkout, and clean execution toolchain/source/dist.
  • Make prompt repo bootstrap idempotent at seed stage, including .git initialized with no HEAD.
  • Reuse readFixedPromptWal() for resume preflight so torn WAL tails preserve baseline/sweep resume semantics.
  • Fail fast on post-candidate RSI resume (prompt_candidate_committed / prompt_candidate_decided or HEAD past seed) because whole-loop WAL replay is not implemented in this PR.
  • Reject legacy manifest-less run roots before mixing artifacts.

Not included:

  • No bounded or full run artifacts.
  • No RSI R2 completion report.
  • No whole-loop replay after a candidate is committed/kept.
  • No acceptance-policy changes or prompt optimization strategy changes.

Verification

  • npm run -w @maka/headless typecheck
  • npm run -w @maka/headless build
  • node --test packages/headless/dist/__tests__/prompt-optimization-bootstrap.test.js packages/headless/dist/__tests__/prompt-optimization-manifest.test.js packages/headless/dist/__tests__/prompt-optimization-run.test.js packages/headless/dist/__tests__/harbor-adapter.test.js
  • node --test packages/headless/dist/__tests__/harbor-cell.test.js packages/headless/dist/__tests__/tools.test.js
  • node --check packages/headless/harbor/run-prompt-optimization.mjs
  • git diff --check

User-facing impact

Future RSI prompt optimization runs get explicit preflight/runtime identity and safer seed/baseline/sweep resume behavior. If a run has already reached candidate commit/decision state, it now fails fast and asks for a new run id until whole-loop WAL replay is implemented.

Reviewer notes

Please review this as pre-run infrastructure, not as the full-run evidence PR. The failed full-run attempt exposed these gaps; this PR closes the runner safety/setup gaps before we decide whether to run again or split a fresh full-run PR.

@Astro-Han

Copy link
Copy Markdown
Contributor Author

Review fixes pushed in ee8a9130.

  • Subject fingerprint now requires a clean MAKA_PROMPT_MAKA_REPO HEAD before building the resume identity.
  • Task source fingerprint now hashes real task directory contents, including files, executable bits, and directory structure; symlinks fail loud.
  • Prompt repo bootstrap is idempotent: an existing seed repo is validated and reused instead of being rewritten/recommitted.
  • Manifest mismatch is verified to fail before prompt-repo rewrite.
  • Moved prompt optimization manifest/bootstrap logic out of run-prompt-optimization.mjs into TS helpers with behavior tests, and removed the weak runtime-profile string-scan test.

Verification:

  • npm run -w @maka/headless typecheck
  • npm run -w @maka/headless build
  • node --test packages/headless/dist/__tests__/prompt-optimization-manifest.test.js packages/headless/dist/__tests__/prompt-optimization-bootstrap.test.js packages/headless/dist/__tests__/prompt-optimization-run.test.js packages/headless/dist/__tests__/harbor-adapter.test.js
  • node --test packages/headless/dist/__tests__/harbor-cell.test.js packages/headless/dist/__tests__/tools.test.js
  • node --check packages/headless/harbor/run-prompt-optimization.mjs
  • git diff --check

@Astro-Han

Copy link
Copy Markdown
Contributor Author

Second review fixes pushed in b4c3b6fb.

  • Chose the explicit fail-fast boundary for post-candidate RSI resume instead of implementing partial whole-loop replay.
  • Existing prompt repos whose HEAD has moved past the seed commit now fail with post-candidate RSI resume is not supported yet before seed-file checks.
  • WALs that already contain prompt_candidate_committed or prompt_candidate_decided also fail-fast with the same boundary.
  • Toolchain fingerprint now binds the execution checkout (repoRoot), requires it to be clean, and includes HEAD plus packages/headless/src, packages/headless/harbor/run-prompt-optimization.mjs, and packages/headless/dist content.

Verification:

  • npm run -w @maka/headless typecheck
  • npm run -w @maka/headless build
  • node --test packages/headless/dist/__tests__/prompt-optimization-bootstrap.test.js packages/headless/dist/__tests__/prompt-optimization-manifest.test.js packages/headless/dist/__tests__/prompt-optimization-run.test.js packages/headless/dist/__tests__/harbor-adapter.test.js
  • node --test packages/headless/dist/__tests__/harbor-cell.test.js packages/headless/dist/__tests__/tools.test.js
  • node --check packages/headless/harbor/run-prompt-optimization.mjs
  • git diff --check

@Astro-Han

Copy link
Copy Markdown
Contributor Author

Third review fixes pushed in 42bd006b.

  • assertPromptOptimizationResumeSupported() now reuses readFixedPromptWal() instead of hand-parsing JSONL, so torn malformed final WAL lines keep the same baseline resume semantics as the fixed-prompt controller.
  • Seed bootstrap now handles .git already initialized with no HEAD by completing the seed commit when seed files are missing or match the expected content.
  • Added helper-level manifest mismatch test that proves the prompt repo is not rewritten; the script-level test remains scoped to early-safety no-rewrite because a dirty execution checkout can correctly fail earlier during local development.

Verification:

  • npm run -w @maka/headless typecheck
  • npm run -w @maka/headless build
  • node --test packages/headless/dist/__tests__/prompt-optimization-bootstrap.test.js packages/headless/dist/__tests__/prompt-optimization-manifest.test.js packages/headless/dist/__tests__/prompt-optimization-run.test.js packages/headless/dist/__tests__/harbor-adapter.test.js
  • node --test packages/headless/dist/__tests__/harbor-cell.test.js packages/headless/dist/__tests__/tools.test.js
  • node --check packages/headless/harbor/run-prompt-optimization.mjs
  • git diff --check

Note: this continues to keep post-candidate whole-loop resume out of scope; the guard now makes that boundary explicit while preserving baseline/sweep resume.

@Astro-Han Astro-Han changed the title Fix RSI runtime profile resume safety Harden RSI full-run preflight and resume safety Jun 29, 2026
@Astro-Han

Astro-Han commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the latest resume-safety review in 7ccf2be.

What changed:

  • Added runtime artifact fingerprinting for prompt optimization subject identity, so ignored/generated artifacts under packages/headless/dist, packages/core/dist, packages/runtime/dist, and packages/storage/dist now affect the run manifest.
  • Reused the same runtime artifact fingerprint for the execution toolchain identity, while tracked source/package/runner identity stays represented by clean git HEAD.
  • Added regression coverage for ignored packages/headless/dist/harbor-cell.js changes in both subject and toolchain fingerprints.
  • Tightened the prompt-optimization early-safety integration assertion to require manifest mismatch, instead of accepting execution-checkout dirty as an equivalent pass.

Verification:

  • npm run -w @maka/headless typecheck
  • npm run -w @maka/headless build && node --test packages/headless/dist/__tests__/prompt-optimization-manifest.test.js packages/headless/dist/__tests__/harbor-adapter.test.js
  • git diff --check

After committing, the clean-checkout integration test ran without skips: 24 pass, 0 skip.

@Astro-Han

Astro-Han commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Keeping external MAKA_PROMPT_MAKA_REPO support for this PR.

Rationale:

  • This is a P3 simplification trade-off, not a remaining resume-safety bug.
  • The runner already has a real external subject path, and the prompt A/B runner has the same subject/toolchain separation pattern.
  • The latest patch closed the unsafe part by fingerprinting ignored/generated runtime artifacts for both subject and toolchain identity.
  • Removing the external subject mode now would shrink state space, but it would also change the runner contract at the end of a resume-safety PR.

So this PR keeps the current implementation and leaves any future Occam-cut of external subject support as a separate product/runner-scope decision.

@Astro-Han Astro-Han changed the title Harden RSI full-run preflight and resume safety fix(headless): harden RSI full-run preflight and resume safety Jun 29, 2026
@Astro-Han
Astro-Han merged commit 9d2c61d into main Jun 29, 2026
@Astro-Han
Astro-Han deleted the codex/i311-rsi-r2-real-run-report branch June 29, 2026 06:15
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