Skip to content

2.x.x: stream PRISM share-window serialization and parsing - #239

Merged
kiwidream merged 2 commits into
2.x.xfrom
fix/prism-236-window-serialization-20260906
Sep 6, 2026
Merged

kiwidream merged 2 commits into
2.x.xfrom
fix/prism-236-window-serialization-20260906

Conversation

@kiwidream

@kiwidream kiwidream commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Several PRISM payout-window paths serialize or parse an entire share array in one call, delaying the lease-monitor thread at large window sizes. Encode share arrays in 512-record batches and parse daemon mirror records incrementally while preserving the historical JSON bytes and canonical digests.

This covers daemon prepare requests, compact audit-builder tails, one-shot payloads, share-array digests and candidate identity hashes. Serialized tails remain cached per generation; partial request failures retire the daemon so a later request cannot reuse an incomplete line. Lazy mirror parsing retains strict framing/count checks and only publishes a complete parse. Sharing parsed key strings and releasing operation-owned temporary lists in batches reduce cleanup pauses.

Validation:

  • Linux worker: full discovery passed (3,277 tests, 2 skipped) before the final key-sharing/cleanup changes; affected suites and 34 lease tests passed after those changes. Real Rust daemon parity and PostgreSQL ledger/scale gates passed; PostgreSQL tests used external psql and disposable databases.
  • Local Python 3.14: 490 focused tests passed, excluding five existing Linux-only os.splice assumptions previously reproduced on the unchanged macOS base.
  • Regression coverage includes exact JSON bytes across batch boundaries, Unicode and large integers, spool/memory parity, malformed/truncated mirror streams, partial request failure, cache reuse and fallback behavior.
  • git diff --check passed.

The included on-demand probe measured replacement encoding/parsing phases at roughly control-level monitor delay on a shared Python 3.12 host. These are synthetic phase measurements, not production-image or end-to-end Stratum recovery validation. See tests/perf/window_pipeline_gil_scaling.md for measurements and limitations.

A separate existing Rust paging allocation defect was reproduced during profiling; a scratch fix dramatically reduced daemon memory use, but no Rust change is included here; the fix is tracked in #240. Candidate-intent SQL literal serialization also remains outstanding; the database-read companion PR does not cover that mutation path. Combined recovery, GC/lease latency and soak gates remain for #236.

Part of #236, alongside pipe transport #237 and database decoding #238. This PR does not close the incident issue.

Integration validation: this branch now includes merged #237 (43fef00). Independent reviews found no blocking regressions. The full three-PR integration tree at 6174754 passed 436 local Python 3.14 tests (2 platform skips), preserving both appended share-ledger test blocks. GitHub CI passed on both updated branches, including 3,374 Python tests (2 skipped) plus PostgreSQL, Rust and payout-window parity gates on the full combination. One unchanged ckpool test hit a readiness-file race; its failed CI job passed on rerun at the same commit.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Every whole-window JSON call on the payout-window paths -- the daemon
prepare_window request, the audit-builder compact tail (spool, in-memory
fallback and one-shot), the digest of a freshly read share list, the daemon
mirror's lazy parse, the found-block candidate identity digest and the
one-shot canonical payload -- is replaced by batched encoding or
record-at-a-time parsing that produces byte-identical output while bounding
any one C call to 512 records or one 64 KiB decode chunk, so the writer-lease
monitor thread can run between batches instead of waiting behind a
whole-window json.dumps/json.loads.

- lab/prism/share_json_stream.py: new leaf helper (batched array/object
  encoders, streamed canonical digest, ShareArrayJsonSequence view,
  bounded list release).
- share_ledger.py: page encoding through the helper; _walk_canonical_items
  (incremental UTF-8 decode + raw_decode per record, shared key strings,
  strict layout checks); DaemonShareJsonSequence parses record by record and
  publishes only after the count check; block_candidate_identity_sha256
  streams shares_json.
- bundle_compiler.py: compact tail as bounded chunks (compact_tail_chunks)
  written identically by spool, daemon in-memory fallback and one-shot;
  prepare_payout_window streams the request and retires the daemon on a
  half-written line; the canonical one-shot payload streams its arrays.
- payout_state.py / job_bundle.py: share-list digests go through the
  streaming view; transient per-share lists released in bounded slices.
- metrics.py: compact-json byte accounting via compact_json_bytes.
- tests: byte-parity, malformed/chunk-boundary parse, fault injection
  (unencodable record mid-request, daemon death mid-request), candidate
  digest parity, spool/in-memory equality.
- tests/perf: --latency-probe mode with a lease-monitor-cadence lateness
  thread, GC attribution and the real daemon round trip; report section 9
  records the shared-host measurements and the Rust paging finding.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AFvDqz6xwHRWxCWwJPiXvT
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 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-06T13:50:42.532810Z ac70fd3 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.

@kiwidream
kiwidream merged commit a4d4b11 into 2.x.x Sep 6, 2026
15 of 16 checks passed
@kiwidream
kiwidream deleted the fix/prism-236-window-serialization-20260906 branch September 6, 2026 13:53
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