Repository navigation
feat(runtime): local-first SQLite store for cycle history with PR-comment recovery - #227
Conversation
Split comment_run_history into history_entry, which reduces one trusted comment to its run IDs, finding tokens and schema-2 receipts, and fold_history, which folds those entries into runs. ProviderComment gains the provider's updated_at. Behaviour is unchanged; the local cycle history (#223) folds the same entries from stored tokens. Refs #223
Schema 18 adds cycle_history_* and cycle_publications tables to the telemetry database, holding only identifiers and closed tokens. A --from resume on GitHub makes one GraphQL freshness check and uses the stored history when it matches the sync watermark; otherwise it reconciles the comments edited since (?since=) and rebuilds after a deletion, a trusted-author change, or with no usable store. A failed check stops as BLOCKED. After each review, resolve and rereview the history is reconciled and the stage's schema-2 receipt confirms its publication; an unobserved one is a warning and the next dispatch of that stage is told to reuse a comment carrying the earlier attempt ID. A per-machine writer lock (stale after the process exits or 24 hours) and foreign-receipt detection stop conflicting writers as BLOCKED. The change request remains the record. Closes #223
sqlite3's connection context manager commits but does not close, so the Windows runner could not delete the temporary database. A helper now commits and closes each connection. Refs #223
Implementation summary — #223Status: IMPLEMENTED · decision Resumed an interrupted run: its uncommitted work (history store, schema 18, driver wiring, docs, tests) was kept as-is; this run fixed a stale Commits
Verification (agent-reported)
Checks on
Not reviewed yet; review is a later stage. |
Initial review — #227 (work item #223)[CCR-20261013-227] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2Verdict: CHANGES_REQUESTED · reviewed head Summary and scopeI reviewed the whole accumulated diff from The design holds up: rows hold tokens only, every comment is parsed before anything is written, writes are idempotent per comment, deletions are caught by the count, and a mismatch on trusted authors or schema forces a full rebuild. Findings[REV-001] · medium · open · - · blocks:yes — On Windows, a crashed cycle's writer lock blocks every resume for 24 hours
Execution evidence (repro outside the repo, The new test Suggested direction (not prescriptive): check liveness on Windows too ( [REV-002] · low · open · - · blocks:no — A recovered-review retry leaves a pending outbox entry that later prompts name as a lost publication
Execution evidence (store API, same sequence as the driver): Suggested direction: don't record an outbox entry for a Security triageThe repository's
Result: no vulnerabilities or potential risks found. Commands and flows executed
Unverified
CI
Residual risks
|
… verdict retries REV-001: _process_alive now asks OpenProcess/WaitForSingleObject on Windows instead of returning None, so a killed cycle's lock is stale at once rather than after 24 hours. The dead-process lock test runs on Windows again. REV-002: the recover=False verdict retry of a recovered review no longer records a pending outbox entry, so later prompts do not name it as a lost publication.
Review resolution — #227 (work item #223)[CCR-20261013-227] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2[CCT-20261013-227] · deep_coder · anthropic/claude-opus-5-5→? · high · triaged:734b8dc0579ddadc1f374ab7b9e0826ec917e1df · schema:2Status: RESOLVED · head This run continues an earlier attempt of the same resolve stage. That attempt wrote and pushed the fix commit Findings[REV-001] · medium · resolved · valid · blocks:yes — On Windows, a crashed cycle's writer lock blocks every resume for 24 hours
Disposition [REV-002] · low · resolved · valid · blocks:no — A recovered-review retry leaves a pending outbox entry that later prompts name as a lost publication
Disposition Verification (agent-reported)
The local run and CI share the Python test suite. The local run is on WSL2 Linux and does not use the Windows API. That path was checked by the Windows CI job. Post-change review and security triage
Checks on
|
| Check | State |
|---|---|
| Skills, manifests, and Bash installer (push) | pass |
| Skills, manifests, and Bash installer (pull_request) | pass |
| PowerShell installer (push) | pass |
| PowerShell installer (pull_request) | pass |
Residual risks
- The initial review's residual risks are unchanged: one-second freshness timestamps, PID reuse within the 24-hour window (on both platforms now), the difference in lock acquisition between fresh and resumed cycles, and no exclusion between machines.
Rereview — #227 (work item #223)[CCR-20261013-227] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2[CCT-20261013-227] · deep_coder · anthropic/claude-opus-5-5→? · high · triaged:734b8dc0579ddadc1f374ab7b9e0826ec917e1df · schema:2[CCR-20261013-002] · senior_reviewer · anthropic/claude-opus-5-5→? · high · schema:2Verdict: APPROVED · reviewed head Scope and what changed since the previous reviewI rereviewed the whole accumulated diff from merge base
The rest of the accumulated diff is the code the initial review judged at Previous findings[REV-001] · medium · resolved · valid · blocks:yes — On Windows, a crashed cycle's writer lock blocks every resume for 24 hours
Fixed and verified by execution. On Windows,
[REV-002] · low · resolved · valid · blocks:no — A recovered-review retry leaves a pending outbox entry that later prompts name as a lost publication
Fixed and verified by execution. New findingsNone. Security triage
Result: no vulnerabilities or potential risks found. Commands and flows executed
Unverified
CI
Residual risks (unchanged, non-blocking)
|
Closes #223 — #223
Keeps a verified local copy of each change request's review history (runs, findings, claims, survivals) in the existing telemetry database, so a
--fromresume on the same machine makes one lightweight remote check instead of refetching and reparsing every comment. PR comments remain the durable record.Diagnosis
seed_historyinscripts/run_cycle.pycalledcomment_run_historyover every comment on each resume.history_entry+fold_history, store those tokens in schema-18 tables, and verify them with one GraphQL probe (head, comment count, newestupdatedAt) before use; reconcile via REST?since=; rebuild on deletion, trusted-author change, or schema change.Design
REV-/attempt IDs, severity, status, disposition, SHAs), enforced byCHECKconstraints and identifier grammars. A hash says when the trusted-author list changed; logins, titles and bodies are never stored.BLOCKEDwith the reason. Unusable database → skipped, history rebuilt from comments.review/resolve/rereviewattempt is recorded aspending; the post-stage sync marks itpublishedwhen a trusted comment carries its schema-2 receipt. Unobserved → stage warning, and the next dispatch of that stage is told to reuse a comment carrying the earlierattempt_idinstead of posting again. The runtime never posts.finally); a receipt from an attempt this machine never dispatched stops the cycleBLOCKEDafter reconciling. GitHub has no atomic check-and-publish, so cross-machine exclusion is reduced, not guaranteed.Work units
WU-1history_entry,fold_history,trusted_logins);ProviderComment.updated_atscripts/review_contract.pycomment_run_historytestspython3 -m unittest discover -s tests→ exit 0, 1286 tests OKWU-2(WU-2 imports the new helpers)WU-2scripts/cycle_history.py,scripts/run_cycle.py,scripts/telemetry.py,scripts/runtime.manifest,docs/telemetry.md,docs/review-cycle.md,docs/instrumentation.md,CHANGELOG.md,tests/test_cycle_history.py,tests/test_stage_recovery.py,tests/test_work_item_outcomes.pytests/test_cycle_history.py(rebuild, verified resume, reconcile new/edited/deleted, trusted-author change, idempotent reprocessing, privacy, outbox, stale lock, foreign writer, driver resume)python3 -m unittest discover -s tests→ exit 0, 1286 tests OKcycle_history_*/cycle_publicationsmanually if desired)Verification (agent-reported)
python3 -m unittest discover -s tests→ exit 0,Ran 1286 tests … OK.headRefOid,totalCountand the newestupdatedAt(2026-10-13T13:23:25Z); RESTissues/224/comments?since=2026-10-13T13%3A23%3A25Zreturns that same comment with an identicalupdated_atstring, confirming matching formats and inclusivesince.python3 scripts/validate-package.pyand the installer jobs (not permitted in this executor); CI runs them.