Skip to content

fix(capture): stream capture bodies into the spool instead of refusing - #5725

Merged
Sinity merged 13 commits into
masterfrom
claude/limits-capture-stream
Sep 29, 2026
Merged

Sinity merged 13 commits into
masterfrom
claude/limits-capture-stream

Conversation

@Sinity

@Sinity Sinity commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

POST /v1/browser-captures no longer refuses bodies over 128 MiB, and nothing downstream of the receiver undoes that. The body streams into a spool staging file, is validated in one streamed pass, and is published with os.replace. The ingest worker decodes the retained capture as a stream too. Bead: polylogue-39faa (the capture-body part).

Problem

browser_capture/server.py read every capture body whole under MAX_BROWSER_CAPTURE_BODY_BYTES (128 MiB), then ran json.loads, BrowserCaptureEnvelope.model_validate and write_capture_envelope_bytes on the in-memory body. A valid capture larger than the cap was refused, and the conversation was lost. Removing the cap alone would have opened three new failures, all raised in review:

  • The ingest worker read_bytes()-ed and json.loads-ed the retained capture, so a huge capture would crash the worker out of memory.
  • The spool byte quota ignored the incoming file's size.
  • Staging files from an interrupted upload were never reclaimed.

Solution

  • New browser_capture/capture_stream.py:
    • stage_capture_body reserves the declared Content-Length on the spool filesystem before reading any byte. It uses posix_fallocate, or compares free space where allocation is unsupported. It then copies the body in bounded reads while hashing. The only byte refusal is the physical one: a typed SpoolStorageExhaustedError, answered with retryable 507 spool_storage_exhausted. A short body is incomplete_body (400).
    • Each staging file stays flock-ed until it is published or discarded. BrowserCaptureHTTPServer reaps, at startup, every staging file whose lock it can take. A live upload in another receiver sharing the spool is left alone.
    • summarize_capture_file makes one ijson pass. It validates the envelope head and folds the admission facts (convergence, dedup hash, accepted identities). The raw payload and the provider_meta objects are digested, not built.
    • capture_decode.load_capture_for_ingest decodes a retained capture for parsing from a stream. Each attachment carrier is handed to a spill callback as it is read.
  • receiver.admit_staged_capture publishes the staged file by os.replace. Resident artifacts are read through the same streamed pass. The 2 GiB byte quota over resident artifacts is removed; the file-count quota stays.
  • ingest_record routes browser-capture raws through load_capture_for_ingest. Carriers are decoded chunk by chunk into the blob store and reach the parser as a SpilledCarrier, which becomes ParsedAttachment.precomputed_blob. JSON cannot produce a SpilledCarrier, so a posted envelope cannot claim a blob. Attachment identity is unchanged: inline_content_hash is the blob hash on both routes.
  • JSON control routes keep their in-memory bound, renamed MAX_CONTROL_BODY_BYTES. Capture-job control bodies keep their 1 MiB bound.
  • Review round 2:
    • Each capture body read has a 60 s idle deadline (CAPTURE_BODY_IDLE_TIMEOUT_S). An upload that stops sending gets 408 upload_stalled, and its staging file and reservation are released. The extension retries a 408 the same way it retries a 5xx.
    • posix_fallocate raising OverflowError (a length past off_t) or EFBIG now gives the typed 507 spool_storage_exhausted. Content-Length must be ASCII digits.
    • CaptureSummary.head keeps no turn. The session's at-least-one-turn rule is checked with one validated placeholder, and the placeholder is dropped afterwards.
    • The worker still publishes spilled carrier blobs itself, since it holds no write lease, but the writer now adopts them: ArchiveBlobPublisher.adopt_published queues a reservation. Under the publisher slot that GC's unlink excludes, flush first checks that every adopted blob is present at its declared size, then reserves it, and the receipt is consumed with the attachment reference. If a blob was reclaimed, flush raises AdoptedBlobEvictedError, a new EVICTED storage fault. The input is then retried rather than refused. Both writers that read precomputed_blob adopt it: ingest_batch._write_session and ingest_governance._writer_preacquired_attachments. The inactive-candidate publisher verifies the blob instead of reserving it. When the worker deduplicates against an existing copy, it renews that copy's mtime (BlobStore.publish_prepared_renewing), which keeps it inside GC's age window until the writer adopts it. The worker now classifies a storage fault during the decode as a storage fault rather than a parser defect.
    • Structured events use registered log field names (bytes, reclaimed, timeout_ms). The earlier unregistered names were dropped.

Verification

  • agentctl job start polylogue verify_quick (job 1971, head 50f82da): succeeded, exit 0. The one later commit (04968fa) changes a single line in capture_stream.py.
  • agentctl job start polylogue pytest_focused -- tests/unit/browser_capture tests/unit/sources/test_browser_capture.py tests/unit/daemon/test_browser_capture_instance_attribution.py tests/unit/maintenance/test_browser_spool_restoration.py tests/unit/pipeline/test_binary_payload_parse_parity.py tests/unit/pipeline/test_ingest_batch.py tests/unit/storage/test_ingest_governance.py tests/unit/pipeline/test_acquisition_blob_gc_age_gate.py tests/unit/storage/test_attachment_acquisition.py tests/unit/pipeline/test_ingest_worker_assembly.py tests/unit/core/test_storage_faults.py (job 2021, head 04968fa): 8 failed after rerun, everything else passed. None of the 8 is caused by this PR:
    • 7 are in tests/unit/sources/test_browser_capture.py and raise IngestDaemonRequiredError from api.ingest.parse_sources. This is the same inherited failure noted in round 1.
    • 1 is test_ingest_governance.py::test_membership_that_becomes_eligible_after_preparation_defers_publication. It also fails on master 915a1f3 (job 2060, 1 failed).
  • devtools schema closure: capture_decode.py joins the closure, as recorded in round 1. This round also edits closure members ingest_worker.py, blob_store.py, blob_publication.py, ingest_batch/_core.py, ingest_governance.py, archive.py, core/storage_faults.py and pipeline/ingest_outcomes.py, so the derived schema identity moves. No rebuild was started.
  • New regression tests, each naming its anti-vacuity condition:
    • test_write_session_reserves_a_worker_published_blob_until_its_reference_commits and test_write_session_refuses_a_worker_published_blob_gc_reclaimed (batch writer).
    • test_precomputed_attachment_is_reserved_and_referenced_by_the_writer and test_precomputed_attachment_reclaimed_before_the_writer_is_refused (cohort writer).
    • test_receiver_cancels_a_stalled_upload_and_releases_its_reservation, test_receiver_answers_an_unrepresentable_body_length_with_the_physical_refusal (real posix_fallocate with 2**63) and test_receiver_refuses_a_content_length_that_is_not_ascii_digits.
    • test_a_body_past_the_largest_file_is_the_typed_physical_refusal, test_the_admission_summary_retains_no_turn and test_a_session_without_turns_is_still_refused.
    • An mtime-renewal assertion added to the worker streaming test.
  • The extension test (background.test.js, 408 queued for retry) was not run here: no declared agentctl operation runs the extension's vitest suite.

Self-review

  • Sibling sites. Every reader of precomputed_blob was checked. archive.py's _preacquire_attachment_blobs never records a precomputed blob, and write.py refuses one without preacquisition, so the two writers that trust it (batch and cohort) are the ones changed. Both now adopt. ChatGPT asset blobs travel the same field, so they get the same protection. Every other storage-exhaustion errno (EFBIG) takes the same typed refusal as ENOSPC.
  • Cancellation and shutdown in loops. The staging copy loop was the one blocking loop with no exit. The idle deadline now bounds it. ThreadingHTTPServer handler threads are daemon threads, so shutdown waits at most one deadline. The _locked_staging_file retry loop only repeats when a concurrent reaper removed its file.
  • Unbounded reads. The receiver holds no turn after validating it. The ingest decode still builds the conversation tree (thread 1, refuted with scope below), and that is filed as polylogue-4vchr.
  • Fail-open fallbacks. precomputed_blob was trusted without an existence check. It now fails closed with a retryable storage fault. The one remaining trusting branch is taken only when _write_session is called without a publisher, which no production caller does.
  • Compatibility shims. None added. The worker keeps publishing because it has no write lease, but the writer's adoption is the only path that records the blob.
  • Tests prove the production route. The adoption tests call _write_session and publish_ingest_cohort with a real ArchiveBlobPublisher over an initialized archive. The receiver tests go through the HTTP server on a real socket, and the 2**63 case uses the real posix_fallocate.

Residuals

  • The worker's decoded tree still holds the conversation itself: turn text and any native transcript, which the whole-session writer consumes. Peak memory therefore scales with the conversation, not with its attachment bytes. The replay route (revision_backfill._parse_one) still takes the retained payload as bytes. Streaming the conversation into a disk-backed sink is polylogue-4vchr.
  • A single JSON scalar is still materialized whole by ijson, both in the receiver's pass and in the worker's pass. That includes one attachment carrier at a time.
  • The idle deadline applies per socket read. A client that sends one byte just inside each deadline still holds its reservation for as long as it keeps trickling.
  • A storage fault during the worker's decode is classified retryable, but it is still recorded through the per-raw failure path rather than escaping the batch the way writer-side faults do.
  • The 16 MiB browser-action attachment bounds (browser_capture/actions.py, daemon/browser_capture.py) are unchanged. They need a chunked extension transport first, as recorded in polylogue-39faa, so the bead stays open.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Sinity and others added 2 commits September 28, 2026 16:59
POST /v1/browser-captures no longer refuses bodies over 128 MiB. The body is
copied in bounded reads into a staging file in the spool while hashed, one
streamed pass validates the envelope and folds every admission fact, and
publication is an os.replace of the staged file. Resident artifacts are read
by the same streamed pass. Control routes keep their in-memory bound.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6
@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 15:09
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 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-28T20:20:25.447125Z 0333453 Draft marked ready
🔒 Security Review ✅ Completed 2026-09-28T20:22:33.709679Z 0333453 Draft marked ready
ℹ️ 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

except OSError as exc:
logger.warning("browser_capture.write_failed", request_id=self._request_id(), error=repr(exc))
self._safe_error(HTTPStatus.INTERNAL_SERVER_ERROR, "write_failed")

P2 Badge Preserve the retryable storage-exhaustion response

If staging succeeds but disk exhaustion occurs later while creating the provider directory, replacing the staged file, or fsyncing the directory, this catch converts ENOSPC/EDQUOT into 500 write_failed. The same physical-pressure condition is returned as the retryable 507 spool_storage_exhausted only during staging, so clients receive inconsistent terminal behavior depending on which filesystem operation encounters the full disk; apply is_storage_exhausted here as well.

AGENTS.md reference: AGENTS.md:L97-L100

ℹ️ 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/browser_capture/receiver.py Resolved
…the shape

The streamed parser reads integer tokens exactly and lowers fractions to the
float json.loads produces, so a valid wide integer no longer overflows the
float mode. The raw-payload shape keeps only what native detection reads,
and a string's digest is its JSON encoding hashed in chunks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

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

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

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

ℹ️ 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/browser_capture/receiver.py Resolved
Comment thread polylogue/browser_capture/server.py Resolved
@Sinity
Sinity disabled auto-merge September 28, 2026 16:00
@Sinity
Sinity marked this pull request as draft September 28, 2026 16:00
@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Paused as a draft and auto-merge disabled. The latest review shows that accepting unbounded captures at the receiver is not enough on its own:

  • the ingest worker still reads and fully decodes the retained capture (ingest_worker.py → raw_payload/decode.py);
  • the spool quota decision ignores the staged file's size;
  • abandoned .staging files are never reclaimed after a restart;
  • the padding scan slices the carrier.

These are required for the route to be safe and are recorded on polylogue-39faa. This PR needs an owner to finish them before it can merge.

Sinity and others added 4 commits September 28, 2026 18:47
The receiver admits captures of any size, so everything downstream of it
must hold that too.

- The ingest worker decodes a browser-capture raw as a stream: the blob
  is never read whole, and each attachment carrier is decoded straight
  into the blob store and recorded as a precomputed blob.
- Staging reserves the declared body length on disk (posix_fallocate,
  or free space where allocation is unsupported) before reading any
  byte; the only byte refusal is the physical one, a typed
  SpoolStorageExhaustedError answered with 507. The 2 GiB byte quota
  over resident artifacts is gone.
- Staging files stay flock-ed until published or discarded, and the
  receiver reaps unheld ones at startup.
- provider_meta objects are digested while streaming instead of built,
  and the carrier padding scan no longer copies the carrier.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The ingest worker imported capture_stream, pulling the whole receiver
admission fold into the derived schema identity closure. The streamed
JSON primitives and the ingest loader move to capture_decode, which is
the one module the closure admits. The closure baseline records it and
drops members that are no longer reached; two stale pattern-baseline
anchors are pruned.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
…re-stream

# Conflicts:
#	devtools/patterns/baselines/cli-nonzero-click-exit.txt
#	devtools/patterns/baselines/legacy-prose-logging.txt
@Sinity
Sinity marked this pull request as ready for review September 28, 2026 20:09

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

ℹ️ 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 and others added 5 commits September 28, 2026 22:23
…re-stream

# Conflicts:
#	polylogue/browser_capture/models.py
#	tests/unit/browser_capture/test_receiver.py
A declared Content-Length is reserved before the first read, so a client
that stopped sending pinned that space indefinitely. Each body read now
has an idle deadline; a stalled upload is answered 408 upload_stalled
and its staging file (and reservation) released. The extension retries
a 408 like a 5xx.

posix_fallocate raises OverflowError for a length no off_t holds and
EFBIG past the largest file; both now become the typed 507
spool_storage_exhausted refusal. Content-Length must be ASCII digits.

The admission summary no longer keeps the first validated turn in its
head, so a replacement capture's first turn is not held while the
resident artifact is summarized. Structured events use registered
field names.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The streamed capture decode publishes spilled carrier bytes from a parse
worker with no write lease. Deduplicated against an old unreferenced
blob, those bytes were GC-eligible until admission, and the writer
recorded precomputed_blob as acquired without checking it existed.

ArchiveBlobPublisher.adopt_published queues a reservation for such a
blob; flush checks every adopted blob is present (with its declared
size) under the publisher slot GC unlinks under, then reserves it, and
the receipt is consumed with the attachment reference. A reclaimed blob
raises AdoptedBlobEvictedError, a new EVICTED storage fault, so the
input is retried rather than refused. The batch writer and the
membership-cohort writer adopt every precomputed blob; the inactive
candidate verifies instead of reserving. The worker renews the age of a
copy it deduplicates against, and classifies a storage fault during the
decode as one.

The admission summary tests cover the stripped head.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
A turn's own model validator reruns on an instance, so an empty
constructed placeholder failed every session. Use one validated turn.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@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.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 02:58
@Sinity
Sinity merged commit c540c43 into master Sep 29, 2026
4 of 5 checks passed
@Sinity
Sinity deleted the claude/limits-capture-stream branch September 29, 2026 03:02
Sinity added a commit that referenced this pull request Sep 29, 2026
Master's blob adoptions (#5725) join the receipt-keyed discard:
discard_pending_receipt drops a queued adoption too and keeps the
latest-receipt bookkeeping master's discard_queued kept. The boundary
census declares the ingest worker's attachment-carrier spill.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity added a commit that referenced this pull request Sep 29, 2026
…ion (#5684)

## Summary
Every origin is now acquired only from its canonical location. Custom
source roots and source narrowing are gone, and config loading refuses
keys Polylogue does not read.

## Problem
`[sources] roots`, `polylogued run --root`, `--default-source` and
`--no-default-sources` let a deployment point the daemon at arbitrary
directories and drop built-in sources. The workstation's hand-enumerated
`--default-source` list silently left out the hook spools, browser
capture and the import inbox, and a watched account-export root bypassed
the deliberate `polylogue import` route. Unread settings also loaded
silently: `daemon.watch.debounce_s` was rendered and never consumed.

## Solution
- `daemon/cli.py`: `_watch_sources` builds the watch set from
`default_sources()` only (the browser-capture spool override stays).
`run` and `watch` lose `--root`, `--default-source` and
`--no-default-sources`.
- `sources/live/watcher.py`: the legacy data-home inbox watch is
removed. Exports enter through `polylogue import` into the archive
inbox.
- `config.py`: `sources.roots`, `ResolvedSourcePaths.explicit`,
`source_declarations`/`configured_source_frontier` and the
`configured-*` runtime sources are removed. `_apply_toml_layer` raises
`ConfigError` naming any TOML key no inventory entry declares.
- Maintenance: the `wanted-sources` command (which only enumerated
custom roots) is deleted. `verify-archive` and the Beads origin census
no longer read explicit roots.
- `nix/`: the `daemon.watch`, `discoverSources`, `debounce-s`,
`logging.level` and `ui.slow-query-notice-seconds` options are removed,
since nothing reads them.
- Harnesses: `tests/infra/daemon_cold_start.py` and
`devtools/daemon_finished_build.py` run the daemon with an isolated
`HOME` and the corpus at its canonical path. For the finished-build
qualification, `--source-root` is that home, and `--input` must sit
under `.codex/sessions` or `.claude/projects`. Integration tests write
under `Path.home()`, which the fixtures isolate.
- Docs: `daemon.md`, `configuration.md`, `getting-started.md` and
`hermes-operators.md` are updated.

## Location binding: one acquisition boundary
A canonical location admits only its own origin's material. Every
acquisition route reads bound source bytes through
`polylogue/sources/acquisition_boundary.py`:
- `open_bound_path`, `open_bound_member` and `bind_stream` return a
stream that feeds each byte, on its first read and in order, to
`BoundRecordValidator`. A foreign record raises
`ForeignOriginContentError` from the read that delivers it. Every record
(a JSONL line, an array element, an object document) is push-parsed and
classified as both a record and a one-record sequence. Classification
reads a bounded view of the record (`_EvidenceBuilder`: string prefixes,
the first entries of each container, a per-record value and character
budget), so memory does not grow with record size. No byte window
truncates the stream.
- `capture_bound_path` and `capture_bound_stream` are the only routes
that retain source bytes. They copy exactly the bytes they validate, so
a refusal raises before any publication is queued.
`_SessionEmitter.emit` and `iter_entry_payloads` bind their input
themselves. A bound stream or ZIP member is released as one unit, only
after it has fully validated.
- Intake and the production baseline share the refusal.
`classify_pre_acquisition` refuses declared foreign databases and
foreign unsupported-class files. The baseline hashes retained files
through the same boundary and records `intake_excluded:<intake's
reason>`.
- `tests/unit/sources/test_acquisition_boundary.py` runs every
acquisition route against a foreign tail. It also fails when any call
that retains source bytes or opens a ZIP member appears outside the
boundary without a declared reason.
The per-site prefix, first-record and captured-blob checks
(`bound_capture.py`, `refuse_foreign_material`,
`validate_bound_grouped_zip_member`, `expected=` detection copies) are
deleted.

Also in this PR: `ops status` probes the daemon's own watch set
(`operations/source_presence.py`). `init` persists a Hermes root
supplied by config. OTel GenAI exports arrive through `polylogue
import`. The unread-key error names a recovery that works without the
CLI. The `salvage/strictdetect` edits (whole-unit ZIP release,
case-exact debt clearing) are folded in.

## Config keys kept (source-related)
- `archive.root`: selects the archive; the one path Polylogue owns.
- `daemon.browser_capture.spool_path` / `--spool`: the browser-capture
spool lives under Polylogue's own root. Scheduled for removal in favour
of the fixed archive location (follow-up bead).
- `sources.hermes.root` / `POLYLOGUE_HERMES_ROOT`,
`sources.hook_sidecar_dir`, `sources.hook_provider`,
`drive.credentials_path` / `drive.token_path`,
`sources.antigravity.language_server`: per-origin overrides scheduled
for removal in a follow-up bead (Hermes moves to its own `HERMES_HOME`).
They are out of scope here, to keep this change reviewable.

## Verification
All runs went through agentctl jobs. The final head is `b5e390a0bc`,
merged with master at `e14b47662d`.
- `agentctl job start polylogue verify_quick --workspace <worktree>`:
job 2234 on `b5e390a0bc`, `verify: PASSED exit=0`.
- `agentctl job start polylogue pytest_focused --
tests/unit/sources/test_acquisition_boundary.py
tests/unit/sources/test_location_binding.py
tests/unit/sources/test_production_baseline.py
tests/unit/sources/test_content_identity_member_refusal.py
tests/unit/sources/test_retained_acquisition.py
tests/unit/sources/test_live_batch_support.py
tests/unit/sources/test_live_storage_faults.py
tests/unit/pipeline/test_acquisition_blob_gc_age_gate.py
tests/unit/storage/test_ingest_governance.py
tests/unit/storage/test_attachment_acquisition.py
tests/unit/pipeline/test_ingest_batch.py tests/unit/browser_capture`:
job 2191 on `d499a00f57`, `645 passed, 2 failed`.
-
`test_ingest_governance.py::test_membership_that_becomes_eligible_after_preparation_defers_publication`
fails the same way on master `915a1f357d` (job 2060).
-
`test_acquisition_blob_gc_age_gate.py::test_slow_following_source_cannot_age_uncommitted_blob_into_gc`
was caused by this PR. It patched `prepare_from_path`, which the
boundary capture no longer calls. Fixed in `b5e390a0bc`; job 2235 with
`tests/integration/test_live_read_amplification.py` passes.
- `agentctl job start polylogue pytest_focused --
tests/unit/sources/test_acquisition_boundary.py
tests/unit/sources/test_location_binding.py
tests/unit/sources/test_production_baseline.py
tests/unit/sources/test_content_identity_member_refusal.py
tests/unit/sources/test_export_member_addressing.py
tests/unit/sources/test_retained_acquisition.py
tests/unit/sources/test_live_batch_support.py
tests/unit/sources/test_live_watcher_parse_stage_equivalence.py
tests/unit/sources/test_unbounded_probe_ceilings.py
tests/unit/sources/test_source_laws.py
tests/unit/sources/test_live_route_interpretation.py
tests/unit/cli/test_status_diagnostics.py
tests/unit/core/test_content_identity_streaming.py`: job 2062 on
`fa3e6b2ccb`, `690 passed`.
- `agentctl job start polylogue pytest_focused --
tests/unit/daemon/test_daemon_cli.py tests/unit/core/test_config.py
tests/unit/core/test_config_inventory.py tests/unit/cli/test_init.py
tests/unit/devtools/test_daemon_finished_build.py
tests/unit/devtools/test_isolated_environment.py`: job 2142 on
`fa3e6b2ccb`, `301 passed, 2 failed, 4 flaky`.
- The 2 failures are
`test_init.py::test_status_reports_absent_daemon_*`. They fail the same
way on master `915a1f357d` (job 2171).
- The 4 flaky tests are daemon timing tests that passed when rerun
alone. They also flake on master (job 2074).

## Residuals
- `test_init`'s two `test_status_reports_absent_daemon_*` tests fail the
same way on master.
- At a bound location, the emitter holds a stream's parsed sessions
until the whole stream has validated. For one very large grouped file,
that is every session in the file.
- `replay_zip_entry_acquisition_payloads` still reads a whole preserved
member into memory, within the ZIP-bomb ceiling. Its callers are
backup-verification replay and tests. The production baseline now uses
the streamed `replay_zip_entry_acquisition_revisions`.
- Two ZIP refusal debt mechanisms now sit side by side. Content-identity
refusals are recorded on the archive path by master's
`_settle_zip_member_refusals`. Foreign-origin refusals are recorded per
member under `<zip>:#`. Their subjects cannot collide.
- The wanted-source receipt library and the per-origin overrides are
bead polylogue-aar35.
- The workstation config no longer sets any removed key (sinnix
`04629c73`, `bd9c4028`), so the new refusal does not trip the live
daemon config.

## Self-review
- **Sibling sites.** The boundary census
(`test_no_route_reads_source_bytes_around_the_boundary`) now also counts
`write_from_writer` and `prepare_from_writer`. The master merge brought
in `_HashingZipEntry`, which opened members outside the boundary. It now
opens them through `open_bound_member`, so baseline member revisions
refuse foreign records the way live intake does. Content-identity
refusals from master reach every route: the live batch,
`iter_source_raw_data`, the retained route, `decoder_zip`, the baseline,
and the emitter. On each route the validated sibling splits or sessions
survive the refusal.
- **Cancellation and shutdown in loops.** The streamed member revision
keeps master's checkpoint per chunk. The baseline still checks
cancellation per member and per unit.
- **Unbounded reads.** Before, the validator copied every value of a
record into memory, with long strings cut to a prefix. It now keeps a
bounded view per record. Retiring an earlier accepted ZIP member used to
read the whole member through `replay_zip_entry_acquisition_payloads`.
It now streams through `replay_zip_entry_acquisition_revisions`. The one
remaining whole-member read is listed under Residuals.
- **Fail-open fallbacks.** A split member that fails on a ZIP-bomb
ceiling or a read fault now releases the captures it queued, instead of
leaving them for flush to reserve. Retirement of an earlier acceptance
returns "changed" on any replay fault, including a content-identity
refusal, so the earlier revision stays demanded.
- **Compatibility shims.** `discard_queued`, `discard_pending_hash` and
`discard_pending_blob` were three discard paths. They are replaced by
one receipt-keyed `discard_pending_receipt`, reached through
`release_refused_capture`. The live batch's second split-release loop is
deleted, because the member iterator owns that release. The
Polylogue-owned watch-source names are declared once, in `watcher.py`,
instead of in both `daemon/cli.py` and `source_presence.py`.
- **Vacuous tests.** Two tests observed acquisition at
`write_from_path`, which the boundary capture no longer calls. The GC
age-gate test failed. The read-amplification counter's "no full reread"
assertions held vacuously. Both now observe `capture_bound_path` or
`prepare_from_fileobj`.
- **Master's publisher adoptions (#5725).** `discard_pending_receipt`
also drops a queued adoption and keeps the latest-receipt bookkeeping
(`test_publisher_discards_one_refused_pending_blob`). The ingest
worker's attachment-carrier spill is declared in the boundary census.
- **Tests prove the production route.** New tests:
- `test_a_record_of_many_values_is_classified_from_a_bounded_view` fails
if the builder copies every value, or if it stops reading before
`payload`.
- `test_publisher_discards_one_refused_pending_blob` runs
`release_refused_capture` against a real publisher.
- master's `test_the_parse_route_captures_elements_after_a_refused_one`
runs `process_zip` at a bound location. It failed on the first merge
(`[] == [0, 1, 3]`) and passes after `ac368894ea`.

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

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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