Repository navigation
feat(context): symmetric citizens/ layout + AgentContext (Slice 4 of #142) - #1525
Merged
joelteply merged 2 commits intoJun 4, 2026
Merged
Conversation
…142) Joel 2026-06-04: "should use a more formulaic naming of directories for all users probably, right? Assume this is all headless rust" + "What about Codex and Gemini etc? Use always lowercase." Three coupled refactors that only make sense together — doing them separately would create transient asymmetric states. ## 1. Symmetric directory layout Every citizen home now lives under one root: ``` <continuum_root>/citizens/personas/<name>/airc/ <continuum_root>/citizens/agents/<provider>/<label>/airc/ <continuum_root>/citizens/humans/<host>/airc/ (Slice 5 wires) <continuum_root>/citizens/jtags/<id>/airc/ (Slice 5 wires) <continuum_root>/citizens/webs/<tab>/airc/ (Slice 5 wires) ``` All lowercase. Plural kinds. agents/ gets the 3-level path because provider is meaningful (claude / codex / gemini / hermes / future). ONE helper `citizen_home_path(continuum_root, kind, provider, label)` called from every kind's bootstrap. Slice 5 wires the remaining kinds; this slice ships the foundation + personas + agents. ## 2. IdentityKind refactor — drop Claude+Codex, add Agent Slice 1 reviewer flagged the sealed enum as an extensibility concern (GPT-5, Claude-5, Gemini, future). Per [[organization-purity-as-we-migrate]] the right collapse: ```rust pub enum IdentityKind { Persona, Agent, // <-- replaces Claude + Codex; provider in agent_provider Human, Jtag, Web, } ``` New field `Identity.agent_provider: Option<String>` carries the specific provider for Agent kinds (`"claude"`, `"codex"`, `"gemini"`, ...). `None` for non-Agent kinds. Lowercase by convention; substrate does NOT auto-lowercase (would mask caller bugs). Why `String` and not a sub-enum: adding a new agent provider should NOT require a substrate release. The few sites that branch on provider (future tool-use harness, model-tier metadata) match the string. Open-ended. ## 3. AgentContext — replaces ClaudeContext, parameterized by provider Slice 3's `ClaudeContext` generalizes to `AgentContext`. Same shape, same bootstrap contract — but `provider: String` carries which flavor. Claude becomes `AgentContext::bootstrap(..., "claude", ...)`, Codex calls with `"codex"`, Gemini with `"gemini"`. Same struct, same trait impl, same `Cow::Borrowed(&self.identity)` zero-clone shape. `AircHandleAdapter` lifts from `context/claude.rs` (private) to `context/airc_adapter.rs` (`pub(crate)`) per Slice 3 reviewer's non-blocking nit — every future non-persona kind reuses one impl. `ClaudeContext` / `ClaudeMetadata` / `ClaudeContextError` → `AgentContext` / `AgentMetadata` / `AgentContextError`. `bin/claude_join_demo.rs` → `bin/agent_join_demo.rs`, defaulting to provider=claude but parameterizable via `CONTINUUM_AGENT_PROVIDER` env. ## Migration — hard-error on legacy layout Existing personas have homes at `<root>/personas/<name>/airc/`. Existing Claude sessions have homes at `<root>/claudes/<label>/airc/`. Per [[no-fallbacks-ever]] the bootstrap path REFUSES to silently use the legacy paths. New error variants: - `PersonaAircRuntimeError::LegacyLayoutDetected` - `AgentContextError::LegacyLayoutDetected` Both messages spell out the exact `mv` command operator should run. Operator sees the rename + retries. No silent migration. ## Tests - `context::citizen_path::*` — 4 new tests (persona path, agent-provider segment, humans/jtags/webs skip provider, legacy detection) - `context::agent::*` — 2 tests (zero-clone Cow::Borrowed, multi- provider uniformity proves Claude/Codex/Gemini all fit one AgentContext shape) - `context::tests::stub_context_implements_context` updated to use `IdentityKind::Agent` + `agent_provider: Some("claude")` - `identity::tests::identity_round_trips_through_orm` updated to exercise the new shape (one Persona + one Agent with provider) - `identity::tests::identity_schema_is_derived` includes `agentProvider` in the schema check - `persona::airc_runtime::tests::bootstrap_resolves_home_under_personas_directory` updated to assert the new `citizens/personas/<name>/airc/` path - All test families pass; no regressions across identity, context, persona `agent_join_demo` compiles + has the right CLI signature (`CONTINUUM_AGENT_PROVIDER` + `CONTINUUM_AGENT_LABEL` env vars). ## Doctrine - [[airc-is-the-session-not-a-feature]] — symmetric layout reflects the every-citizen-is-the-same-kind-of-citizen substrate model - [[organization-purity-as-we-migrate]] — collapse asymmetric kinds + provider into one extensible shape - [[no-fallbacks-ever]] — legacy layout hard-errors, operator sees the exact mv command - CLAUDE.md outlier discipline — Agent(provider: String) is the open-end version of the sealed enum Slice 1 reviewer flagged - CLAUDE.md outlier validation — `AgentContext` with 4+ providers (claude / codex / gemini / hermes) all flow through ONE shape; proves the generalization holds beyond compile ## Out of scope (Slice 5) - `JtagContext` concrete + bootstrap - `HumanContext` concrete + bootstrap - `WebContext` (deferred until browser-tab actor exists) Slice 5 becomes mechanical given this foundation: each new kind calls `citizen_home_path` + `airc_lib::Airc::attach_as` + constructs Identity + wraps in AircHandleAdapter. Same shape, three times. Co-Authored-By: Claude Opus 4.7 <[email protected]>
…not-fallback, legacy detection tests Addresses Reviewer 1's BLOCK findings on PR #1525 (Slice 4 of #142). ## Finding #1 (BLOCKING) — hard build break `context::tests::log_actor_action_takes_any_context` constructed an `Identity` literal missing the new mandatory `agent_provider` field. `cargo test --lib -p continuum-core context::` failed to compile with E0063. The sibling `stub_context_implements_context` HAD the field; this one was missed in the refactor. **Fix:** added `agent_provider: None,` to the test's Identity literal (`IdentityKind::Jtag`; non-Agent kinds get None). The earlier test run that returned exit 0 was misleading — the tmp filesystem ran out of space and output was truncated; the actual compile error was hidden. Rerun confirms 13/0 pass for `context::` after the fix. ## Finding #2 (BLOCKING) — stale StubContext outlier-validation doc The `StubContext` doc at `context/mod.rs:151-161` still named `ClaudeContext` as the validation outlier. Slice 4 replaced `ClaudeContext` with `AgentContext`; the doc wasn't updated. **Fix:** doc now names `AgentContext` (Slice 4, parameterized by provider, ONE shape for Claude/Codex/Gemini/Hermes/future). The three-impl outlier story remains intact; the named impl is now correct. ## Finding #3 (BLOCKING) — LegacyLayoutDetected never exercised The "actionable `mv` command" message is the load-bearing safety claim of the migration story per [[no-fallbacks-ever]], and zero tests fired it. A regression flipping a path component or breaking the `new_parent` calculation would have passed CI silently. **Fix:** added three legacy-detection tests: 1. `context::agent::tests::legacy_claude_layout_hard_errors_with_mv_command` — seeds `<tmp>/claudes/default/airc/`, bootstraps with provider=claude, asserts `LegacyLayoutDetected` with exact `legacy` / `new` / `new_parent` paths. 2. `context::agent::tests::non_claude_provider_ignores_claude_legacy` — seeds the same Claude legacy, bootstraps with provider=codex, asserts the detection does NOT false-positive on a different provider's mint. 3. `persona::airc_runtime::tests::legacy_persona_layout_hard_errors_with_mv_command` — seeds `<tmp>/personas/maya/airc/`, bootstraps PersonaAircRuntime for "maya", asserts the same shape. Per [[every-error-is-an-opportunity-to-battle-harden]]: the message is load-bearing safety; these tests are the rigging that catches the regression class. ## Finding #4 — `unwrap_or("unknown")` was a soft fallback `citizen_home_path(.., kind=Agent, provider=None, ..)` previously joined an `"unknown"` segment, silently landing the agent under `citizens/agents/unknown/<label>/airc/`. Per the cited `[[no-fallbacks-ever]]` doctrine this is exactly what the substrate refuses — a programming bug ("forgot to thread the provider") should surface AT the call site, not produce a directory full of indistinguishable agents. **Fix:** changed to `.expect("provider is REQUIRED when kind == Agent")` with operator-actionable message. Panic point IS the call site; bug fix is local. Pinned by `context::citizen_path::tests::agent_without_provider_panics` (`#[should_panic]`). `AgentContext::bootstrap` always passes `Some(&provider)`, so this is purely defensive — the panic catches future call sites that misuse the helper. ## Findings deferred (non-blocking nits) - **#5** — Lowercase enforcement debug-assert on AgentContext's provider input. The substrate-is-mechanism-not-policy choice stands; documented in doc-comment. Could be tightened in a follow-up if pressure builds. - **#6** — `provider-label` agent_name cross-host collision (e.g. two machines both with `claude-default`). Existing Slice-3-acknowledged hazard now carried forward to all Agent providers. Per the original review, the substrate routes on peer_id (cryptographic, never collides); the human-readable label collision is a UX rough edge. Suffix-peer_id-short remediation tracked as a follow-up if/when `airc whois <name>` starts mattering more. ## Test results - `context::*` — 13/0 pass (was 6; +7 for Slice 4 legacy detection + panic invariant + the existing fix tests) - `persona::airc_runtime::*` — 7/0 pass (was 6; +1 for persona legacy detection) - No regressions ## Doctrine - [[no-fallbacks-ever]] — soft `unknown` fallback replaced with panic at the call site - [[every-error-is-an-opportunity-to-battle-harden]] — legacy detection now has the rigging that catches the class - CLAUDE.md "never commit code until you validate it works" — the earlier exit-0 was a misleading-truncation signal; the full build+test loop now passes locally Co-Authored-By: Claude Opus 4.7 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Slice 4 of #142 — three coupled refactors that only make sense together:
citizens/<kind>/[<provider>/]<label>/airc/directory layout — one root for all citizens, kind discriminator, lowercase plural, agents/ gets a 3-level path because provider is meaningful.IdentityKindrefactor — dropClaude+Codex(sealed-enum extensibility concern flagged by Slice 1 reviewer); addAgentvariant +agent_provider: Option<String>field. Adding GPT-5 / Gemini / Hermes is now a string, not an enum churn.AgentContextreplacesClaudeContext, parameterized by provider. Claude =bootstrap(.., "claude", ..); Codex/Gemini/etc. use the same struct with their provider tag.AircHandleAdapterlifted fromclaude.rs(private) tocontext/airc_adapter.rs(shared) per Slice 3 reviewer's nit.Doing these separately would create transient asymmetric states. Bundled for coherence.
What changes
Layout helper
context/citizen_path.rs—citizen_home_path(continuum_root, kind, provider, label)is THE single source of truth for citizen home directory resolution. Every kind's bootstrap calls it.legacy_home_pathreturns pre-Slice-4 paths for migration detection.IdentityKind
New
Identity.agent_provider: Option<String>field.Nonefor non-Agent kinds.AgentContext
context/agent.rs— generic external-AI Context. Bootstrap takesprovider: impl Into<String>. ImplementsContextwithCow::Borrowed(&self.identity)zero-clone. Tests prove Claude/Codex/Gemini/Hermes all flow through one shape.AircHandleAdapter lift
context/airc_adapter.rs—Arc<airc_lib::Airc>→dyn AircCitizen + dyn AircTranscriptReaderbridge. Reusable across every non-persona kind (JtagContext / HumanContext / future).PersonaAircRuntime
Bootstrap calls
citizen_home_path(.., Persona, ..)→ new pathcitizens/personas/<name>/airc/. Legacy path detection returns typedLegacyLayoutDetectederror with the exactmvcommand.bin/agent_join_demoRenamed from
claude_join_demo. Env vars:CONTINUUM_AGENT_PROVIDER(defaultclaude),CONTINUUM_AGENT_LABEL(defaultdefault).Migration discipline
Per
[[no-fallbacks-ever]]: both PersonaAircRuntime AND AgentContext hard-error if they detect a pre-Slice-4 path. The error message spells out themvcommand — operator runs it, retries, done. No silent re-use of legacy paths.Test plan
context::citizen_path::*— 4 new tests (persona path, agent provider segment, humans/jtags/webs skip provider segment, legacy detection)context::agent::*— 2 tests (Cow::Borrowed semantics + Claude/Codex/Gemini/Hermes uniformity)context::tests::stub_context_implements_contextupdated to new Agent shapeidentity::tests::identity_round_trips_through_orm+identity_schema_is_derivedupdatedpersona::airc_runtime::tests::bootstrap_resolves_home_under_personas_directoryupdated to new layoutagent_join_democompiles withmetal,acceleratecargo run --bin agent_join_demo, verifyairc inboxshows message authored by the Claude peer_id (separate from host)Doctrine
[[airc-is-the-session-not-a-feature]]— symmetric layout reflects the every-citizen-is-the-same-kind-of-citizen substrate model[[organization-purity-as-we-migrate]]— collapse asymmetric kinds + provider into one extensible shape[[no-fallbacks-ever]]— legacy layout hard-errors with operator-actionable remedyAgent(provider: String)is the open-end version of the sealed enumAgentContextshapeOut of scope (Slice 5)
JtagContext,HumanContext,WebContextconcrete typesTargets
canary.🤖 Generated with Claude Code