Skip to content

Establish truthful 0.4 stabilization baseline - #8

Merged
bosprimigenious merged 19 commits into
mainfrom
stabilize/0.4-truthful-acceptance
Jun 22, 2026
Merged

bosprimigenious merged 19 commits into
mainfrom
stabilize/0.4-truthful-acceptance

Conversation

@bosprimigenious

Copy link
Copy Markdown
Owner

No description provided.

Repository owner deleted a comment from chatgpt-codex-connector Bot Jun 21, 2026
@bosprimigenious

Copy link
Copy Markdown
Owner Author

@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:

  1. False READY / acceptance truthfulness
  • Previously, 0.4-d could report READY even when 0.4-c was NOT READY.
  • Verify whether this is now fixed.
  • Confirm that verify_0_4_acceptance.py is the only authority allowed to report full 0.4 READY.
  • Confirm that verify_0_4d_acceptance.py cannot pass if 0.4-c fails.
  • Confirm that component scripts cannot report READY when runtime checks, pytest, migrations, or prerequisites fail.
  • Look for any weakened assertions, skipped tests, xfail markers, ignored tests, filtered test paths, or fake readiness checks.
  1. 0.4-c Review Layer
  • Verify whether 0.4-c is now truly implemented, not just superficially registered.

  • Check cli_review.py, ReviewService, ReviewStore, migrations, and tests.

  • Confirm that these commands work with sqlite backend:

    • review list
    • review show <run_id>
    • approve <run_id>
    • reject <run_id> --reason ...
    • defer <run_id> --until ...
    • cancel <run_id> --reason ...
    • resume <run_id>
    • report <run_id>
  • Confirm that review commands are blocked on non-sqlite backends.

  • Confirm that workers cannot self-approve.

  • Confirm that rejected and cancelled runs cannot be resumed.

  • Confirm that patch-producing runs cannot silently become completed before human review.

  • Confirm that review decisions are persisted and auditable through review_items and decision events.

  1. Migration v3/v4 conflict
  • Previously, migration v3 had a semantic conflict between summaries and the planned review_items schema.
  • Verify that v3 is preserved and v4 repairs/adds review functionality safely.
  • Confirm that existing v3 databases can migrate to v4 without losing summaries or corrupting state.
  • Confirm that db verify detects v3-only databases missing review_items.
  • Confirm that migration history is checked properly, not only MAX(version).
  • Confirm that repeated migration is idempotent.
  1. db migrate --dry-run safety
  • Previously, dry-run could create or mutate the SQLite database.

  • Verify that dry-run is now strictly read-only.

  • Confirm:

    • no database file is created when the DB is missing;
    • no schema is mutated;
    • no migration row is inserted;
    • no WAL/journal residue is left;
    • file size and mtime do not change for an existing DB.
  1. InternLoop pytest execution
  • Previously, InternLoop used bare pytest, which could fail outside an activated venv.
  • Verify that it now uses the active interpreter via sys.executable -m pytest.
  • Confirm that ToolBroker allows this safely without allowing arbitrary executables.
  • Check that this does not create a security hole where any absolute executable can bypass policy.
  1. Recovery / resume
  • Previously, recovery tests were hidden from default pytest and resume semantics were unreliable.
  • Verify that tests/integration/test_v1_recovery.py is no longer excluded by default.
  • Confirm that exact-round resume is genuinely correct.
  • Confirm that rejected/cancelled runs cannot resume.
  • Check whether budget, checkpoint, workspace identity, policy, or config state could be reset or bypassed during resume.
  • Check whether interrupted ACTING/tool paths require review when side effects may be ambiguous.
  1. Terminal artifacts and auditability
  • Previously, some failure paths did not produce complete audit artifacts.

  • Verify that every terminal run path produces the canonical artifacts:

    • run_meta.json
    • gate_result.json
    • tool-results.json
    • report.md
    • artifact-manifest.json
    • loop_trace.jsonl
  • Confirm that these files contain truthful data, not just placeholder content.

  • Check success, failed, blocked, interrupted, cancelled, review-required, and invalid-input paths.

  • Confirm that artifact-manifest.json lists real artifacts with correct checksums.

  1. Formal runability
    Please try to determine whether the following commands can now run successfully and truthfully:
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.py

If any command fails, explain whether the failure is expected, acceptable, or a blocker.

  1. Merge decision
    Please answer clearly:
  • Are the previous P0 bugs actually fixed?
  • Is 0.4-c truly implemented enough to pass acceptance?
  • Can this PR be merged as a truthful 0.4 stabilization baseline?
  • Can it be described as Full 0.4 READY, or only as stabilization progress?
  • Are there any remaining P0/P1/P2 issues?
  • What exact follow-up PR should be opened next?

Please provide:

  • Final recommendation: approve / request changes / comment only.
  • P0/P1/P2 findings.
  • Exact file and line references.
  • Concrete commands and expected outputs.
  • A short verdict on whether this PR can be formally run through the 0.4 acceptance path.

@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: 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".

Comment thread src/loop_pilot/review/service.py Outdated
Comment on lines +64 to +65
if record.outcome == RunOutcome.SUCCEEDED and (run_dir / "patch.diff").exists():
record.review_status = "needs_review"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread src/loop_pilot/review/service.py Outdated
Comment on lines +101 to +102
if (run_dir / "patch.diff").exists():
record.review_status = "resume_requested"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +160 to +162
{
"path": rel,
"sha256": _sha256(path),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@bosprimigenious

Copy link
Copy Markdown
Owner Author

@codex please re-review the latest HEAD of this PR, not the outdated e2bc128557 review target.

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:

  • fix(0.4): stabilize aggregate gate and stale runtime locks
  • fix(0.4): truthful patch review gate and artifact reporting
  • chore: remove unused approve_run import in recovery test
  • docs(0.4): document Codex PR #8 review gate fixes
  • chore(0.4): stabilize acceptance locks and document Codex PR #8
  • fix(0.4): use clear_repo_runtime_locks in acceptance scripts

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:

  1. Previous P1/P2 review-gate findings

    • Patch-producing InternLoop runs must not report final pass / completed success before human review.
    • gate_result.json, run status, review status, report.md, and summaries must agree.
    • Human review must be the gate that makes a patch-producing run final.
    • Approval/resume semantics must be consistent: approved patch runs must either become final in a truthful way or become resumable through a valid post-review checkpoint.
  2. Artifact manifest correctness

    • artifact-manifest.json must not contain stale checksums.
    • If the manifest excludes itself, confirm this is intentional and documented by behavior/tests.
    • Every listed artifact must exist and have a matching checksum.
  3. Report selection correctness

    • loop-pilot report <run_id> and summary report links must point to the actual report artifact.
    • It must not accidentally pick diff-summary.md or the first arbitrary Markdown artifact.
  4. 0.4-c Review Layer

    • Confirm that the following commands are backed by real sqlite state and tests:

      • loop-pilot review list
      • loop-pilot review show <run_id>
      • loop-pilot review approve <run_id>
      • loop-pilot review reject <run_id> --reason ...
      • loop-pilot review defer <run_id> --until ...
      • loop-pilot review cancel <run_id> --reason ...
      • loop-pilot resume <run_id>
      • loop-pilot report <run_id>
    • Confirm that rejected/cancelled runs cannot be resumed.

    • Confirm that deferred review items remain deferred until their defer date and are not reset to pending by sync.

  5. 0.4 aggregate readiness truthfulness

    • verify_0_4_acceptance.py must be the only authority for full 0.4 READY.
    • Component scripts must not report full READY independently.
    • 0.4-d must not report full 0.4 readiness if 0.4-c fails.
    • Look for weakened assertions, skipped tests, fake readiness checks, or xfail markers.
  6. 0.5-prep boundary

    • This PR should remain a truthful 0.4 stabilization baseline.
    • It should not enable real unattended scheduling or unsafe schedule install --yes.
    • If any 0.5 behavior remains, verify it is blocked or out of scope.
  7. Formal runability
    Please confirm whether these commands should now pass truthfully:

    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.py

Please answer clearly:

  • Are the previous Codex findings fixed on latest HEAD?
  • Are there any remaining P0/P1/P2 issues?
  • Can this PR be merged as a truthful 0.4 stabilization baseline?
  • Can it be called Full 0.4 READY, or only stabilization progress?
  • Final recommendation: approve / request changes / comment only.

@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

manifest_path = run_dir / "artifact-manifest.json"
manifest_path.write_text(
__import__("json").dumps(manifest.to_dict(), indent=2),

P1 Badge Stop overwriting the review-gate manifest

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".

Comment on lines +123 to +125
for item in prior:
if isinstance(item, dict) and item.get("path") != "artifact-manifest.json":
artifacts.append(dict(item))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +72 to +73
UPDATE review_items
SET status = 'pending', artifact_path = ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
bosprimigenious added a commit that referenced this pull request Jun 21, 2026
… 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.
bosprimigenious added a commit that referenced this pull request Jun 21, 2026
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.
@bosprimigenious

Copy link
Copy Markdown
Owner Author

@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)

  1. Patch-producing runs must NOT report final pass/completed before human review
    • phase=WAITING_APPROVAL, outcome=PARTIAL, review_status=needs_review
    • gate_result.json=needs_review, not pass
    • summary must not show Completed
  2. Approve on patch.diff must use direct-finalize (NOT resume_requested deadlock)
    • approve → approved + TERMINATED + SUCCEEDED + gate=pass
    • resume must fail appropriately for finalized/rejected/cancelled runs
  3. artifact-manifest.json must not list itself with stale self-checksum
  4. report_path must prefer canonical reports, not diff-summary.md

Round 2 (addressed in 90b2f3f)

  1. InternLoop must NOT overwrite canonical artifact-manifest.json after finalization
    • Only finalize_terminal_artifacts() may write the final manifest
  2. finalize_terminal_artifacts() must recompute sha256 from final on-disk files
    • Must NOT copy stale checksums from prior manifest entries
    • Atomic write (.tmp + replace); manifest written last
  3. Deferred review items must NOT be reset to pending by sync_from_runs/list_pending
    • future deferred_until stays deferred; approved/rejected/cancelled never revert

Also verify unchanged requirements:

  • verify_0_4_acceptance.py is the only authority for Full 0.4 READY
  • 0.4-d cannot pass if 0.4-c fails
  • No weakened assertions, skip/xfail, filtered tests, or fake readiness
  • db migrate --dry-run is read-only; v4 migration idempotent
  • InternLoop uses sys.executable -m pytest via ToolBroker safely
  • recovery tests in default pytest; terminal artifacts complete on failure paths
  • No real 0.5 schedule install / unattended daemon enabled in this PR

Expected commands (should pass truthfully on clean checkout):
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.py

Please answer clearly:

  1. Are ALL previous P1/P2 findings fixed on latest HEAD?
  2. Any remaining P0/P1/P2 issues?
  3. Final recommendation: approve / request changes / comment only
  4. Can this be called Full 0.4 READY, or only stabilization progress?
  5. Exact file+line references for any remaining issues

@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: 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".

Comment thread src/loop_pilot/review/service.py Outdated
state_store: StateStore | None = None,
) -> RunRecord:
"""Patch-producing runs are not final success until a human approves."""
record.phase = RunPhase.TERMINATED

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread src/loop_pilot/review/service.py Outdated
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +531 to +532
if has_patch and not patch_decided:
record = mark_patch_run_waiting_review(artifact_dir=self.artifact_dir, record=record)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@bosprimigenious

Copy link
Copy Markdown
Owner Author

@codex review

@bosprimigenious

Copy link
Copy Markdown
Owner Author

@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:

  1. P2 — Keep patch runs in WAITING_APPROVAL

    • mark_patch_run_waiting_review() now sets phase=WAITING_APPROVAL (not TERMINATED)
    • Pre-approve state: WAITING_APPROVAL / PARTIAL / needs_review / gate=needs_review
    • Tests: test_patch_run_phase_is_waiting_approval_before_approve
  2. P2 — Write review suggestion before sealing manifest

    • Order: write_review_suggestion() → then finalize_terminal_artifacts() (single finalize)
    • review_suggestion.json is included in final manifest with matching sha256
    • Tests: test_review_suggestion_included_in_final_manifest
  3. P2 — Record terminal trace after review gating

    • InternLoop appends waiting_review / partial trace AFTER review gating, not terminated/succeeded
    • loop_trace.jsonl aligns with gate_result.json and run_meta.json
    • Tests: test_patch_run_trace_reflects_needs_review_not_succeeded

Please confirm ALL prior findings are fixed on 04923ef:

Round 1 (10aa1ef+)

  • Patch runs do not report pass/completed before human review
  • Approve uses direct-finalize (not resume_requested deadlock)
  • Manifest excludes self; sha256 recomputed from disk
  • report_path prefers canonical reports, not diff-summary.md

Round 2 (90b2f3f)

  • InternLoop does NOT write artifact-manifest.json (only finalize_terminal_artifacts)
  • Manifest checksums recomputed from final on-disk files
  • Deferred items not reset to pending by sync

Round 3 (04923ef) — your three P2 above

Also verify unchanged:

  • verify_0_4_acceptance.py is the ONLY authority for Full 0.4 READY
  • 0.4-d cannot pass if 0.4-c fails
  • No skip/xfail/weakened assertions/fake readiness
  • db migrate --dry-run read-only; v4 idempotent
  • sys.executable -m pytest via ToolBroker
  • recovery tests in default pytest
  • No 0.5 schedule install / unattended daemon in this PR

Expected commands (should pass on clean checkout):
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.py

Please answer:

  1. Are ALL previous P0/P1/P2 findings fixed on 04923ef?
  2. Any remaining issues? (P0/P1/P2 with file+line)
  3. Final recommendation: approve / request changes / comment only
  4. Can this PR be merged as a truthful 0.4 stabilization baseline?
  5. Can it be called Full 0.4 READY?

@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: 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".

Comment thread src/loop_pilot/review/service.py Outdated
status="approved",
reason=note,
)
finalize_terminal_artifacts(run_dir, record, gate="pass", review_required=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +197 to +201
manifest = {
"run_id": record.run_id,
"loop_type": record.loop_type,
"terminal_outcome": record.outcome.value if record.outcome else None,
"artifacts": artifacts,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@bosprimigenious

Copy link
Copy Markdown
Owner Author

@codex re-review HEAD d44e3c8

@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: 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".

Comment thread src/loop_pilot/review/service.py Outdated
Comment on lines +170 to +171
self._require_item(run_id)
record = reject_run(self.state_store, run_id, reason)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread src/loop_pilot/review/service.py Outdated
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@bosprimigenious

Copy link
Copy Markdown
Owner Author

@codex review

Require pending/deferred review items before approve/reject/cancel and persist artifact_manifests to SQLite on reject/cancel, matching approve.

@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: 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".

Comment thread src/loop_pilot/review/service.py Outdated
Comment on lines +170 to +171
self._require_item(run_id)
record = reject_run(self.state_store, run_id, reason)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +171 to +174
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@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:

  1. 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
  2. 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@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.
@bosprimigenious

Copy link
Copy Markdown
Owner Author

@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.

@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: 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"}:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@bosprimigenious

Copy link
Copy Markdown
Owner Author

@codex re-review HEAD e967a04 — defer guard (P2-6b) applied. Please confirm approve or list any remaining findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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.
@bosprimigenious
bosprimigenious merged commit f073353 into main Jun 22, 2026
1 check passed
bosprimigenious added a commit that referenced this pull request Jun 22, 2026
Reflect PR #8 merge (11/11 READY, 254 pytest) with inline SVG badges, milestone bar, state machine diagram, and acceptance gate table.
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