Skip to content

Fix sentinel timeout: 0 means no timeout (#446) - #447

Merged
joelteply merged 1 commit into
mainfrom
fix/sentinel-timeout-446
Mar 25, 2026
Merged

joelteply merged 1 commit into
mainfrom
fix/sentinel-timeout-446

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

timeout=0 from Academy was ignored. Training killed at 600s. Fix: 0 = unlimited.

)

Academy sessions run for hours/days. timeout=0 was being ignored because
u64_or returns 0 (which was then used as 600s default by the sentinel).

Fix: if timeout is explicitly 0, treat as no timeout (u64::MAX/2).
Training should never be killed by a hardcoded fallback.
Copilot AI review requested due to automatic review settings March 25, 2026 17:50
@joelteply
joelteply merged commit 4d2caad into main Mar 25, 2026
@joelteply
joelteply deleted the fix/sentinel-timeout-446 branch March 25, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix Sentinel timeout handling so that timeout=0 (sent by Academy) is treated as “no timeout/unlimited”, preventing long-running training sessions from being killed at the default 600s.

Changes:

  • Adjusts sentinel/run timeout parsing to treat timeout=0 as unlimited.
  • Adjusts sentinel/await timeout parsing to treat timeout=0 as unlimited.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// timeout=0 means no timeout (Academy sessions can run for hours/days).
// Default 600s (10 min) for ad-hoc sentinels.
let raw_timeout = p.u64_or("timeout", 600);
let timeout_secs = if raw_timeout == 0 { u64::MAX / 2 } else { raw_timeout };

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping timeout=0 to a huge sentinel value (u64::MAX / 2) makes the existing timeout_secs == 0 “no timeout” branches below unreachable (e.g., pipeline log prints a massive timeout instead of none, and the code always wraps execution in tokio::time::timeout). Prefer keeping timeout_secs as the raw value and treating 0 explicitly as “no timeout” (e.g., represent it as None and skip tokio::time::timeout) so behavior/logging stays consistent and avoids extremely large Duration deadlines.

Suggested change
let timeout_secs = if raw_timeout == 0 { u64::MAX / 2 } else { raw_timeout };
let timeout_secs = raw_timeout;

Copilot uses AI. Check for mistakes.
Comment on lines 469 to 472
let handle_id = p.str("handle")?;
let timeout_secs = p.u64_or("timeout", 600);
let raw_timeout = p.u64_or("timeout", 600);
let timeout_secs = if raw_timeout == 0 { u64::MAX / 2 } else { raw_timeout };

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await_sentinel still always uses tokio::time::timeout(Duration::from_secs(timeout_secs), ...). Converting timeout=0 to u64::MAX/2 changes semantics from an explicit “no timeout” to “almost forever”, and can create impractically large Duration deadlines. Handle raw_timeout == 0 by awaiting rx.wait_for(...) without wrapping it in tokio::time::timeout (and keep error/log messages consistent with the intended unlimited behavior).

Copilot uses AI. Check for mistakes.
Comment on lines +151 to +154
// timeout=0 means no timeout (Academy sessions can run for hours/days).
// Default 600s (10 min) for ad-hoc sentinels.
let raw_timeout = p.u64_or("timeout", 600);
let timeout_secs = if raw_timeout == 0 { u64::MAX / 2 } else { raw_timeout };

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change modifies timeout semantics (0 => unlimited) but there’s no test coverage guarding it. Consider adding a unit test around timeout parsing/normalization (e.g., missing => 600, 0 => unlimited) so regressions don’t reintroduce 600s timeouts for long-running Academy sessions.

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Aug 15, 2026
…dge substrate (#447) (#2321)

* feat(cognition): causal memory graph slice A — acts join the engram edge substrate (#447)

Joel's overhaul ruling (2026-08-15): act memory is fundamental to every
activity and room, and it was structurally broken — a citizen with 1,808
lifetime acts sees 1-2 of them, concludes she has nothing to contribute,
and withdraws (the deprivation mechanism, measured live in the v4 round).

The diagnosis is a design gap, not a budget bug: the receipt's 'because'
clause is a causal edge serialized as prose, starving the char-budgeted
archive. Every mature system converges on two pointers per node (trace/
span, correlation/causation, PROV, git parents); we had the thread pointer
(Engram.context_id) and were missing the cause pointer — and EngramGraph,
the substrate built for exactly this, had ZERO production callers.

This slice gives it its first:

- EdgeKind::{CausedBy, Produced} — the causal spine, joining BJG's
  epistemic kinds on the ONE graph (no parallel store).
- AdmissionState owns the graph: link_engrams()/engram_neighbors(),
  wired at the site that KNOWS the relation, never inferred.
- ActChain: the settle driver owns the turn's causal thread; apply_act
  links each admitted act CausedBy its predecessor. Chain dies with the
  turn — edges cannot cross turns or rooms by construction.
- probe! engram.edge.caused_by at the link site (glass box).
- Design doc: docs/cognition/CAUSAL-MEMORY-GRAPH.md (slices B-D: compact
  scope-first ledger, thread retrieval affordance, confab/L1 consumers).

Freedom doctrine inherited from BJG §5: edges are facts about what
happened; the graph never decides; retrieval is an affordance she invokes.

Tests: a_settle_chain_links_each_act_caused_by_its_predecessor (+ serde
round-trip rows for the new kinds); act_observe 37/37, engram_graph 16/16,
admission_state 41/41 green.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(bindings): regenerate EdgeKind.ts for CausedBy/Produced + doc slice E (GraphViewState)

The ts-rs drift gate caught the missing regenerated binding for the new
EdgeKind variants. Also records slice E in the design doc per Joel:
the positron GraphViewState — event-driven engram-graph rendering, one
truth in Rust keyed (room_id, kind) per #408, her slice-C introspection
walk IS the human's clicked view (one graph, one query, two observers).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Fable 5 <[email protected]>
joelteply added a commit that referenced this pull request Aug 16, 2026
…2322)

* feat(cognition): causal memory slice B — compact typed receipt heads + room-scoped archive + scope-first ledger (#447)

Receipt heads now store the compact call form (name(args), 48-char arg cap)
instead of full prose dragging its ~250-char because-clause — ~5x more act
history in the same char budget. Heads carry an Option<room> tag; the
StepsLedger renders scope-first (this room's acts at real depth, cross-room
remainder as one honest line, unscoped heads never hidden at the upgrade
boundary). VolatileSnapshot round-trips the room tags via a parallel
receipt_head_rooms array (serde-default, old snapshots restore as unscoped).

Also fixes a 100%-reproducible SELF-DEADLOCK found by the suite: snapshot()
took receipt_heads.lock() twice inside one struct literal — the first guard
(a literal temporary) lives until the whole expression ends, so the second
lock waits on ourselves forever. Every deploy-pause snapshot would have
wedged. One lock now builds both parallel arrays.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(work): grader hears the STORE not the VERB — bridge wire CardStateChanged onto the bus, single emitter (#450)

Found positive-controlling the done→grade tail with Asha's real rle_roundtrip
artifact: 'airc work state <card> closed' changed the board and reached every
persona's stream, but benchmark_grade never fired — it subscribed to the
internal bus event only continuum's work/state verb emitted. One fact, two
disjoint event planes: a card closed by the operator CLI or a remote peer
graded NOTHING.

bridge_wire_work_event in modules/work.rs is now THE one emitter of
work.card.state_changed: pure decode via airc-work's real codec
(transcript_is_work_event → decode_transcript_work_event → CardStateChanged),
once-per-event-id dedup (every resident persona's subscribe stream echoes the
same wire event), publish through the existing WORK_EVENT_BUS. Called from the
persona inbound raw-event loop — the only channel-complete receiver this core
has (the daemon attach covers ONE room) — before the perceptual filter and the
self-skip, so a citizen's own work/state echo counts. The verb-side emit is
deleted; payload upgrades to the full hyphenated card UUID + snake_case
CardState serde form (the exact is_terminal/parse_state vocabulary).

Tests pin the decode contract against the real encoder, the non-state/non-work
refusals, and the first-sighting dedup.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(grade): room-scoped grading — read the CARD'S board, post the verdict IN the run room, glass-box every step (#450)

Live diagnosis after the bridge fired for Atlas's real balanced_brackets close:
the grade task parked forever with zero receipts. grade_card read the board via
work_board_complete — which airc-lib's own doc names as the #345 wrong-room
trap: it resolves current_room(), i.e. whatever room the grading citizen sits
in (academy), not the bench room the card lives in.

The bridge payload now carries the event's room_id (the card's own room — the
wire event knows). grade_card resolves that room from the citizen's
subscription set (same pattern as claim_following_card_room), reads
work_board_in(&room), and posts the verdict via publish_text_in_room into the
RUN room the citizens are standing in — Joel's #329 slice-3 targeting, no more
current-room dependency anywhere in the grade path. A missing/unresolvable
room fails LOUD instead of grading a guessed board.

Glass box per Joel ('this is why we have probes'): benchmark_grade.start,
benchmark_grade.verdict (both arms), benchmark_grade.error — the tail can
never again park silently.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(grade): subscribe on the LIVE bus tier — grade-on-done shipped on a dead dispatch path and never once fired (#450)

Third and final dead link in the done→grade tail, proven live: two bridged
publishes reached the bus, zero handle_event probes. Root cause is the
runtime's own documented trap (runtime.rs:99): config().event_subscriptions
installs synchronous-tier subscriptions the registry marks synchronous=false —
which publish() filters OUT. 'The (currently unused) synchronous publish path.'
Grade-on-done was born on it (#439) and has never fired in production.

Fix is the runtime's own prescription: initialize() spawns a bus-receiver task
(same shape as chat::spawn_persist_listener) filtering WORK_CARD_STATE_CHANGED;
the reaction logic is extracted into on_card_state_changed, shared with
handle_event (kept for the synchronous tier should it ever dispatch).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(grade): sweep lapsed bench claims with written artifacts — the manual flip becomes algorithm (#451)

The first graded pass needed an operator flip: Atlas wrote his artifact but the
grade only ran when a human closed his card. The sweeper encodes exactly that
hand-move: benchmark_grade ticks every 180s (a periodic actuator — lease expiry
is a time fact with no wire event) and closes any bench-titled card whose claim
LAPSED (card_holder::hold_of, the one lease predicate) with an owner and a real
artifact behind it (gym: non-empty solution_file; SWE: dirty workspace tree —
an untouched clone graded would burn a fake capability-zero, the #384 class).

The close is the whole action: its wire echo drives the proven
bridge → bus → receiver → grade tail. ONE grade path; the sweeper only detects.
A live claim is never preempted; a citizen's own done still beats the sweep;
normal work cards are never touched; ≤3 closes/tick so a backlog trickles
instead of storming the room. Provenance note posted before each close.

sweep_ready is a pure truth table with a pinned test.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(grade): sweep closes were failing SILENTLY — close first, note on success, loud error probes (#451)

First live tick: 21 sweep_close probes in 0.6s, sailing past the 3-close cap.
The cap only counts SUCCESSES, so 21 probes means the closes themselves were
refused — and the Err path had no probe, so the entire failure mode was
invisible (my own glass-box rule, violated in my own module). Worse, the
provenance note posted BEFORE the close attempt: a persistently-failing close
would have spammed every old bench room once per tick.

Reordered: change_work_card_state first; provenance note only on Ok (still
lands before the verdict — grading takes seconds); sweep_close_failed probe
with the refusal error on Err. Next tick's probes will name WHY airc refuses.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(grade): sweep closes through airc's room-scoped mutate (airc #1363) — the WRITE half of #345 (#451)

The instrumented tick named the refusal in one pass: 'work card X is not in
current room …; switch to the card's room before mutating it' — airc's
change_work_card_state guards against the author's CURRENT room, while the
sweeper's targets live in per-run bench rooms. Reads grew room-scoped
variants (work_board_in); mutates never did. Fixed at the native seam
(contribute-up): airc #1363 adds change_work_card_state_in(room, req) — same
guard strength, room as a parameter — merged to airc canary as 103fd898.

Continuum: bump airc rev 574ce235 → 103fd898; sweeper closes via the
room-scoped verb against the room whose board it just read.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants