Skip to content

fix(intake): prepare retained non-JSON raws without size cap - #5565

Merged
Sinity merged 2 commits into
masterfrom
fix/raw-materialization-limit-5557
Sep 26, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/raw-materialization-limit-5557

Conversation

@Sinity

@Sinity Sinity commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Prepare retained non-JSON raws in an isolated process worker without the old payload-size refusal.

Problem

A retained raw beyond the old size cap could remain outside ordinary materialization even when its parser supported it. The first worker patch opened archive tiers directly from the source layer, bypassing the declared read boundary.

Solution

Route non-JSON retained preparation through the same sealed artifact publication path and inject an operations-owned worker that pins the archive through open_operation_read. The worker revalidates its descriptor, blob and enrichment dependencies before publishing; worker exit and stale input remain retryable. Content-aware routing keeps logical SQLite/Hermes exports named .json on their proper parser route. The separate 419 MB and 1.6 GB completed-convergence qualifications remain under 58bwo, and the broader one-route work remains under 9m93s.

Verification

  • devtools test with the seven exact selectors for non-JSON over-limit replay, text/JSON parity, SQLite page and logical-export replay, worker death, canonical daemon raw admission and discovery costs: 9 selected, 9 passed on the frozen refactor content; receipt 20260926T221843Z-focused-test-4118482-81995384.
  • devtools gate controlled-read: zero violations; devtools gate schema-closure: 565 observed/565 baseline; devtools verify --quick: passed, receipt 20260926T222117Z-quick-4130603-b8e512a5 on that content.
  • The two-commit branch was rebased onto merged master dddac2422 after feat(intake): stream whole JSON preparation into sealed shards #5562. The same seven exact selectors passed 9/9 on clean published head d50005095, receipt 20260926T225042Z-focused-test-48131-03662e2f. The hosted quick gate checks that head. An independent read-only review found no concrete wrong output or missing production caller.

A wider three-file test selection was cancelled after it reached an unrelated 4,096-row bound test and occupied the managed pytest slot for 11 minutes. It is not acceptance evidence. The isolated worker still materializes a non-JSON parser's complete session tree; this PR removes the size refusal and makes that failure retryable, while bounded representation for supported large JSON is handled separately.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 49091dd6-fa9f-4540-90e4-52c3add8342b

📥 Commits

Reviewing files that changed from the base of the PR and between dddac24 and d500050.

📒 Files selected for processing (24)
  • docs/plans/sqlite-degradation-baseline.json
  • polylogue/daemon/cli.py
  • polylogue/daemon/raw_observation_owner.py
  • polylogue/maintenance/raw_authority.py
  • polylogue/operations/archive_debt.py
  • polylogue/operations/intake_adapters.py
  • polylogue/operations/raw_observation_derivation.py
  • polylogue/sources/census_parse_stage.py
  • polylogue/sources/revision_backfill.py
  • polylogue/storage/derived/raw.py
  • tests/infra/whale_fixtures.py
  • tests/unit/daemon/test_daemon_cli.py
  • tests/unit/daemon/test_fair_resumable_intake.py
  • tests/unit/daemon/test_raw_materialization_fair_intake.py
  • tests/unit/daemon/test_raw_materialization_parse_stage_equivalence.py
  • tests/unit/daemon/test_raw_observation_owner.py
  • tests/unit/daemon/test_raw_parse_recovery.py
  • tests/unit/operations/test_archive_debt.py
  • tests/unit/scenarios/test_codex_804_live_proof.py
  • tests/unit/storage/test_raw_authority_ledger.py
  • tests/unit/storage/test_raw_convergence.py
  • tests/unit/storage/test_raw_observation_derivation.py
  • tests/unit/storage/test_rebuild_complexity.py
  • tests/unit/storage/test_repair_concept_retirement.py

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 26, 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-26T22:57:36.213533Z d500050 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 b6eebf4 into master Sep 26, 2026
3 checks passed
@Sinity
Sinity deleted the fix/raw-materialization-limit-5557 branch September 26, 2026 23:10
Sinity added a commit that referenced this pull request Sep 27, 2026
## Summary

Fixes the tests that fail on clean master, and the two product defects
behind the biggest groups of them.

## Problem

On clean master (checked at `2da021c54`), 11 tests in the web reader,
MCP raw-session operations, thread profiles and browser capture failed,
35 in `test_privileged_tools.py` and `test_facade_mutation_census.py`, 5
in `test_session_insight_refresh.py`, and 4 more elsewhere. Two of the
causes are product defects:

- **API-owned mutations were refused through the daemon.** The daemon
labels every machine-protocol principal as surface `cli`. `user.*`
overlay operations and `mutation.facade.*` products have no CLI route,
and their actuators allow only `mcp`/`api`/`facade`. So a web-reader
saved-view save, or an annotation or saved-view delete, answered 409
`SurfaceDeniedError`. Every Python-API or MCP facade write through a
running daemon also failed; for example, `add_tag` returned "did not
complete: failed".
- **The async insight rebuild never cleared profile demand.**
`rebuild_session_insights_async` replaced profiles but left the
`session_profile_demand` row they satisfied. The profile therefore read
`stale` forever, although its binding matched. The sync twin already
acknowledges the captured revision.

The remaining failures were stale tests, each against a deliberate
change:

- The index version counter restarted at 1, so `user_version = 1` no
longer mismatches.
- Raw coverage rows follow configured source order since #5632.
- `session_events.summary` was retired in #5446.
- Markers are consumed from source-owned accepted inputs since #5493.
- #5550 deleted `_execute_facade_mutation`, which the census measured.
- `add_raw` gained `prepared_artifact`.
- The census wrapper gained a phase commit in #5550.
- Retained preparation runs in a spawned worker since #5565, so a 3 s
completion bound times out on a loaded host.
- `CliRunner.output` interleaves stderr, where `--allow-no-auth` writes
its warning.

## Solution

- `MutationPrincipal.on_surface(...)`. The user-overlay handler and the
facade product handlers now execute as the `api` surface, the public
surface that owns them, whichever transport delivered the request.
- The facade client lowers tuple arguments to JSON arrays before the
strict request models validate them. `bulk_tag_sessions` and
`post_blackboard_note` were refused before any daemon call.
- The saved-view HTTP route validates its query spec strictly, so a bad
field is a 400 with `field`, not a 409 failed operation.
- The async rebuild deletes the exact captured demand revision for each
rebuilt session. The derived-sweep census declares it and is
regenerated; the regeneration also reorders the stale `daemon_ingest.py`
entry.
- The MCP write, run and confirm-gate tests now run against the real
resident operation stack (`running_daemon_operations`). The executor
spies and failure-propagation proofs therefore observe the daemon's
executor.
- `test_facade_mutation_census.py` is deleted. Its own retirement
condition fired: the helper is gone and every facade mutation submits a
declared operation.
- Each stale test is realigned with the contract it tests; see the
commit messages.

## Verification

- `devtools test` over the 11 affected test files plus the three
`test_revision_backfill.py` ids and `test_raw_observation_owner.py`:
`707 passed` (receipt `20260927T193036Z-focused-test-1998248-bb6cdb4a`,
pre-rebase; the rebase onto `917fcaa17` applied cleanly and touched none
of these files except an unrelated appended web-reader test).
- `devtools verify --quick` passed before the last two test-only edits;
the hosted quick gate covers the pushed head.
- Derived-sweep census round-trip re-checked on the rebased tree:
identical.
- `devtools schema closure`: `mutation_transaction.py` and
`derived/session/rebuild.py` are IN, so this lands before a rebuild. The
other changed production files are OUT.

## Residuals

- The route-family declarations carry placeholder examples
(`default`/`route`) that no handler accepts, for example
`/api/import/explain` and `/api/webui/freshness` return 400. The example
replay now covers the kernel-bound routes only; `polylogue-otmpm` tracks
making the family examples real.
- A pre-reset archive (index `user_version` 67) is now classified
`upgrade_runtime`, because the counter restarted at 1. The old archive
is inert salvage and is never opened, so this was not changed.

🤖 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]>
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