Repository navigation
Establish truthful 0.4 stabilization baseline - #8
Conversation
|
@codex please perform a strict verification review of this PR. The goal is not to add new features. The goal is to verify whether the previous P0/P1 blockers around 0.4 and 0.4-c have actually been fixed, and whether the project can now truthfully run the 0.4 stabilization / 0.4-c acceptance path. Please specifically verify the following previous blockers:
ruff check .
pytest -q
python scripts/verify_0_3_acceptance.py
python scripts/verify_0_4b_acceptance.py
python scripts/verify_0_4c_acceptance.py
python scripts/verify_0_4d_acceptance.py
python scripts/verify_0_4_acceptance.pyIf any command fails, explain whether the failure is expected, acceptable, or a blocker.
Please provide:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2bc128557
ℹ️ 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".
| if record.outcome == RunOutcome.SUCCEEDED and (run_dir / "patch.diff").exists(): | ||
| record.review_status = "needs_review" |
There was a problem hiding this comment.
Prevent patch runs from reporting success before review
When an InternLoop run succeeds it writes patch.diff and finalizes gate_result.json as pass before maybe_enqueue runs. This branch only sets review_status=needs_review while leaving outcome=SUCCEEDED and the already-written pass gate/report intact, so run intern and summaries can still show a patch-producing run as completed before any human decision, violating the 0.4-c review gate.
Useful? React with 👍 / 👎.
| if (run_dir / "patch.diff").exists(): | ||
| record.review_status = "resume_requested" |
There was a problem hiding this comment.
Make approved patch runs resumable or final
For a run with patch.diff, approval records resume_requested but the run is still TERMINATED/SUCCEEDED from the original loop. build_recovery_plan rejects succeeded runs before considering the resume_allowed checkpoint, so loop-pilot resume <run_id> fails after a successful approval and the required post-approval validation/resume path cannot run.
Useful? React with 👍 / 👎.
| { | ||
| "path": rel, | ||
| "sha256": _sha256(path), |
There was a problem hiding this comment.
Recompute the manifest hash after writing it
On normal loop finalization, artifact-manifest.json already exists when the finalizer runs, so this hashes the old manifest and then the function overwrites artifact-manifest.json with a different payload. The manifest therefore lists a checksum for itself that never matches the file users audit, which breaks the terminal artifact contract for successful/partial runs.
Useful? React with 👍 / 👎.
| path_name = entry.get("path", "") | ||
| if not path_name.endswith(".md"): | ||
| continue | ||
| if entry.get("human_readable") is False: |
There was a problem hiding this comment.
Return actual reports instead of the first Markdown artifact
InternLoop manifests list markdown log artifacts such as diff-summary.md before development-report.md, and those legacy entries do not contain human_readable=false. This predicate treats any such .md entry as reportable, so loop-pilot report <run_id> can print diff-summary.md instead of report.md/development-report.md for reviewed runs.
Useful? React with 👍 / 👎.
Record direct-finalize approve semantics, manifest/report fixes, and update 0.3 acceptance to expect partial for patch-producing intern runs.
Clear stale var/locks before aggregate acceptance runs to prevent flaky intern lock timeouts; update CHANGELOG and 0.4-c acceptance checklist for direct-finalize patch approve semantics.
Centralize stale lock cleanup for var/locks and var/state/locks so chained acceptance runs do not flake on intern lock timeouts.
|
@codex please re-review the latest HEAD of this PR, not the outdated The previous Codex review found several 0.4 blockers around the review gate, patch-producing runs, artifact manifest checksums, and report selection. Since then, the PR has added follow-up fixes, including:
CI is currently passing, but please perform a strict verification review of whether the PR is now actually safe to merge as a truthful 0.4 stabilization baseline. Please specifically verify:
Please answer clearly:
|
There was a problem hiding this comment.
💡 Codex Review
LoopPilot/src/loop_pilot/loops/intern/loop.py
Lines 541 to 543 in 5693c05
On patch-producing InternLoop runs, mark_patch_run_waiting_review() writes the canonical needs_review artifacts and manifest, but these lines immediately rewrite artifact-manifest.json with the legacy ArtifactManifest. The manifest that the orchestrator persists therefore loses the canonical run metadata/gate/report entries and keeps legacy checksums, so a run can be correctly held for human review while its published manifest is not truthful. Regenerate the canonical manifest last, or do not rewrite it after finalization.
ℹ️ 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".
| for item in prior: | ||
| if isinstance(item, dict) and item.get("path") != "artifact-manifest.json": | ||
| artifacts.append(dict(item)) |
There was a problem hiding this comment.
Recompute manifest entries after rewriting artifacts
finalize_terminal_artifacts() rewrites files such as run_meta.json, gate_result.json, report.md, and tool-results.json earlier in the function, but this branch copies entries from any existing manifest verbatim and treats them as already seen. When loops first write a legacy manifest, or when approval changes gate_result.json from needs_review to pass, the final manifest can retain stale sha256 or path values for files that were just rewritten, leaving listed artifacts with mismatched checksums. Recompute entries from disk or rebuild the manifest instead of carrying prior entries forward unchanged.
Useful? React with 👍 / 👎.
| UPDATE review_items | ||
| SET status = 'pending', artifact_path = ? |
There was a problem hiding this comment.
Preserve deferred review items during sync
ReviewService.list_pending() calls sync_from_runs() before listing, so a run that was deferred still flows through maybe_enqueue() and reaches this update; the update changes an existing deferred item back to pending. A future-dated defer is therefore visible again on the next list/sync instead of remaining deferred until deferred_until, which breaks the review queue semantics the CLI exposes.
Useful? React with 👍 / 👎.
Clear repo runtime locks before each component and prerequisite script so nested verify_0_3 intern runs do not hit loop:intern timeouts after pytest or sibling gates.
… approve Port Codex PR #8 patch review gate from stabilize: InternLoop _finalize sets PARTIAL/needs_review for patch.diff runs; ReviewService maybe_enqueue safety layer and approve() direct-finalizes without resume_requested; terminal_artifacts excludes manifest self-checksum; report_path prefers canonical reports.
Document Codex PR #8 state model, files changed, and cross-refs in 0.5 spec and Chinese review layer guide.
Ensure artifact-manifest.json is written only once by terminal_artifacts with disk-rescanned checksums, stop InternLoop from overwriting it, and preserve deferred review items until due date.
|
@codex please re-review the latest HEAD of PR #8 (stabilize/0.4-truthful-acceptance), not the outdated e2bc128 review. Review target commit: 90b2f3f (and any newer commits if present). Goal: verify this PR is safe to merge as a truthful 0.4 stabilization baseline — not to add new features. Please specifically verify the PREVIOUS Codex findings are fixed on latest HEAD: Round 1 (already addressed in 10aa1ef / 5693c05 / 463c572)
Round 2 (addressed in 90b2f3f)
Also verify unchanged requirements:
Expected commands (should pass truthfully on clean checkout): Please answer clearly:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90b2f3f266
ℹ️ 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".
| state_store: StateStore | None = None, | ||
| ) -> RunRecord: | ||
| """Patch-producing runs are not final success until a human approves.""" | ||
| record.phase = RunPhase.TERMINATED |
There was a problem hiding this comment.
Keep patch runs in WAITING_APPROVAL
When a run produces patch.diff and has not been approved yet, this forces the persisted run into TERMINATED even though the documented 0.4-c review gate says the pre-approve state is WAITING_APPROVAL / PARTIAL / needs_review (docs/development/45-personal-daily-loop-0.4c-acceptance.md:49-53). In that scenario status/recovery consumers no longer see the run as awaiting human approval, so latest HEAD does not satisfy the stated truthful patch-review baseline.
Useful? React with 👍 / 👎.
| elif record.review_status is None: | ||
| record.review_status = "pending" | ||
| gate = read_gate_result(self.artifact_dir, record.loop_type, record.run_id) or "needs_review" | ||
| write_review_suggestion(run_dir, record, gate) |
There was a problem hiding this comment.
Write review suggestion before sealing manifest
For patch-review runs, lines 72-77 call mark_patch_run_waiting_review(), which already runs finalize_terminal_artifacts() and writes the final artifact-manifest.json; this line then creates or updates review_suggestion.json after the manifest was sealed. A first-time needs_review/blocked review item therefore omits the required suggestion artifact from the manifest, and later syncs can leave a stale checksum, contradicting the 0.4-c artifact contract in docs/development/45-personal-daily-loop-0.4c-acceptance.md:34-39.
Useful? React with 👍 / 👎.
| if has_patch and not patch_decided: | ||
| record = mark_patch_run_waiting_review(artifact_dir=self.artifact_dir, record=record) |
There was a problem hiding this comment.
Record terminal trace after review gating
For successful patch-producing InternLoop runs, the terminated trace event is appended just before this branch converts the run from SUCCEEDED to PARTIAL/needs_review; finalize_terminal_artifacts() then copies that stale trace.jsonl into loop_trace.jsonl. In the normal “tests passed and patch.diff exists” path, the canonical terminal artifacts can still report a final success before human approval, undermining the truthful review gate even though run_meta.json and gate_result.json are corrected afterward.
Useful? React with 👍 / 👎.
Patch runs awaiting human review now stay in WAITING_APPROVAL with review_suggestion sealed in the manifest before finalize; InternLoop loop_trace records waiting_review/partial instead of succeeded.
|
@codex review |
|
@codex please re-review the latest HEAD of PR #8, commit 04923ef — not 90b2f3f, 5693c05, or e2bc128. CI is green. Local aggregate acceptance: verify_0_4_acceptance.py 11/11 READY (220 pytest passed). Since your last review on 90b2f3f, we added: 04923ef — fix(0.4): Codex P2 patch review WAITING_APPROVAL and honest trace This commit specifically addresses your three P2 findings on 90b2f3f:
Please confirm ALL prior findings are fixed on 04923ef: Round 1 (10aa1ef+)
Round 2 (90b2f3f)
Round 3 (04923ef) — your three P2 above Also verify unchanged:
Expected commands (should pass on clean checkout): Please answer:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04923ef8d6
ℹ️ 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".
| status="approved", | ||
| reason=note, | ||
| ) | ||
| finalize_terminal_artifacts(run_dir, record, gate="pass", review_required=False) |
There was a problem hiding this comment.
Persist manifests after approval finalization
When a stored patch run is approved via the review service, this rewrites run_meta.json, gate_result.json, and artifact-manifest.json on disk to TERMINATED/succeeded/pass, but the SQLite artifact_manifests row is never refreshed because only save_run() is called afterward. Any DB-backed consumer or later integrity check that reads the persisted manifest payload will still see the pre-approval needs_review manifest/checksums even though the on-disk files have changed.
Useful? React with 👍 / 👎.
| manifest = { | ||
| "run_id": record.run_id, | ||
| "loop_type": record.loop_type, | ||
| "terminal_outcome": record.outcome.value if record.outcome else None, | ||
| "artifacts": artifacts, |
There was a problem hiding this comment.
Keep generated manifests schema-compatible
The new canonical manifest omits the required schema_version field and adds loop_type, which is rejected by the existing schemas/artifact-manifest.json (additionalProperties: false). Any consumer using validate_artifact_manifest() or the documented schema against a freshly finalized run will fail on every generated artifact-manifest.json, so the writer and schema need to be kept in sync.
Useful? React with 👍 / 👎.
Approve on patch runs now persists the refreshed manifest to SQLite so disk and DB agree after gate=pass; finalize_terminal_artifacts emits schema_version 1 and the JSON Schema enforces the canonical fields.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d44e3c8425
ℹ️ 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".
| self._require_item(run_id) | ||
| record = reject_run(self.state_store, run_id, reason) |
There was a problem hiding this comment.
Refuse changes to already-decided reviews
In the reject/cancel paths, the result from _require_item is discarded, so a review item whose status is already approved, rejected, or cancelled can still be mutated again. For example, after approve finalizes a patch run as TERMINATED/SUCCEEDED, a later accidental loop-pilot reject <run_id> reaches reject_run and rewrites that same run to BLOCKED, corrupting the persisted outcome. Please gate these paths the same way approve gates decided items.
Useful? React with 👍 / 👎.
| self._require_item(run_id) | ||
| record = reject_run(self.state_store, run_id, reason) | ||
| run_dir = run_artifact_dir(self.artifact_dir, record.loop_type, run_id) | ||
| finalize_terminal_artifacts(run_dir, record, gate="blocked", review_required=True) |
There was a problem hiding this comment.
Persist rejected patch manifests to SQLite
When rejecting a patch run, finalize_terminal_artifacts() rewrites the on-disk artifact-manifest.json with the blocked terminal state, but unlike the approve path this returned manifest is never saved via state_store.save_artifact_manifest. If the run had already been enqueued, SQLite keeps the old partial/needs_review manifest while disk shows blocked; the cancel path has the same omission. Persist the returned manifest for these terminal decisions too.
Useful? React with 👍 / 👎.
|
@codex review |
Require pending/deferred review items before approve/reject/cancel and persist artifact_manifests to SQLite on reject/cancel, matching approve.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c1adeff33
ℹ️ 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".
| self._require_item(run_id) | ||
| record = reject_run(self.state_store, run_id, reason) |
There was a problem hiding this comment.
Prevent approved reviews from being overwritten
In the CLI workflow where a patch run has already been approved, a later loop-pilot reject RUN --reason ... still reaches this path because _require_item only checks that a row exists; reject_run then flips the RunRecord to TERMINATED/BLOCKED and record_decision rewrites the review row from approved to rejected. The same missing terminal-status guard exists for defer/cancel, so an accidental second decision can corrupt an already finalized successful run; reject/defer/cancel should refuse items whose status is already approved/rejected/cancelled.
Useful? React with 👍 / 👎.
| record = reject_run(self.state_store, run_id, reason) | ||
| run_dir = run_artifact_dir(self.artifact_dir, record.loop_type, run_id) | ||
| finalize_terminal_artifacts(run_dir, record, gate="blocked", review_required=True) | ||
| self.store.record_decision(run_id, decision="reject", status="rejected", reason=reason) |
There was a problem hiding this comment.
Persist blocked manifests after review rejection
When a previously enqueued patch run is rejected, finalize_terminal_artifacts rewrites the on-disk manifest/gate to blocked, but unlike the approve path this branch never saves the returned manifest back to artifact_manifests. If the orchestrator already persisted the earlier needs_review manifest, SQLite remains stale with terminal_outcome=partial while the run row says blocked; DB-backed status/export consumers will read inconsistent results. Save the finalized manifest here, and in the analogous cancel path, as the approve branch does.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@codex This review targeted 3c1adef, which is a docs-only commit and predates the fix.
Please re-review HEAD cadd630 (fix(review): block re-decision and sync reject/cancel manifests).
That commit specifically addresses both P2 findings:
-
Prevent approved reviews from being overwritten
- Added
_require_decidable_item()in ReviewService - approve/reject/cancel only allowed when status is
pendingordeferred - Raises
ReviewDecisionErrorfor already decided items - Tests:
test_approved_review_cannot_be_rejected_later,test_rejected_review_cannot_be_cancelled_later
- Added
-
Persist blocked manifests after reject/cancel
- reject/cancel call
finalize_terminal_artifacts()thenstate_store.save_artifact_manifest(run_id, manifest)(same as approve) - Tests:
test_reject_persists_blocked_artifact_manifest,test_cancel_persists_blocked_artifact_manifest
- reject/cancel call
Local verification on cadd630:
- pytest -q: 227 passed
- verify_0_4_acceptance.py: 11/11 READY
Please confirm on cadd630 whether any P0/P1/P2 remain, or recommend approve.
There was a problem hiding this comment.
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
There was a problem hiding this comment.
@codex This review targeted 3c1adef, which is a docs-only commit and predates the fix.
Please re-review HEAD cadd630 (fix(review): block re-decision and sync reject/cancel manifests).
That commit specifically addresses both P2 findings:
Prevent approved reviews from being overwritten
Added _require_decidable_item() in ReviewService
approve/reject/cancel only allowed when status is pending or deferred
Raises ReviewDecisionError for already decided items
Tests: test_approved_review_cannot_be_rejected_later, test_rejected_review_cannot_be_cancelled_later
Persist blocked manifests after reject/cancel
reject/cancel call finalize_terminal_artifacts() then state_store.save_artifact_manifest(run_id, manifest) (same as approve)
Tests: test_reject_persists_blocked_artifact_manifest, test_cancel_persists_blocked_artifact_manifest
Local verification on cadd630:
pytest -q: 227 passed
verify_0_4_acceptance.py: 11/11 READY
Please confirm on cadd630 whether any P0/P1/P2 remain, or recommend approve.
Record honest v0.3 paper repositioning—measured acceptance oracles, protocol-only benchmarks, terminology compression, and PDF build status.
|
@codex This review targeted 3c1adef, which is a docs-only commit and predates the fix. Please re-review HEAD cadd630 (fix(review): block re-decision and sync reject/cancel manifests). That commit specifically addresses both P2 findings: Prevent approved reviews from being overwritten Added _require_decidable_item() in ReviewService reject/cancel call finalize_terminal_artifacts() then state_store.save_artifact_manifest(run_id, manifest) (same as approve) pytest -q: 227 passed |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cadd630560
ℹ️ 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".
|
|
||
| def _require_decidable_item(self, run_id: str) -> ReviewItem: | ||
| item = self._require_item(run_id) | ||
| if item.status not in {"pending", "deferred"}: |
There was a problem hiding this comment.
Block deferring already-decided reviews
This guard still lets the immutability invariant be bypassed because defer() continues to accept any existing item via _require_item() and writes status='deferred'. A user can approve a run, defer that already-approved review, and then this new check treats the row as decidable again, allowing a later reject/cancel to overwrite the approved decision; defer needs the same decided-item protection (and CLI handling) or decided rows can still be changed.
Useful? React with 👍 / 👎.
defer() used _require_item(), allowing approve→defer to reopen reject/cancel on finalized items; align with approve/reject/cancel via _require_decidable_item().
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Integrate 0.5 SafetyGate and prep while preserving 0.4 truthful acceptance fixes: review guards, patch gate, terminal artifacts, and deferred sync. Wire InternLoop/SummaryCollector to main config and review_store APIs.
Reflect PR #8 merge (11/11 READY, 254 pytest) with inline SVG badges, milestone bar, state machine diagram, and acceptance gate table.
No description provided.