Skip to content

test(arch): ban CommandExecutor calls inside cognition via shape-5 ratchet (task #240) - #1592

Merged
joelteply merged 1 commit into
canaryfrom
chore/arch-test-compose-by-event
Jun 10, 2026
Merged

joelteply merged 1 commit into
canaryfrom
chore/arch-test-compose-by-event

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Fourth proof in the architecture-test matrix. Shape-5 build-graph ratchet pinning the "module compose-by-event" doctrine clause — bans new CommandExecutor::execute_* calls inside cognition/*.

  • Test ships at: core/continuum-core/tests/architecture_compose_by_event.rs
  • Grandfathered budget: 1 call — cognition/vision_describe.rs::describe_image_via_ai_generate invokes executor.execute_json("ai/generate", ...).
  • Ratchet only moves down. NEW calls BLOCK; migration tracked under Build(deps-dev): Bump @typescript-eslint/eslint-plugin from 8.29.1 to 8.41.0 #112-Build(deps): Bump inquirer from 8.2.6 to 12.9.4 #114 (route persona response / should_respond / validate through inference handle).
  • Forbidden patterns: the four CommandExecutor-distinctive methods — .execute_json(, .execute_with_caller(, .execute_ts(, .execute_ts_json(. Bare .execute( intentionally NOT in the list (false positives on futures, queues, etc).
  • Test mods exempted via brace-depth parser (same shape as the singleton-ban PR test(arch): ban static OnceLock<Arc<T>> singletons via shape-5 ratchet (task #240) #1591).
  • Line comments skipped so doc references like Commands.execute('cognition/vision-describe', ...) don't trip the scanner.
  • Positive pin: command_executor_remains_the_outer_boundary asserts runtime/command_executor.rs exists, declares pub struct CommandExecutor, exposes execute_json. Rename → loud, not silent.

Why ratchet (not strict)

The single existing call needs a considered migration (InferenceHandle pre-binding, lifecycle wiring), not a sed sweep. The doctrine clause graduates to ✅ when the inference-routing campaign (#112-#114) lands.

Matrix update

PROVING-THE-DOCTRINE.md row for "Module compose-by-event" flips from 🔴 (no proof) to 🟡 (ratchet active).

Test plan

  • cargo test -p continuum-core --test architecture_compose_by_event --features metal,accelerate — 2/2 pass
  • Grandfathered count = 1 (exact match)
  • // proves: module compose-by-event tag applied

Doctrine alignment

  • Substrate doctrine § "Module compose-by-event"
  • [[no-fallbacks-ever]] — ratchet IS the no-fallback equivalent for cognition↔command-executor coupling at build-graph layer

Related

🤖 Generated with Claude Code

…ratchet (task #240 — fourth proof shape)

Fourth proof in the architecture-test matrix. Pins the "module
compose-by-event" doctrine clause — substrate-internal modules
compose via the event substrate (MessageBus subscribe/emit) or via
pre-bound handles, not by imperative `CommandExecutor::execute_*`
round-trips through the outer command interface inside the
cognition hot path.

## What ships

`core/continuum-core/tests/architecture_compose_by_event.rs` — two
integration tests:

1. `cognition_command_executor_calls_ratchet` — scans every `.rs`
   file under `core/continuum-core/src/cognition/`, finds lines
   matching `.execute_json(`, `.execute_with_caller(`,
   `.execute_ts(`, `.execute_ts_json(`, asserts the count doesn't
   grow beyond the current grandfathered budget of **1**. NEW
   calls BLOCK; the existing one is tracked under #112-#114
   (route persona response / should_respond / validate through
   inference handle).

   Bare `.execute(` is intentionally NOT in the forbidden list —
   it would generate false positives across futures, queues, and
   other APIs. If a typed `executor.execute(typed_args)` pattern
   appears inside cognition in a future refactor, extend the list.

   Test mods (`#[cfg(test)] mod ... { ... }`) are exempted via
   the same brace-depth parser as the singleton-ban test, with
   inline `#[cfg(test)] mod tests {` handling.

   Line comments (`//` lines) are skipped so doc comments quoting
   the very pattern being banned don't trip the scanner — this
   matters for cognition module top-of-file docs that reference
   `Commands.execute('cognition/...')` as the TS-side caller
   contract.

2. `command_executor_remains_the_outer_boundary` — positive pin:
   `runtime/command_executor.rs` exists, declares
   `pub struct CommandExecutor`, exposes `pub async fn execute_json`.
   If the type is renamed or `execute_json` moves, the test is
   loud, not silent — and the FORBIDDEN list in this test file
   needs updating to match.

## The 1 grandfathered violation

`cognition/vision_describe.rs::describe_image_via_ai_generate` calls
`executor.execute_json("ai/generate", ...)`. The clean fix is a
pre-bound `InferenceHandle` (cf. tasks #107-#108), called directly
the same way `airc_chat_demo` already does. Migration tracked under
#112-#114 (the inference-command-routing campaign) and #106
(ai/* namespace consolidation).

## Why ratchet (not strict)

Same reason as engine-OS layering and singleton-ban: the single
existing violation needs a considered migration (which `InferenceHandle`
to pre-bind, where to wire the lifecycle), not a sed sweep. NEW
violations BLOCK at PR time; the ratchet count graduates to ✅ when
#112-#114 land.

## Matrix update

`PROVING-THE-DOCTRINE.md` row for "Module compose-by-event" flips
from 🔴 (no proof) to 🟡 (ratchet active, target ✅ when count = 0).

## Test plan

- [x] `cargo test -p continuum-core --test
      architecture_compose_by_event --features metal,accelerate`
      — 2/2 pass; grandfathered count = 1 (exact match)
- [x] `// proves: module compose-by-event` tag applied
- [x] Ratchet logic verified (both grow-detection and
      shrink-detection paths via inspection)
- [x] Line-comment skip verified — the two pre-existing
      `Commands.execute(...)` doc references in
      `vision_describe.rs` and `rate_proposals/mod.rs` do NOT
      trip the scanner

## Doctrine alignment

- Substrate doctrine § "Module compose-by-event" — cognition
  composes via event substrate or pre-bound handles, not
  imperative request-response round-trips
- [[no-fallbacks-ever]] — the ratchet IS the no-fallback
  equivalent for the cognition→command-executor coupling at
  build-graph layer

## Related

- Task #240 — architecture-test matrix, fourth proof
- Builds on PR #1589 (ratchet pattern) and PR #1591 (singleton ban —
  same scanner shape)
- Migration follow-up: tasks #112-#114 (#113 is currently
  in_progress) → ratchet count goes 1 → 0 → strict

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@joelteply
joelteply merged commit 5752d00 into canary Jun 10, 2026
2 checks passed
@joelteply
joelteply deleted the chore/arch-test-compose-by-event branch June 10, 2026 01:16
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