Skip to content

feat(ingest): page accepted source manifests and receipts - #5630

Merged
Sinity merged 1 commit into
masterfrom
feat/paged-ingest-manifest
Sep 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
feat/paged-ingest-manifest

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Page accepted ingest manifests and terminal receipts so one machine operation can retain and report more than 10,240 physical inputs without unbounded source or audit rows.

Problem

The active ingest route built a full input manifest and generation receipt in memory, carried the full accepted manifest in audit acceptance, and capped terminal input evidence. A 10,241-input request could not complete or be read historically as one operation. Multi-transaction preparation also needs an abort path: a later input disappearing, cancellation, or process death after page one must not leave GC-protecting blob reservations indefinitely.

Solution

  • Stage source-owned manifest members in bounded pages, seal their ordered semantic and custody digests, and promote the accepted generation atomically after audit acceptance. The semantic digest remains byte-for-byte compatible with v1; the custody digest binds publication receipts separately.
  • Abort a failed pre-accept attempt by deleting its staged rows and publisher-owned reservations in one source transaction. At the existing daemon startup recovery seam, settle audit continuity first, then reclaim only unpromoted dead preparations and their publisher reservations. Accepted generations and ambiguous audit transitions remain protected and are never semantically replayed automatically.
  • Stream source receipt evidence and generation-owned cohort membership through disk-backed/keyset reads. Reduce raw IDs globally, including duplicates across pages.
  • Persist 256-input audit pages before an ingest/v2 terminal root. Validate order, count, digest, foreign pages, and duplicate conflicts. Historical reads use audit pages without consulting the current source or index. Preserve the ingest/v1 decoder.
  • Include the prepared-manifest relations in the fresh source-v1 DDL, with PRAGMA user_version=1 and no source 002 migration. Advance the six-tier archive format lineage marker from v2 to v3 so earlier v1-shaped archives are refused before tier writes; the aside archive remains inert. The schema evolution gate permits a fresh-floor DDL revision only with a changed lineage marker and no added migrations.

Verification

  • devtools verify --quick — PASSED, exact-head receipt 20260927T133908Z-quick-3735541-4515553a.
  • Focused managed selection covering the 10,241-input machine route, 257-input later-page failure, synthetic kill/restart cleanup, accepted crash-boundary preservation, fresh source-v1 and old-marker refusal, v1 digest/custody, global receipt reduction, cross-page cohort membership, v2 audit pages, and the narrow schema-gate exception — 14 passed in 159.32s, exact-head receipt 20260927T134232Z-focused-test-3757794-d81be62d.
  • devtools schema closure polylogue/storage/sqlite/archive_tiers/source_items.py — IN. This change moves the derived schema identity: land before a rebuild begins, then reconverge the derived archive.

Residuals

Hosted ci/circleci: quick-gate candidate verification is pending on this updated head. No broad corpus run was requested.

@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 27, 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-27T13:49:07.072027Z 830685d New commits
ℹ️ 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: 9306845698

ℹ️ 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/operations/daemon_ingest.py Resolved
@Sinity
Sinity force-pushed the feat/paged-ingest-manifest branch from 9306845 to 830685d Compare September 27, 2026 13:45
@Sinity
Sinity merged commit 659c8ca into master Sep 27, 2026
2 checks passed
@Sinity
Sinity deleted the feat/paged-ingest-manifest branch September 27, 2026 13:56
Sinity added a commit that referenced this pull request Sep 28, 2026
Phased Drive catch-up classifies revision lineage against an in-memory
snapshot of the cohort. Since #5630 membership classification also
reads source_item_raw_members, which the scratch lacked, so every grown
Drive document was quarantined instead of bound as an asserted
revision. The cohort's generation members are now snapshotted, and
revalidated at publish like the other relations.

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

## Summary

Second intake pass (stacked on #5643).

- Every ChatGPT mapping node now goes through the scratch carrier. That
includes tool chains, multimodal parts, reasoning timings,
code-interpreter runs and authorship evidence, not only text nodes.
- A decoded value too large for one SQLite cell is refused as a counted
conservation gap, never truncated.
- Live, retained-replay and cold-build publication of one raw now
produce identical rows.
- Remaining SQLite connections are closed, and intake readers are
migrated onto the profiled factories.
- Seven old, unanswered Codex P1 findings from earlier PRs are fixed
here or dismissed with evidence.

## Problem

- **ChatGPT collecting fallback:** any node outside a narrow text-only
shape sent the whole mapping back through the collecting parser.
Normalized messages, attachments and events then grew with the
conversation.
- **Oversized values:** nothing bounded a single giant scalar, and the
ChatGPT parser capped sandbox-link attachments at 512 per message,
dropping the rest.
- **Route characterization:** the route test pinned a "delta" that was
an artefact of acquiring the retained raw without the revision identity
live intake assigns.
- **Connection leaks:** spool connections used `with
sqlite3.connect(...)`, which commits but never closes.
- **Stale test fixtures:** three tests failed on master against stale
fixtures:
  - one patched a helper that no longer exists;
  - one used a fake with an out-of-date signature;
  - one expected pre-fresh-v1 migration behaviour.

## Solution

- **One ChatGPT normalization, two stores.** `chatgpt.parse(...,
spill=)` collects messages into a `MessageEntries` store. It is a list
for the collecting parser and scratch for preparation. Ordering, parent
resolution, the active leaf and generation-timing ownership are written
once and read through the store. Declared sibling order is answered from
the spilled `children` rows. The old text-only fast path is deleted.
- **Physical value limit.** `polylogue.sources.value_bounds` reads
`SQLITE_LIMIT_LENGTH` from the linked SQLite.
- The ijson member normalizer, bundle records and ChatGPT keys refuse
any value whose UTF-8 encoding exceeds it, with
`ValueBoundRefusedError`.
- Source conservation types that refusal as `value_bound_refused`, a
counted warning.
- The sandbox attachment cap and the Gemini sidecar size caps are
removed; attachments spill to scratch instead.
- **Route equality.** The characterization test acquires the retained
raw under live's revision identity and asserts identical source and
index rows across all three routes.
- **Connections.** A `spool_connection` context closes spool databases.
The live batch, watcher, batch observability and raw-retention readers
use `open_readonly_connection`, and sibling tiers use
`attach_readonly_database`.
- **Old P1 findings:**
- #5610: a browser-capture envelope that also carries a mapping keeps
the capture route.
- #4720: a Gemini sidecar that is still being written, or is shorter
than the inline envelope, becomes debt and does not replace the
envelope. Claude Code also leaves the path-independent parse cache, for
the same sidecar reason as Gemini CLI.
- #4850: the sibling tool-id index composes the full revision plus its
appended tails.
- #5603: interrupted attempts stay `running` until the rewind read has
succeeded.
- #5630: a resumed completed ingest decodes the nested
`historical_receipt`.
- #5250 and #5630 (abandoned manifests): already fixed on master.
Evidence is in the review thread replies.
  - #5557: deferred to the location-binding change in daemon config.

## Verification

- `devtools test` over 14 files (prepared JSONL, the ChatGPT parser,
source conservation, route characterization, live watcher/append/batch,
raw retention, daemon ingest idempotency, Gemini sidecars, cursor
recovery, machine receipts, reviewed defects, route interpretation): 741
passed, 1 failed. The one failure is the Gemini oversize-sidecar
expectation that changed with the cap removal. It is fixed and its rerun
is below.
- `devtools gate mypy`, `layering`, `patterns` and `schema-closure` pass
locally; the cursor-recovery test file was rerun on the final head.
- Hosted quick gate on this head.

## Schema closure

This moves the derived schema identity, so it must land before the
rebuild. `decoder_json.py`, `prepared_jsonl.py`,
`prepared_message_sink.py`, the live batch/watcher/observability modules
and `raw_retention.py` are in the closure. The baseline grows by one
module, `polylogue/sources/value_bounds.py`, because the decoder now
imports the storable-value limit from it.

## Residuals

- behu4 shapes that still load whole objects, all code-ready with no
decision pending:
- Claude AI `chat_messages` (the evidence graph in
`normalize_chat_messages`);
  - Drive and chunked prompts;
  - Hermes ATIF and OTel;
  - the Grok fallback.
- The Claude Code tool-result sidecar join keeps its 64 MiB-per-file and
256 MiB-aggregate caps.
- Storing values above SQLite's cell limit is an undecided future
question, not committed work.

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

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

Periodic profile ticks now serve demanded session work before the
archive-wide audit, and never re-run the audit once it has swept
(polylogue-6remh). Phased Drive catch-up binds a grown document as an
asserted revision again instead of quarantining it. The halted-units
status test gets a genuinely green baseline.

## Problem

- **Demand starved behind the audit (6remh).** Two landed contracts
conflicted. #5540 says a periodic tick publishes demanded work and an
idle tick inspects nothing. #5570 made every unscoped tick run the
startup audit one domain slice at a time (summary, usage rollup,
profile; 128 keys each) before any demand pass. Take a one-session
archive with pending `session_profile_demand`: the first
`callback(None)` returned `outcomes=()`, and no profile was published.
On a large archive, demanded profiles waited for all three domains to
sweep after every daemon start.
`test_two_accepted_revisions_survive_one_periodic_profile_pass` and
`test_working_dir_demand_withholds_profile_readiness` were red on
master.
- **Drive scratch missed a relation.** Phased Drive preparation
classifies revision lineage against an in-memory snapshot of the cohort.
Since #5630, membership classification also reads
`source_item_raw_members`, and the scratch did not carry that table.
Every grown Drive document was therefore quarantined instead of being
bound to its predecessor
(`test_drive_phased_matches_ordinary_document_growth`).
- **Halted-units test baseline.** The healthy frontier fixture set only
`overall_status` over unknown sub-checks. That is not a proof, and it
refutes `ok`, so the test's "green before the halt" baseline was not
green.

## Solution

- Decision recorded on 6remh: #5540's contract wins. `callback(None)`
runs only the demand pass. The startup/promotion audit advances in
bounded slices through `ComposedSessionProfiles.converge_backlog` after
that demand pass, and it does not repeat once swept (only promotion
resets it). Tests that encoded the per-tick audit now drive `audit_pass`
/ `converge_backlog`. The insights race test now models the replacement
at the record the route actually compares.
- `_prepare_ingest_unit_sync` snapshots the cohort's
`source_item_raw_members` into the scratch alongside the other
relations, and revalidates it at publish in the same way.
- The halted-units test pins every collector to a measured healthy
value, keeping the archive's real raw-failure lifecycle, and the shared
frontier fixture proves each sub-check.

`devtools schema closure`: both source files are `out`, so the derived
identity does not move.

## Verification

- `devtools gate mypy`: `Success: no issues found in 3095 source files`
- `devtools test` on session profile composition, the periodic-pass
test, insights browser endpoint, convergence restart law,
raw-materialization fair intake, Drive catch-up execution, status
observations and status unmeasured: pending; this body is updated with
the receipt when it reports

## Residuals

- None known for these three changes.

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

https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6

---------

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

  • 68.F034 / P1: fixed-already at the checked revision: polylogue/operations/daemon_ingest.py:650-652 aborts failed preparation, and lines 692-697 settle uncertain acceptance before aborting a generation that did not become accepted. abort_prepared calls abort_prepared_source_manifest with both the generation and publisher identity in one committed source transaction at lines 518-523, rather than only removing the discovery spool.
  • 68.F040 / P1: fixed-already at the checked revision: polylogue/operations/daemon_ingest.py:1799 decodes restored[historical_receipt], not the surrounding IngestResult dictionary. Completed and degraded retries reconstruct the completed envelope from that typed receipt without re-executing ingestion.

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