Skip to content

feat(persona): service_module batched cutover via analyze_burst (task #249) - #1598

Merged
joelteply merged 2 commits into
canaryfrom
feat/service-module-batched-cutover
Jun 11, 2026
Merged

joelteply merged 2 commits into
canaryfrom
feat/service-module-batched-cutover

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Production wiring for the demand-pull cognition doctrine PR #1597 landed at the substrate seam. PersonaServiceModule::service_burst_for replaces the per-item service_once_for path: ONE call per persona per tick drains every channel's coherent burst via ChannelRegistry::service_cycle_batched and runs cognition's analyze_burst per burst.

Stacks on #1597 (base = feat/channel-adapter-batch-cognition). Auto-rebases to canary once #1597 merges.

Theme — Demand-pull cognition cutover (task #249)

Per [[cognition-batches-per-channel-adapter]]: one gate decision per channel-tick, not per item. A burst aggregating N chat messages = ONE inference dispatch.

  • ServiceBurstDecision replaces ServicePopDecision: Silent | NeedsResponse | UnsupportedDomain. Non-Chat bursts surface as UnsupportedDomain (typed view not yet implemented) rather than silently dropping per [[no-fallbacks-ever]].
  • build_respond_input_from_burst replaces the per-item build_respond_input; reads BurstRespondContext.aggregated_content + room_id, anchors message_id at burst granularity.
  • drain_all_personas loses the while drained < MAX_DRAIN_PER_TICK item-counting loop — replaced by a Vec iterator over the bursts service_burst_for returned. Per-tick work is naturally bounded by the number of active ActivityDomains (4), not an arbitrary item cap. Lock discipline preserved: brief lock around the sync drain, drop, await respond, brief lock to update CB.
  • Dead code removed: MAX_DRAIN_PER_TICK, ChatItemWire, ServiceOnceOutcome (was never consumed by a caller). Per [[organization-purity-as-we-migrate]].

Theme — Stale doc-refs cleanup

The airc_chat_demo binary is gone (deleted with task #137's reshape); service_module::service_once_for is gone (this PR). Six doc comments still named them as load-bearing examples — that's misleading for navigators.

Rewrites the references in host.rs, airc_persona_conversation.rs, spawner_module.rs, service_loop.rs (3 sites), channel_registry.rs (2 sites), and channel_view.rs to point at what's actually in tree (service_burst_for, analyze_burst, integration tests).

Task #245 deferred

ChatItem::embedding() still routes through the placeholder pure-decoder, not the real EmbeddingModule. Architectural read: making embedding() async to route through EmbeddingModule cascades to OnceLock → tokio::sync::OnceCell, ChatChannelView::interpret, interpret_for_domain, and service_cycle_batched — a substantive shape change to the lazy cell PR #1597 just landed. burst_embedding has no production consumer today (doctrine-witness tests only), so the right slice is a follow-up after #1597 merges, with the async cascade designed cleanly against a stable canary baseline. Tracked as task #245.

Doctrines anchoring this PR

  • [[cognition-batches-per-channel-adapter]] — one analyze per channel-tick
  • [[no-fallbacks-ever]] — UnsupportedDomain surfaces non-Chat bursts; analyze_burst's typed contract (should_respond ⇒ respond_context = Some) is enforced at the seam
  • [[organization-purity-as-we-migrate]] — dead code (MAX_DRAIN_PER_TICK, ChatItemWire, ServiceOnceOutcome) deleted as we touch the file

Architecture docs

  • docs/architecture/PERSONA-COGNITION-PIPELINE.md — what a persona IS + the cognition cycle
  • docs/architecture/CONCURRENCY-STYLE-GUIDE.md — RTOS shape every ServiceModule inherits

Test plan

  • cargo check -p continuum-core --features metal,accelerate clean (69 warnings, 0 errors)
  • cargo test -p continuum-core --features metal,accelerate --lib persona::service_module — 24/24 green
  • cargo test -p continuum-core --features metal,accelerate --lib persona:: — 777/777 green
  • New tests pin the burst contract: service_burst_for_idle_returns_empty_vec, service_burst_for_dispatches_chat_burst_through_analyze_burst, drain_handles_large_burst_without_tripping_cb
  • CI: full continuum-core build + integration tests (after feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597 merges to canary)

@joelteply

Copy link
Copy Markdown
Contributor Author

SENTINEL VERDICT: APPROVE (producer-pays self-review)

Adversarial self-review per producer-pays. This is the production wiring slice of #1597's demand-pull cognition; the changes are narrow, doctrinally consistent, and test-pinned.

What's structurally right:

  • ServiceBurstDecision { Silent | NeedsResponse | UnsupportedDomain } correctly extends the typed-decision shape from feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597 into the substrate seam. UnsupportedDomain surfacing non-Chat bursts honestly is the [[no-fallbacks-ever]] move — silent-drop would have been a regression dressed up as a refactor.
  • drain_all_personas loses the while drained < MAX_DRAIN_PER_TICK loop. Naturally bounding per-tick work by active ActivityDomain count instead of arbitrary item cap is the right shape for the burst-cognition doctrine. The Vec iterator over the bursts service_burst_for returned is correct: synchronous drain → drop lock → await respond → re-acquire lock to update CB. Lock-discipline-across-await is preserved (CB section is short, no await held).
  • Dead-code removal (MAX_DRAIN_PER_TICK, ChatItemWire, ServiceOnceOutcome) per [[organization-purity-as-we-migrate]]. These had no callers; removing them now is cheaper than removing them at task Widget state → RAG pipeline + semantic loop detection #245's seam later.
  • Six stale doc-refs rewritten to name what's in tree (service_burst_for, analyze_burst, integration tests) instead of the deleted airc_chat_demo / service_once_for. Doc rot is the silent kind; catching it under "I'm touching this file anyway" is the cheapest fix moment.
  • ChatItem::embedding() deferred to Widget state → RAG pipeline + semantic loop detection #245 with honest justification. The body articulates the async-cascade cost (OnceLock → tokio::sync::OnceCell → ChatChannelView::interpret → interpret_for_domain → service_cycle_batched) and notes burst_embedding has no production consumer today. That's the right shape for a deferral: documented, scoped, with a follow-up tracked.

Five non-blocking findings:

  1. Stack dependency on feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597 is the same trap that just bit the positron stack tonight. Base = feat/channel-adapter-batch-cognition (feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597's branch). If feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597 squash-merges with --delete-branch, feat(persona): service_module batched cutover via analyze_burst (task #249) #1598 closes auto and loses its review trail (the exact 2-hour cascade I just rebuilt on positron tonight). Recommend: BEFORE feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597 merges, retarget feat(persona): service_module batched cutover via analyze_burst (task #249) #1598 to canary via gh api -X PATCH .../pulls/1598 -f base=canary (the only call that doesn't silently no-op when GraphQL emits the projects-classic warning), then merge feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597 first, then rebase feat(persona): service_module batched cutover via analyze_burst (task #249) #1598 onto the new canary HEAD. Sibling to airc gap card 6967921d.

  2. Per-tick CPU bound is domains × max_burst_size, not MIN(item_cap, …). Body says "Per-tick work is naturally bounded by the number of active ActivityDomains (4)" — but each burst can aggregate arbitrarily many items into a coherent unit. A flood-room (1000 messages in one tick) produces one burst of 1000 items, and the analyze runs against that whole burst. Worth verifying: does consolidation_key clustering enforce a max-burst-size invariant upstream? If not, the new bound is "4 × unbounded" and the old MAX_DRAIN_PER_TICK was actually load-shedding under flood — its removal could change behavior under adversarial input. Probably fine since flood-room is rare and consolidation is per-room/sender, but worth a comment in service_burst_for documenting the assumption.

  3. UnsupportedDomain handling at the call site. Surfacing it from service_burst_for is correct; what the caller does is the load-bearing half. If drain_all_personas silently logs + skips on UnsupportedDomain, that's a fallback by another name. If it fails loudly (panic, error-bubble), the substrate breaks the first time a video burst hits a chat-only persona. Worth a // TODO(domain-X): when Video/Code/Game views land, the UnsupportedDomain branch becomes Domain::interpret(...) comment so the failure mode is documented as known-incomplete rather than oversight.

  4. ChatItem::embedding() placeholder is consumable today. The justification is correct (no production consumer right now), but production-callers between feat(persona): service_module batched cutover via analyze_burst (task #249) #1598 merge and Widget state → RAG pipeline + semantic loop detection #245 land could accidentally consume the placeholder. Suggest: make the placeholder return type structurally refuse production use — e.g. wrap in Placeholder(Vec<f32>) newtype that doctrine-witness tests construct via Placeholder::for_tests(...) and production code can't construct. Then a future caller gets a compile error instead of a quiet wrong value. Same shape as PersonaIdentity's newtype in feat(persona,client): demand-pull cognition + AircIpcTransport::subscribe (tasks #244/246/247/248/251/143) #1597. Minor; the deferral itself is the right call.

  5. Test plan checkbox [ ] CI: full continuum-core build + integration tests (after #1597 merges to canary). Producer-pays should be: when the prerequisite (1597 merge) flips state, revisit + check the box. Recommend marking this PR draft-until-1597-merged so the checkbox commitment is structural, or adding an issue-comment template that prompts the producer to re-validate post-prerequisite.

Smaller PR than #1597, smaller review. Ship it after the stack-retarget mechanic in finding #1.

@joelteply
joelteply changed the base branch from feat/channel-adapter-batch-cognition to canary June 11, 2026 04:16
joelteply and others added 2 commits June 10, 2026 23:17
… analyze_burst (task #249)

Production wiring for the demand-pull cognition doctrine that PR #1597
landed at the substrate seam. `PersonaServiceModule::service_burst_for`
replaces the per-item `service_once_for` path:

- ONE call per persona per tick drains every channel's coherent burst
  via `ChannelRegistry::service_cycle_batched` and runs cognition's
  `analyze_burst` per burst. Per `[[cognition-batches-per-channel-
  adapter]]`: one gate decision per channel-tick, not per item. A
  burst aggregating N chat messages = ONE inference dispatch.

- `ServiceBurstDecision` replaces `ServicePopDecision`:
  `Silent | NeedsResponse | UnsupportedDomain`. Non-Chat bursts
  surface as `UnsupportedDomain` (typed view not yet implemented)
  rather than silently dropping per `[[no-fallbacks-ever]]`.

- `build_respond_input_from_burst` replaces the per-item
  `build_respond_input`; reads `BurstRespondContext.aggregated_content`
  + `room_id`, anchors `message_id` at burst granularity.

- `drain_all_personas` loses the `while drained < MAX_DRAIN_PER_TICK`
  item-counting loop — replaced by a Vec iterator over the bursts
  service_burst_for returned. Per-tick work is naturally bounded by
  the number of active `ActivityDomain`s (4), not an arbitrary item
  cap. Lock discipline preserved: brief lock around the sync drain,
  drop, await respond, brief lock to update CB.

- Dead code removed: `MAX_DRAIN_PER_TICK`, `ChatItemWire`,
  `ServiceOnceOutcome` (was never consumed by a caller — only
  defined). Per `[[organization-purity-as-we-migrate]]`.

Tests updated:
- service_burst_for_idle_returns_empty_vec (pins zero-work to zero
  bursts, not "one burst with empty content")
- service_burst_for_dispatches_chat_burst_through_analyze_burst
  (pins one item to one Chat burst to NeedsResponse with config
  flowing through + aggregated_content carrying burst text)
- drain_handles_large_burst_without_tripping_cb (replaces the
  MAX_DRAIN_PER_TICK item-count test — new contract is "many items
  consolidate into a coherent burst; CB stays clean")
- Existing CB / responder-DI tests unchanged in shape; comments
  rewritten to reference `analyze_burst` instead of `full_evaluate`
  and the new break-on-inference-error semantics.

24/24 service_module tests + 777/777 persona:: tests green.

Stacks on PR #1597 (analyze_burst + service_cycle_batched seams).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…m in-tree doc comments

The `airc_chat_demo` binary is gone (deleted with task #137's reshape);
the `service_module::service_once_for` symbol is gone (replaced by
`service_burst_for` in the prior commit). Six doc comments still
named them as load-bearing examples — that's misleading for anyone
navigating the substrate.

Rewrites the comments to reference what's actually in tree:
- `persona/host.rs`: `spawn_persona_service` users → "supervisor and
  integration tests"
- `persona/airc_persona_conversation.rs`: live-stream-lag handling
  rationale → `[[no-fallbacks-ever]]` doctrine link (the binary
  reference was always derivative)
- `persona/spawner_module.rs`: "demo binary's main today" → "originally
  inlined per-persona; slice 9 factored it out for production boot +
  tests"
- `persona/service_loop.rs` (3 sites): `airc_chat_demo` direct caller
  → "integration tests"; the bin/line ref in the test docstring → the
  doctrine name
- `persona/channel_registry.rs` (2 sites): `service_cycle` legacy
  surface now correctly points at `service_module::service_burst_for`
  as the production cutover (task #249), with `service_cycle` retained
  for the parity-architecture-proof test and `modules/channel` paths
- `persona/channel_view.rs`: Delta 5 `service_cycle` rewrite reference
  → `analyze_burst` + `service_burst_for` (the production seams that
  actually shipped)

Comment-only change. Zero behavioral delta.
`cargo check -p continuum-core --features metal,accelerate` green.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@joelteply
joelteply force-pushed the feat/service-module-batched-cutover branch from 8ce9f90 to 9f287c3 Compare June 11, 2026 04:18
@joelteply
joelteply merged commit 2a4b996 into canary Jun 11, 2026
2 checks passed
@joelteply
joelteply deleted the feat/service-module-batched-cutover branch June 11, 2026 04:18
joelteply added a commit that referenced this pull request Oct 21, 2026
…pen special cases (card f878fb9a)

Serves the residents directly (plan: order of work, "every fast-path miss loud" /
the act gate): a card reopened under its holder left her holding work the board
showed Open. Atlas and 4c9bb8d9 on the M5 renewed claims on SWE cards she could
not act on (card 12afbb2f). airc #1598 fixes the owner: its projection now ends
the claim on any transition to Open, so continuum stops patching around it.

- airc pin 44478af -> 2666f36 (#1592, #1594-#1598; the Cargo.toml note lists each).
  Cargo.lock changes only the rev; `cargo metadata` resolved with no other change.
- work_create: delete release_live_claim_on_reopen. Its release is now a no-op on
  the projection (the claim already ended). The bench round's settled mark is still
  cleared on reopen.
- work_focus::actionable: revert #5248's Open arm and its test. An Open card can no
  longer be in her held set, because the held set is the board's live claims.
- release_live_claim_on_reopen.rs held four verbs after the #5245 split. Each moves to
  its own file, as a pure move (checked with a multiset diff: the only lines without a
  match are the deleted function, the deleted call and its comment, the mod/use
  wiring, and one `use super::*;` per new file): work_note.rs, work_heartbeat.rs,
  work_list.rs; the work/similar types join their impl in work_similar.rs (644 lines).
- identity/mod.rs: the loose-card-id allowlist names the new files.
- card_holder: the comment says Open no longer carries a claim.

Net: 397 lines removed, 332 added (git --numstat). Git reads the move as a rename,
release_live_claim_on_reopen.rs -> work_list.rs, plus the new files; the real deletions are
the release function (~45 lines) and #5248's Open arm and test (29).
source-hygiene 43/43 on IntelMac. The core isn't compiled here (serving node); CI compiles it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Oct 21, 2026
…pen special cases (card f878fb9a) (#5256)

Serves the residents directly (plan: order of work, "every fast-path miss loud" /
the act gate): a card reopened under its holder left her holding work the board
showed Open. Atlas and 4c9bb8d9 on the M5 renewed claims on SWE cards she could
not act on (card 12afbb2f). airc #1598 fixes the owner: its projection now ends
the claim on any transition to Open, so continuum stops patching around it.

- airc pin 44478af -> 2666f36 (#1592, #1594-#1598; the Cargo.toml note lists each).
  Cargo.lock changes only the rev; `cargo metadata` resolved with no other change.
- work_create: delete release_live_claim_on_reopen. Its release is now a no-op on
  the projection (the claim already ended). The bench round's settled mark is still
  cleared on reopen.
- work_focus::actionable: revert #5248's Open arm and its test. An Open card can no
  longer be in her held set, because the held set is the board's live claims.
- release_live_claim_on_reopen.rs held four verbs after the #5245 split. Each moves to
  its own file, as a pure move (checked with a multiset diff: the only lines without a
  match are the deleted function, the deleted call and its comment, the mod/use
  wiring, and one `use super::*;` per new file): work_note.rs, work_heartbeat.rs,
  work_list.rs; the work/similar types join their impl in work_similar.rs (644 lines).
- identity/mod.rs: the loose-card-id allowlist names the new files.
- card_holder: the comment says Open no longer carries a claim.

Net: 397 lines removed, 332 added (git --numstat). Git reads the move as a rename,
release_live_claim_on_reopen.rs -> work_list.rs, plus the new files; the real deletions are
the release function (~45 lines) and #5248's Open arm and test (29).
source-hygiene 43/43 on IntelMac. The core isn't compiled here (serving node); CI compiles it.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant