Skip to content

fix(daemon): retain typed sources with additional roots - #4515

Merged
Sinity merged 4 commits into
masterfrom
feature/packet/polylogue-4zqh3
Sep 2, 2026
Merged

Sinity merged 4 commits into
masterfrom
feature/packet/polylogue-4zqh3

Conversation

@Sinity

@Sinity Sinity commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Makes daemon --root inputs additive and documents the resulting source-selection behavior.

Problem

Supplying an explicit root replaced every typed source, which stopped provider-specific sources such as Codex state, Hermes SQLite, the inbox, browser capture, and hooks from being watched.

Solution

Start from typed defaults, replace only an explicit browser-capture spool, and append deduplicated export roots with ordinary export suffixes. Preserve the inbox and browser-capture contracts when their roots are named explicitly. Update daemon and configuration guidance to describe additive roots and fixture isolation with a disposable HOME.

Verification

  • nix develop --accept-flake-config --command devtools test tests/unit/daemon/test_daemon_cli.py -k 'explicit_archive_inbox_root or explicit_browser_capture_root or configured_root_does_not_duplicate_typed_default or additional_root_excludes_provider_state_suffixes or builds_sources_from_roots or spool_override_replaces_default_browser_capture_source or polylogued_run_can_skip_configured_source_catchup': 8 passed.
  • agentctl job start polylogue verify_quick --workspace packet-polylogue-4zqh3: passed at cacb5726982bb9f568ddffd5096636e9b3f86270 (job d75ea71b-8428-462f-bbe5-e86e7b37575c).
  • git diff --check origin/master...HEAD: clean.

Residual risk

The full daemon CLI file previously ran 128 passed and 3 failed in lifecycle/status teardown paths that open an uninitialized ops.db; the changed source-selection tests passed. devtools verify atlas is blocked by repository-wide stale atlas anchors, including unchanged files.

LANE-BRANCH: feature/packet/polylogue-4zqh3
LANE-COMMIT: cacb572
LANE-QUICK: green


Receipt: harvest-e779ba89434e1053e9ddba6e863a2de8
Bead: polylogue-4zqh3

@coderabbitai

coderabbitai Bot commented Sep 2, 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: 6af02946-7292-47ba-94aa-ee009ae26559


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 2, 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-02T01:32:31.654650Z 277bfef Manual request
ℹ️ 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.

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

ℹ️ 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 polylogue/daemon/cli.py Resolved
@Sinity Sinity changed the title fix(sources): enforce complete topology capability census fix(daemon): retain typed sources with additional roots Sep 2, 2026
@Sinity
Sinity force-pushed the feature/packet/polylogue-4zqh3 branch from 925e3fe to 277bfef Compare September 2, 2026 01:21
@Sinity

Sinity commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

@codex review

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

ℹ️ 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 polylogue/daemon/cli.py Resolved
Comment thread docs/hermes-operators.md Resolved
Sinity added a commit that referenced this pull request Sep 2, 2026
## Summary
`.lane/body.md` and `.lane/title` leave the index; `.gitignore` already
lists `.lane/`.

## Problem
Every merged lane PR rewrote the two tracked files, so every other open
lane branch conflicted with master on them (#4509 rebased four times
tonight, #4513/#4515/#4516/#4520/#4522 all cycled through the rebase
reaction for this alone). The harvest reads the publication text from
the worktree, not from the commit.

## Solution
Untrack the two files. Lane branches that still carry them conflict once
more (delete versus modify) and then never again.

## Verification
```
devtools verify --quick   # exit 0
```

## Residual risk
A lane that force-adds `.lane/` reintroduces the churn for itself only.

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

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

Receipt: session-01YGi8wLWGR2HYBh8p8fXFXz

Co-authored-by: Claude Fable 5.1 <[email protected]>
@Sinity
Sinity merged commit a238d27 into master Sep 2, 2026
3 checks passed
@Sinity
Sinity deleted the feature/packet/polylogue-4zqh3 branch September 2, 2026 16:32
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 added a commit that referenced this pull request Sep 3, 2026
…4587)

## Summary

Fixes the eleven verified Codex review findings in the sources / daemon
/
operations sweep. Each was re-confirmed at this branch's base before
being
changed; none were taken on faith from the sweep file.

## Findings and what changed

| # | PR | Site | Claim | Action |
| --- | --- | --- | --- | --- |
| 1 | #4455 | `daemon/backup.py` `_source_recoverability_proofs` | a
full-snapshot append row is hashed as a byte window | fixed: falls back
to the full prefix `[0, end)` when the window does not prove the blob |
| 2 | #4457 | `operations/append_acquisition_replay.py` | unbounded
`handle.readline()` during replay | fixed: bounded at 1 MiB, matching
live acquisition |
| 3 | #4506 | `sources/live/deferred_cursor.py` | semantic frontier
re-derived from current bytes with no comparison to retained evidence |
fixed: recomposed frontier must reproduce the recorded **body** digest |
| 4 | #4506 | `sources/origin_specs.py` | ChatGPT derives
`inheritance_branch_point` from `mapping.parent`/`mapping.children` |
fixed: declared structurally absent |
| 5 | #4515 | `sources/live/source_selection.py` | no typed-vs-generic
tiebreak, so a typed source loses ownership to a nested generic root |
fixed: ownership resolved among sources that accept the path |
| 6 | #4539 | `sources/live/watcher.py` | tool-outcome semantics changed
without a parser-fingerprint bump | fixed: `live-batched-v2` ->
`live-batched-v3` |
| 7 | #4549 | `sources/live/batch.py` | legacy promotion commits durably
before append planning succeeds; resynthesized cursor never returned |
fixed: promotion deferred behind a successful plan; cursor handed back
to the caller |
| 8 | #4549 | `sources/sqlite_snapshot.py` | `sqlite_sequence` excluded,
so insert-then-delete on AUTOINCREMENT yields no digest change | fixed:
AUTOINCREMENT state included |
| 9 | #4549 | `sources/live/batch.py` | full-head Claude authority
computed from the live file | fixed: live prefix must reproduce the
retained blob digest |
| 10 | #4554 | `parsers/base_support.py` -> write boundary | idless
model turn yields `("model_output", None)` and the write rejects the
whole session | fixed at the write boundary (see note) |
| 11 | #4558 | `sources/origin_specs.py` | fingerprint memo keyed on
`(path, mtime, size)` | fixed: keyed by content digest |

None were refuted. Master moved while this work ran; `git diff` over all
eleven files across that range is empty, so every cited line still
described
current code.

### Finding 1: live exposure remains unconfirmed

The code-level defect is real and now covered by a test. Its **live**
reachability is not established: every current production caller of
`admit_raw_observation` (`revision_governance.py:825,3995,4126`) passes
`prior_head=None`, which never reaches the append arm that writes the
full-payload-with-tail-offsets shape. This fixes the defect without
claiming
it was reachable in production.

### Finding 6: schema-regime classification

Classified as **none of the schema-regime classes** -- it is not a
schema
change. There is no DDL edit and no derived-tier version bump, so no
`DerivedDeltaClass` declaration in `storage/sqlite/lifecycle.py`
applies; that
table is keyed on index-schema version pairs.

It is a *parser-semantic* change, whose declared route is the
fingerprint bump
itself. `base_support.py` is already inside the origin-spec
parser-semantic
closure (verified: `_semantic_source_paths` for a parser resolves it),
so the
origin-scoped fingerprint recomputed on its own with #4539. The gap was
only
the live watcher's hand-written literal. Bumping it marks every existing
live
cursor as stale, and the watcher routes those sources back through parse
on
its next pass -- the production convergence route. Nothing forces a
rebuild by
hand.

**Operational consequence:** the first daemon pass after this lands
re-ingests
every live-watched source once. That is the intended cost of the
correction,
but it is a real one.

### Finding 10: fixed at the write boundary, not the parser

The sweep points at `base_support.py:633-635`. The parser genuinely
cannot fix
this: `attachment_from_meta` takes `message_id: str | None` and there is
no
identity to name when it is `None`. The stored message id exists only at
the
write boundary, which is where the producer is now supplied -- covering
both
the parser-declared and role-derived paths. The fallback completes
missing
provenance and never overwrites parser-supplied evidence.

### Findings 3 and 9 are one fix

Both derived Claude authority from bytes on disk at planning time rather
than
from retained evidence, so a rewrite preserving the prefix length
inherited
the previous observation's authority. Finding 3 (deferred cursor)
compares the
recomposed frontier's body digest against the recorded one; finding 9
(full-head resynthesis) requires the live prefix to hash to the retained
blob.
The reconstructed-chain branch already proved its prefix byte by byte
and is
left alone.

Finding 3's check is deliberately on the **body**, not the whole
frontier
token: `ClaudeSemanticFrontier` is "replaceable header plus stable
body", and
an equality check on the token broke
`test_deferred_claude_cursor_rebases_frontier_after_header_rewrite`,
which
protects legitimate rebasing onto a rewritten header.

## Verification

Anti-vacuity was verified mechanically, not asserted: with all ten
source
files reverted to master and the new tests kept, every new test fails.

```
git checkout <master> -- <the ten source files>
devtools test tests/unit/sources/test_reviewed_acquisition_defects.py \
  tests/unit/storage/test_attachment_idless_model_turn.py \
  tests/unit/sources/test_live_deferred_append_dedup.py \
  tests/unit/sources/test_live_append_cursor_resynthesis.py \
  tests/unit/daemon/test_backup.py -n 2
-> 15 failed, 79 passed
```

The 15 are the 13 new tests plus the 2 existing expectations this change
updates. `test_backup_still_proves_a_window_shaped_append_row`
**passes** on
master -- it is the control proving finding 1's fix did not
over-generalize
into "always read the full prefix".

With the fixes restored, the same selection is green:

```
devtools test tests/unit/sources/test_reviewed_acquisition_defects.py -n 2         -> 5 passed
devtools test tests/unit/sources/test_live_deferred_append_dedup.py -n 2           -> 8 passed
devtools test tests/unit/sources/test_live_append_cursor_resynthesis.py -n 2       -> 13 passed
devtools test tests/unit/daemon/test_backup.py \
  tests/unit/storage/test_attachment_idless_model_turn.py -n 2                     -> 68 passed
devtools verify --quick                                                            -> all 12 gates ok
devtools render all --check                                                        -> exit 0, no "out of sync"
```

Collateral selection over the consumers of the changed modules (live
watcher,
source snapshot, source differential, catchup planning, codex state, and
the
four attachment suites):

```
devtools test tests/unit/sources/test_live_watcher.py \
  tests/unit/sources/test_source_snapshot.py \
  tests/unit/sources/test_source_differential.py \
  tests/unit/sources/test_live_catchup_planning.py \
  tests/unit/sources/parsers/test_codex_state.py \
  tests/unit/storage/test_attachment_acquisition.py \
  tests/unit/storage/test_attachment_first_class_ids.py \
  tests/unit/storage/test_source_attachments.py \
  tests/unit/storage/test_attachment_relink.py -n 2
-> 1 failed, 218 passed
```

After the fixture fix below, the one affected file was re-run on its
own:

```
devtools test tests/unit/sources/test_live_watcher.py -n 2   -> 125 passed
```

The other eight files were green in the combined run and are untouched
by
that fixture change; no combined re-run was made, so the "219" total is
not
claimed as an observed number.

The single failure was
`test_parser_fingerprint_change_triggers_reingest`,
caused by this branch and not inherited. It simulated a fingerprint
change by
monkeypatching `_PARSER_FINGERPRINT` to the *literal*
`"live-batched-v3"`,
which finding 6 makes the real value -- so the patch became a no-op, no
change
was simulated, and no reingest fired.

The bump is not miswired; the fixture collided with it. The sentinel now
derives from the real constant (`f"{_PARSER_FINGERPRINT}-changed"`), so
the
test asserts the same behaviour and cannot silently no-op on a future
bump.
Finding 6's own test
(`test_superseded_parser_fingerprint_refuses_append_
planning`) independently proves a `live-batched-v2` cursor refuses
append
planning, and went red when the constant was reverted.

Selected scope only: this proves the selected files, not the corpus.

## Residual risk

- **Finding 6 forces a one-time live re-ingest** of every watched source
on
  the next daemon pass.
- **Finding 8 changes `sqlite_logical_revision`** for every
AUTOINCREMENT
database, so previously recorded identities differ once and those
sources
  re-acquire on next observation. Self-healing, but not free.
- **Finding 5 changes ownership for overlapping default roots** beyond
the
  reported case: a `.db` under `~/.codex/sessions/` now resolves to
`codex-state` rather than `codex`, because only `codex-state` accepts
it.
That looks correct, but it is a behaviour change the finding did not
name.
- **Finding 7** delays promotion until planning succeeds, not until the
plan
is *applied*. Closing that gap needs a larger refactor of the ingest
stage.
- **Finding 11** reads parser sources instead of stat-ing them. A
per-process
digest cache keyed on full inode identity including `st_ctime_ns` (which
`os.utime` cannot restore) keeps this correct and measurably faster than
before: 0.818 ms/call warm vs 1.343 ms/call for the previous stat-keyed
  signature, over a 449-file / 9 MB closure.
- Three tests are reported 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`). None are
in
  files this branch touches and none were in the selections run here.

---------

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 0914f89):

  • P2 polylogue/daemon/cli.py:525: Fixed on master (checked at 0914f89): deepest_source_for_path now resolves ownership among the sources that accept the path, so a generic additional root nested under a typed root no longer takes over typed artifacts (polylogue/sources/live/source_selection.py:37-44).

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

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 62.F042 / P1: fixed-already at the checked revision: The workspace_env fixture used by the daemon integration tests now redirects HOME to a temporary home directory at tests/conftest.py:764,768 as well as redirecting the archive. Subprocesses inheriting that environment do not discover the developer's real default provider directories.

Only the rows listed above are dispositioned. Held findings remain open.

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