Imported from cntryl/fitz (
AGENTS.md). Install upstream withnpx skills add cntryl/fitz. Copyright stays with the author.
Fitz Agent Guide
Repo Layout
- Root is a Rust workspace. Main code lives under
src/. ui/is a separate Node/Vite workspace with its ownAGENTS.mdand localskills/tree.public/containsopenapi.ymlfor UI adapter generation and legacy static files; production SPA assets are served from/app/public. See public/README.md.- Root workspace skills live under root
skills/.
Read First
- docs/development/architectural-laws.md
- docs/development/domain-boundaries-spec.md
- docs/development/routing-design.md
- docs/development/architecture.md
- docs/development/testing.md
- docs/development/benchmarks.md
- docs/development/stress-bench-contract.md
- docs/development/perf-loop.md for performance work
- CONTRIBUTING.md for local setup and validation
Hard Constraints
- Async belongs only at the transport edge in
src/api/. - Keep
src/session/,src/runtime/,src/protocol/, andsrc/domains/synchronous. - Sessions are ephemeral. Disconnect creates a new session.
- Do not imply durability, replay, exactly-once delivery, recovery, or ownership continuity unless storage and docs explicitly support it.
- Preserve the domain meanings: Notice = live ephemeral fanout, Stream = durable history/replay, KV = current authoritative state, Queue = durable work delivery, RPC = live request/response, Lease = ephemeral ownership coordination, Schedule = durable timing intent.
- If semantics change, update the relevant docs in the same change.
Realm vs RouteFamily
realmis an opaque, application-defined namespace boundary.- A
realmmay represent a tenant, department, cost center, user, environment, or any other developer-chosen partition. - Fitz does not assign one business meaning to
realm, so do not define it as "tenant" in core semantics. realmandroute_familyare orthogonal identifiers.realmis the application-visible namespace label used in Fitz routes, permissions, and admin/API payloads.route_familyis a broker-internal routing and isolation key used for session assignment and delivery partitioning.- They MUST NEVER be inferred from each other, aliased, substituted, or used as fallback values.
- If
realmis unknown or absent, it stays unknown or absent. It is neverroute_family.to_string().
Wrong:
session.realm = session.route_family.to_string()- describing
realmas inherently equal totenant - treating
?realm=41as route-family selection
Right:
- expose
realmandroute_familyseparately when both matter - filter by
realmusing realm-bearing data only - treat external claim names like
tenant_idas claim-source naming, not Fitz core terminology
Working Rules
- Keep changes small and focused.
- Do not overwrite unrelated user edits.
- Prefer the nearest file that controls the behavior over broad refactors.
- Keep files small. No file should exceed 1,000 lines, and files should be split or refactored before they approach that limit.
- Optimize for simplicity. Complexity, DRY, and clarity are mandatory design constraints.
- Avoid adding async constructs to core Rust code outside transport (
.await,tokio::spawn,tokio::sync, async locks). - Do not create a top-level
scripts/directory or repo-owned standalone shell scripts. Put automation in Rust tests or tools, package scripts, or explicit workflow steps. - When editing UI tooling, prefer ESM and
.jsover.mjsfor repo-owned files. - When
public/openapi.ymlor the UI client changes, regenerate adapters withnpm run gen:adaptersfromui/.
Validation
- Rust:
cargo fmt --all -- --check,cargo test --workspace,cargo clippy --locked --workspace --all-targets --all-features -- -D warnings -D clippy::pedantic. - UI: run from
ui/withnpm run test,npm run lint,npm run type-check, andnpm run build. - Benchmarks: use direct
cargo benchcommands for the relevant tier or target, then runcntryl-tools summarize-benchmarkswhen a report is needed.
Test Rules
- Use
should_*names for Rust tests. - For tests longer than 5 lines, use exact
// Arrange,// Act, and// Assertcomments. - Keep each test focused on one behavior.
- Put unit tests near the code and integration tests in
tests/.