Skip to content

feat(capture): durable recovery-job timelines and retention on the receiver - #4574

Merged
Sinity merged 1 commit into
masterfrom
feature/packet/polylogue-06zm
Sep 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/packet/polylogue-06zm

Conversation

@Sinity

@Sinity Sinity commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Bead polylogue-06zm: browser recovery jobs survive client identity loss. Adds retention state and timeline projection to the receiver's capture-job spool; collection runs on the existing orphan-census housekeeping route.

Problem

A capture job lost its history when the client identity changed; nothing owned its deletion.

Solution

Retention state per job (retention_json, idempotent ALTER upgrade), timelines projected from events, and gc() wired into GET /v1/capture-jobs/orphans, the receiver's existing housekeeping pass. request_budget (never enforced) removed. Review 2026-09-03: /realm/tmp/work/flagged-lanes-review-2026-09-03.md (Z1-Z8).

Verification

devtools test tests/unit/browser_capture -n 2   # 172 passed

End-to-end test drives GC through the production route; unwiring it turns the test red.

Residuals

Retention state is client-writable under a valid lease (Z6); timeline pages carry no truncation marker (Z7).

🤖 Generated with Claude Code

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

@Sinity
Sinity enabled auto-merge (squash) September 3, 2026 02:33
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 52968563-2c47-4a51-b8e4-62fd6cb78c3a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T02:42:19.197740Z 7777de7 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity
Sinity merged commit 15b3dd1 into master Sep 3, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/packet/polylogue-06zm branch September 3, 2026 02:34
Sinity added a commit that referenced this pull request Sep 3, 2026
…st_budget (#4575)

## Summary
The two review conditions for polylogue-06zm. #4574 merged the lane's
pre-review head (the remote branch was stale; the rebased push was
rejected non-fast-forward after the merge had already been queued). This
PR carries the reviewed delta.

## Solution
`gc()` runs on `GET /v1/capture-jobs/orphans`, the receiver's existing
housekeeping pass; the end-to-end test drives GC through that route
(unwiring it turns the test red). `request_budget` (never incremented or
enforced) removed; the job insert uses named columns so a receiver
database that already has the retired column still opens.

## Verification
```
devtools test tests/unit/browser_capture -n 2   # 172 passed on the lane head
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>

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

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

Sinity added a commit that referenced this pull request Sep 3, 2026
…re (#4583)

## Summary

Eighteen Codex review findings verified against `cc58ef3e6` and
re-confirmed
by behavior at this branch's base. Eleven are prose or
operation-description
corrections; seven are code defects, each with a test naming the
mutation
that reddens it.

## Findings and disposition

Every finding held at HEAD. None were refuted.

### Docs and config

| # | PR | Location | Claim | Change |
| --- | --- | --- | --- | --- |
| 1 | #4456 | `docs/verification-authority.md:17` | "do not claim ...
recorded run evidence" is unqualified, but `run_tests.py:533` and
`verify.py:585` both call `append_verify_history` | Says what foreground
runs do record, and that the disclaimer is about AgentCTL |
| 2 | #4456 | `docs/internals.md:1002` | "The member row is the durable,
complete inventory" is singular; the same step writes one row per
candidate | Member rows, plural |
| 3 | #4458 | `docs/internals.md:1247` | Owner list named
`verified_blob_receipts`/`blob_publication_reservations`, omitted
`material_observations` and `history_sidecars` | Restated from
`BLOB_OWNERS` (`storage/blob_liveness.py`), whose docstring excludes
receipt caches |
| 4 | #4458 | `docs/sidecars.md:11` | `content_hash` claimed to bind
sidecar bytes to a primary revision; `source.py:924-931` has no FK or
raw-id column | Describes the 32-byte blob hash and the `blob_refs`
`sidecar` edge that is the only ownership link |
| 5 | #4458 | `docs/sidecars.md` | `.lane/` row documents
harvest/coordinator mechanics in a product doc | Row removed. `.lane/`
untracked by #4531, `.gitignore:120`, zero tracked files |
| 6 | #4458 | `docs/internals.md:1251` | Retention said to delete
references only; `cleanup_superseded_raw_snapshots(dry_run=False)` calls
`unlink_unreferenced_blob_hashes_under_exclusion` and returns deleted
blob counts | Retention's immediate unlink stated; integrity repair and
hook-payload replacement remain reference-only |
| 7 | #4458 | `docs/sidecars.md:9` | Antigravity metadata said to live
with the vendor tree only; `origin_specs.py:1470-1477` routes it
`parse_policy="raw-only"` | Durable raw admission documented |
| 8 | #4503 | `docs/repo-layout.md:17` | `.coderabbit.yaml` listed in
the complete tracked root inventory; file deleted | Row removed |
| 9 | #4515 | `docs/hermes-operators.md:528` | Smoke overrides HOME/XDG
but not the five `POLYLOGUE_*` roots that outrank them | `env -u` for
all five |
| 10 | #4571 | `CLAUDE.md:151` | Verb list claims twelve and names ten |
`status` and `bench` named. `COMMAND_SPECS` yields exactly twelve
top-level verbs |
| 11 | #4504 | `.agentctl/project.toml:226` | Description hides the
timed fail-open merge | Discloses the `merge-answered` path and the
30-minute `REVIEW_ABSENT_GRACE_SECONDS` fail-open |

### Code

**12 — `.config/wt.toml:8`.** The substituted worktree path was unquoted
inside
the command substitution, so a path containing a space handed `readlink`
two
operands and `--python` a fragment.

**13 — `.config/wt.toml:14`.** `cp -f` of a live testmon datafile can
copy a
partial transaction and leaves the source's `-wal` behind, so the
committed
tail the copy depends on is missing. Replaced by
`devtools.testmon_provision --seed`, which snapshots through SQLite's
backup
API and leaves nothing behind on failure.

**14 — `polylogue/sources/sqlite_snapshot.py:20`.**
`_SQLITE_SIDECAR_SUFFIXES`
omitted `-journal` while `daemon/backup.py`, `migration_runner.py` and
`audit_leaf.py` all include it. A database in the default journal mode
writes
`-journal`, so `sqlite_database_for_sidecar` returned `None` for it and
the
watcher could not attribute the event to its database.

**15 — `capture_jobs.py` update digest.** `retention` joined the request
digest
in #4574, after update receipts were already durable. A retry/TTL-only
request
replayed against a receipt written before that recomputed a different
digest
and hit `request_id_conflict`. The pre-upgrade digest shape is now an
accepted
match for requests that carry no retention; a retention-bearing request
has no
legacy shape and still conflicts.

**16 — `capture_jobs.py` retention states.** No client sends a retention
object, so every job held the creation default forever and `gc()`
collected
nothing. A terminal retry state now retires a job that no client has
spoken
for: state `active` -> `eligible`, with `timeline_authoritative` derived
from
whether the job actually holds conversation-bearing events. A job whose
retention a client declared is left alone.

**17 — `capture_job_events.py` paging.** The page was read ascending
from the
oldest event with no cursor, so on any job with more than one page of
events
the newest fell out — and the timeline projection is defined
most-recent-first, so it never saw them. The page is now selected
newest-first
and returned in receiver order, with a `before_revision` cursor and
`next_before_revision` for walking older.

**18 — `capture_jobs.py` checkpoint.** Nothing posted to
`/v1/capture-jobs/{id}/events`, and the only automatic event (`created`)
carries empty refs, which the projection predicate excludes — so
`timelines`
was empty for every production job. The checkpoint route, which the
extension
does call, now appends a `capture-attempted` event without advancing the
job
revision.

## Verification

```
devtools verify --quick                       # exit 0, zero "out of sync"
devtools render all --check                   # exit 0, zero "out of sync"
devtools test tests/unit/browser_capture -n 2                     # 176 passed
devtools test tests/unit/devtools/test_worktree_hooks.py \
  tests/unit/devtools/test_testmon_provision.py \
  tests/unit/sources/test_sqlite_sidecars.py \
  tests/unit/sources/test_live_watcher.py -n 2                    # 141 passed
```

Ten tests added; each docstring names its anti-vacuity condition —
remove
`-journal` from the suffix tuple, swap `backup()` for `shutil.copyfile`,
drop
the inner quotes in `wt.toml`, delete the legacy-digest branch, return
`current` from `_retention_after_retry`, delete the checkpoint
`_append_event`
call, or restore ascending `ORDER BY event_revision LIMIT`.

Selected scope only; no full-corpus run. Three api/mcp tests are red on
master
itself (`test_archive_tiers_api_session_costs_read_index_tier`,
`test_existing_same_version_ops_database_receives_additive_call_log`,
`test_record_context_delivery_requires_initialized_user_tier`) —
inherited,
untouched here.

## Residual risk

Finding 18's fallback ref is `intent:<intent_key>` when a checkpoint
payload
names no conversation. That key is an intent, not a conversation, in a
conversation-keyed map; the alternative is the empty projection the
finding
reports. Worth a follow-up if checkpoint payloads should carry
conversation
refs directly.

Finding 17 changes the default page from oldest-first to newest-first,
and
`has_more` is now cursor-derived rather than `total > limit`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):

Resolving the fixed, stale and refuted threads; tracked threads stay open.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at f88b4a6):

Resolving every thread listed; confirmed defects are fixed under the named bead.

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