Repository navigation
Native wake receipts on Jcode 0.98.1 source baseline - #107
KooshaPari wants to merge 3 commits into
Conversation
tx-agent: codex tx-validated: cargo-check tx-scope: native
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. Comment |
tx-agent: codex tx-validated: test
tx-agent: codex tx-validated: test tx-parent: 17b4a61
…xamined PRs Corrections to pass-2 claims: #107 conflict count (357 files/1149 hunks, not 1658), desk-linux runner exists (desk-kcode-1 online), #124 retains hosted Windows CI (macOS only removed), #124 real stat +514/-352 66 files, B-7b cohort measurements voided and re-run, cold-target ring/aws-lc retracted as environment flake, #132 attribution reconfirmed on true isolation trees. New finding: 5 open PRs were never examined at all (#123 #119 #121 #8 #10). #8 and #10 are non-mergeable; #121 conflicts with #124 so landing order matters. #123/#119/#121 validated locally with no CI on head. Baseline tui failure count is run-dependent (27/28/31 across runs) - flagged as flaky. tx-agent: jcode tx-validated: manual tx-intent: correct the landing brief with third-pass evidence and expanded PR scope
Strike the stale claims that survived into the pass-3 append layer so the brief no longer contradicts itself: - #124 summary-table row was still "LAND" unconditionally. Split it into keyboard fix (LAND) vs bundled CI migration (BLOCKED). - #107 row still said "1,658 conflicts". Use 357 files / 1,149 hunks. - Pass-2's "+513/-351" and "+449/-277" are both wrong; GitHub API reports +514/-352 across 66 files. Inline stat at the merge-attempt call site updated, not just the correction section. - Pass-2's operator-call bullet said "confirm the desk-linux runner exists" as if existence were open; it exists but is OFFLINE, which turns the concern from advisory into blocking. Retained as strikethrough plus a correction note rather than silently deleted. No behavioral claims changed: #124 still fixes the most pre-existing tui failures and the clippy --lib failure; #107 still DO NOT MERGE; #132 attribution still confirmed correct. This is a consistency pass, not a re-measurement pass. tx-agent: jcode tx-validated: manual tx-scope: docs/sessions/2026-10-18-resume-reland tx-intent: Remove self-contradicting pass-2 claims from the operator-facing landing brief tx-task: KCode open-PR landing audit
|
Superseded by #233. This PR is stacked on #233 carries that same 14-file delta directly onto
Verified Nothing from this PR is lost. Closing so the work is reviewable on a base that can actually merge. |
…ersedes #107) (#233) * feat(protocol): native wake receipts, lifted onto current master (#107) Lifts the change from #107 onto master. That PR is stacked on codex/native-wake-base-1c7426e, which is 2810 ahead / 403 behind master and will never land, so merging the base into #107 could not help. This carries the PR's own 14-file delta onto master instead. Two ports were required because master moved under the branch: 1. crates/jcode-protocol/src/wire/events.rs no longer exists - master flattened the wire/ directory into a single wire.rs. The ServerEvent:: WakeReceipt variant is ported into wire.rs after Ack, unchanged in shape. 2. append_user_context_message_with_display_role gained a fourth parameter in the branch's base that master does not have. Recovered the original contract from the base blob (1c7426e) rather than inventing one: // A synthetic continuation (reload recovery) resumes the previous // turn, so it must not start a new model-usage turn. continues_turn: bool, and folded it into the guard as `!continues_turn && (blocks.len() > 1 || !user_message.trim().is_empty())`. The two ordinary call sites (chat, append_user_context_message) pass false; the wake-receipt path passes false as the branch did. Verified: cargo check --all-targets exits 0 for jcode-protocol, jcode-app-core and jcode-base with CARGO_LOCK=0 (the wrapper exits 101 silently when slots are held, which looks like a compile failure but is not). tx-agent: jcode tx-task: pr107-lift tx-validated: cargo-check tx-scope: jcode-protocol,jcode-app-core,jcode-base,docs tx-intent: land #107's work on a base that can actually merge * fix(wake-receipts): address every bot finding on #233 Applies the review findings raised on #233 (CodeRabbit 2 major + 3 minor, CodeAnt 5 major + 1 nitpick). Each fix is scoped to the defect it names; no behavior outside the native wake receipt path changes. Durability and admission (crates/jcode-base, crates/jcode-app-core) * sync_wake_turn_entry flushed a handle that could be read-only. On Windows FlushFileBuffers on a read-only handle fails, so the fsync silently did nothing. The write path now opens with OpenOptions::write(true) and only falls back to File::open. * handle_notify_session_receipt resolved the existence guard before the replay lookup. A replay of an already-admitted receipt therefore failed once the target transcript was gone, and an attached session that had not saved a transcript yet was rejected. The replay lookup now runs first and an attached in-memory session counts as existing. Progress accounting * A GetWakeReceipt poll could never advance a Queued receipt, so a target that was idle at submit time stalled in Queued forever. Polling now runs run_receipt_turn_if_idle, which returns immediately for busy or unattached targets. docs/native-wake-receipts.md states this. * client_lifecycle.rs aborted the connection task via unreachable!() when NotifySessionReceipt or GetWakeReceipt arrived after subscribe. Both now route through handle_lightweight_control_request and emit ServerEvent::Error on failure instead of panicking. State hygiene * A receipt turn reused an agent whose current_turn_system_reminder could still be set by a turn that panicked before cleanup, leaking a stale reminder into the synthetic wake input. Receipt-turn entry clears it. * The receipt ledger was unbounded. It now stamps created_at, caps at MAX_RECEIPTS = 256 and prunes awakened receipts first, never the id that was just accepted. Test isolation * wake_receipts.rs and server/tests.rs set JCODE_HOME while the code under test reads KCODE_HOME, so the tests wrote into the real profile. Both now set KCODE_HOME (12 call sites). Clippy gate * spawn_tracked_live_turn reached 8 arguments when this PR added receipt_id, which fails clippy -D warnings. Annotated with #[expect(...)] and a reason, matching the 103 existing call sites of that pattern in the tree. New regression tests * wake_receipts::tests::ledger_is_bounded_and_keeps_the_newest_receipt * server::tests::native_receipt_admits_attached_session_and_replays_without_target Verified on 702d29a + this commit: cargo check --all-targets and cargo clippy -p jcode-app-core -p jcode-base --all-targets -- -D warnings both exit 0; cargo fmt --all --check exits 0; the full app-core server test module passes 484/484. jcode-base --lib reports `1747 passed; 12 failed` with a byte-identical failure-name set on both unmodified 702d29a and this commit, so those 12 are pre-existing rebrand drift (tests asserting jcode where the KCode build emits kcode) and not from here. tx-agent: jcode tx-task: pr233-review-fixes tx-validated: test tx-scope: jcode-app-core,jcode-base,docs tx-intent: clear every blocking finding on #233 with a tested fix * chore(ratchet): track wake-receipt growth in the code-size baseline The Quality Guardrails job fails because five tracked oversized files grew: turn_execution.rs 1489 -> 1531 server.rs 2445 -> 2446 client_actions.rs 1354 -> 1423 client_lifecycle.rs 3936 -> 3974 wire.rs 1712 -> 1735 These cannot be satisfied by extraction alone. `server.rs` grows by exactly one line, the `pub(crate) mod wake_receipts;` declaration, and a module declaration has to live in the module root; the rest is call-site plumbing for the wake receipt flow that belongs with the code it drives. Bumping the five entries keeps the ratchet meaningful (no new oversized files, every other tracked file still fails on growth) and follows the practice already in this repo's history, e.g. 6aab10e refreshed the baseline and raised server.rs 2376 -> 2430 and client_lifecycle.rs 3282 -> 3625. Deliberately not run with --update: that would also absorb unrelated shrinkage in other files, widening this PR's diff beyond its purpose. Only the five regressed entries are changed. Validated: python3 scripts/check_code_size_budget.py exits 0 on a full checkout (crates/, src/ present) and reports no regressions. tx-agent: jcode tx-validated: manual * fix(wake-receipts): stop swallowing delivery errors and split oversized tests The Quality Guardrails job runs four ratchets; after the code-size baseline was refreshed, the other three still failed: - swallowed-error budget grew by 10 (three files plus the new wake_receipts.rs). Every new site was a `let _ = client_event_tx.send(..)` or an `.ok()`. Add `wake_receipts::send_event`, `error_event` and `reread_or` so delivery failures are logged instead of dropped, a turn that fails to start is reported with its error, and a receipt re-read that errors keeps the value in hand. `target_is_allowed` now matches `std::env::var` explicitly instead of `ok().is_some_and(..)`. Total is back to the baseline with no per-file growth. - test-size budget rejected server/tests.rs as a new oversized test file (1388 LOC > 1200). Move the two receipt tests into server/tests/native_wake_receipt_tests.rs, leaving tests.rs at 1175 LOC. - code-size baseline re-tightened for client_actions.rs (1414) and client_lifecycle.rs (3973), which shrank from the helper extraction. Validated with the four scripts the job runs, on a checkout with crates/, src/, tests/ and scripts/ present: check_code_size_budget, check_test_size_budget, check_panic_budget and check_swallowed_error_budget all exit 0. Files were rustfmt --edition 2024 clean. CI compilation is not verified locally. tx-agent: jcode tx-validated: manual * fix(wake-receipts): use crate logging, correct bool result, fix module paths Compile-verified corrections to the previous commit: - jcode-app-core does not link `tracing` directly; logging goes through `crate::logging::warn/debug` (the jcode-logging facade). All three call sites now use it. - `run_receipt_turn_if_idle` returns `bool`, not a `Result`. Take the boolean and log at debug level when no turn started (target busy or already awakened); the receipt state still comes from the durable ledger. - In the child test module `server::tests::native_wake_receipt_tests`, `super::` resolves to `server::tests`, so the receipt, live-turn and client-action paths needed one more level. Validation on this machine (macOS, rust 1.99 nightly): - cargo check -p jcode-app-core --lib: clean - cargo check -p jcode-app-core --lib --tests: clean - cargo test -p jcode-app-core --lib native_receipt: 2 passed - cargo test -p jcode-app-core --lib server::tests::: 17 passed - all four Quality Guardrails ratchets exit 0 - rustfmt --edition 2024 --check clean on every touched Rust file Note for reviewers: these receipt tests fail locally when `TMPDIR` points inside a `.jcode` directory, because jcode-storage refuses KCode paths under a jcode path. That is the guard working, not a defect; rerun with a neutral TMPDIR. tx-agent: jcode tx-validated: cargo-check+cargo-test+ratchets * fix(wake-receipts): refuse new wakes at the ceiling and keep settled tombstones Two data-integrity findings on the pruning rule: - At MAX_RECEIPTS with no awakened entries, prune evicted the oldest queued receipt. That receipt had already been accepted as durable: a later poll returned 'Unknown wake receipt' and the wake never ran. The ledger now refuses new submissions when every slot holds a queued receipt, and settling one frees a slot. - Pruning an awakened receipt erased its dedup record, so retrying that id was admitted as a fresh queued wake and could save the message a second time. The ledger now keeps a bounded tombstone set (1024) holding the id and target (the delivered message is dropped), and get/submit read it, so a retried settled id still answers 'awakened'. The on-disk format gains those two sections; the file is only written by this branch, so no migration is needed. takes the number of slots the caller is about to consume so submit can settle before rejecting. Tests: ledger_rejects_new_wakes_instead_of_evicting_queued_ones replaces the test that asserted eviction, and evicted_awakened_receipt_still_blocks_a_second_turn covers the tombstone path including re-settling and target pinning. Docs note the ceiling and tombstone behaviour. Validated: 4 wake_receipts tests, 2 native_receipt tests and 17 server::tests pass; cargo check --lib --tests clean; all four ratchets exit 0; rustfmt clean. tx-agent: jcode tx-validated: cargo-test+ratchets
The legacy
notify_sessionrequest returnsdonefor immediate, notified, or queued delivery, so an external bridge cannot use it as proof that a specific target turn accepted its message. This candidate adds an explicit native receipt request and lookup on the exact Jcode 0.98.1 source commit1c7426eb1925a1167eb56011fa479ad707cc28b6.notify_session_receiptrequires an exact server-sideJCODE_NATIVE_WAKE_SESSION_ALLOWLISTentry and an existing persisted target session. A durable record deduplicates retries by receipt ID, session ID, and message. Busy or unattached targets returnqueued; a live idle target enters a receipt-specific turn, saves the exact message to its transcript, then advances the receipt toawakened.get_wake_receiptlets a bridge poll the correlated state. Existingnotify_sessionbehavior remains separate.This is an isolated source candidate, not a shared-runtime promotion. It is an at-least-once turn-entry protocol: a crash after transcript save and before receipt-state save can replay on retry. Busy or unattached pending receipts require a retry to dispatch.
awakeneddoes not prove model completion. No production Discord bridge or existing user session was exercised.Validation:
cargo check -p jcode-protocol -p jcode-app-core -j 1and downstreamcargo check -p jcode -p jcode-tui -j 1passed. Final focused receipt test run passed 7/7 acrossjcode-app-core(6) andjcode-protocol(1).cargo fmtandgit diff --checkpassed. Build artifacts used a separate target directory; no shared Jcode service or profile was changed.