Source reference: docs/architecture/native-layout.md at 41af2124

C# and Rust implement the same three products. Selecting an implementation does not change the UI, wire contracts, database or product responsibilities. The tree below shows shared files and language-specific code.

Source tree#

services/
  crossfire/
    apps/web/                         one React application
    database/
      management/sqlite/
        migrations/                   Knex only
        seeds/
    knexfile.management.mjs
    packages/                         shared TypeScript contracts and tooling
    tools/                            optional operator clients
    Dockerfile.build                  UI/assets/Knex build stages
    csharp/
      apps/Crossfire.Server/
      packages/
      tests/
      build/
        Crossfire.EfCompiler/          design-time query generation
        Crossfire.EfHost/              design-time host
      scripts/
      Dockerfile
    rust/
      apps/server/
      packages/
      tests/
      scripts/                        native container package construction
      Dockerfile
    tests/contracts/                  implementation-independent assertions
    scripts/                          shared asset/schema generators
  fleetd/
    packages/                         shared TypeScript contracts and tooling
    tools/
    csharp/{apps/Fleetd.Daemon,packages,tests}/
    rust/{apps/daemon,packages}/
    tests/contracts/
  fleet/
    packages/                         shared TypeScript contracts and tooling
    csharp/{apps/Fleet.Cli,packages}/
    rust/{apps/cli,packages}/
    tests/contracts/
scripts/                              workspace/build/verification only

Rust integration tests live in their crates. C# uses .NET project, namespace and file conventions. Corresponding packages have the same responsibilities but need not have identical file names.

Semantic package map#

ResponsibilityC#Rust
Primitive results, identity and timeCrossfire.Kernelkernel
Rules and repository portsCrossfire.Domaindomain
Wire validation and viewsCrossfire.Contractscontracts
Private files and path validationCrossfire.AdapterFilesystemadapter-filesystem
REST client and transportCrossfire.AdapterHttpadapter-http
Matrix HTTP integrationCrossfire.AdapterMatrixadapter-matrix
SQLite connections, query metadata and transactionsCrossfire.AdapterSqliteadapter-sqlite
Calendar schedulingCrossfire.AdapterScheduleadapter-schedule
Pure listener/runtime coordinationCrossfire.AgentCoreagent-core
Journals, delivery confirmation and restart stateCrossfire.AdapterRuntimeadapter-runtime
Native parent-lifetime guard and owned groupsCrossfire.AdapterRuntime + Crossfire.AdapterProcessadapter-process
Codex integrationCrossfire.AdapterCodexadapter-codex
Earendil Pi integrationCrossfire.AdapterPiadapter-pi
Enrollment, fleet connection and private listener hostCrossfire.AdapterCrossfireadapter-crossfire
Fleet lifecycle and pure portsFleetd.Domainfleetd/domain
Fleet configuration and API contractsFleetd.Contractsfleetd/contracts
Fleet private persisted stateFleetd.Storagefleetd/storage
Concrete runtime/listener compositionFleetd.AdapterExecutionfleetd/adapter-execution
Daemon clientFleet.DaemonClientfleet/daemon-client
Strict SSH transportFleet.SshTransportfleet/ssh-transport

Domain code depends on kernel values and declared pure ports, never concrete transport, SQLite, runtime, filesystem or UI implementations. Composition roots assemble adapters. Applications are not reusable dependencies and product dependencies cannot reference test fixtures or build tooling.

fleetd owns one shared listener host and native lifecycle. Its daemon application owns the user-scoped private API, configuration, signals and composition only. fleet uses that API even locally; SSH wraps the same private API remotely. crossfire coordinates leases, authorization, activity and receipts but never launches an agent. Native adapters encapsulate engine-specific protocols.

Knex alone creates and migrates databases. EF and Diesel own native application queries over the exact same schema. Generated entities, tables and precompiled queries remain inside the SQLite adapter. No native ORM creates a schema or silently migrates on startup. The shared one-shot migration container runs after writers stop; Compose gates runtime startup on its success. Backups are optional and operator-managed. Filesystem state has one current reader and writer per selected implementation. There are no historical conversion commands or alternate runtime readers.

Required target differences#

  • C# owns its EF design-time compiler projects; Rust uses generated Diesel table metadata and typed native query expressions. Neither creates imitation packages for a compiler mechanism it does not use.
  • Native targets own process and TOML libraries because those runtimes require them. Shared TypeScript validators remain tooling, not service implementations.
  • Rust domain orchestration uses Tokio concurrency and serde_json values as native primitives, equivalent to Promise/Task and native JSON values in the other targets. The graph names these dependencies explicitly; unknown external libraries and concrete Tokio/std filesystem, transport and process operations remain rejected. No facade hides such operations behind a purported pure port.
  • Each process adapter owns its native engine-group guard. C# observes an exact parent process handle and Rust a Linux parent pidfd. Rust also owns its pidfd-based readiness reactor. Guards are process-adapter executables, not another product, listener or service. They run only with an active engine, retain the exact private native-group lock and terminate the owned group if fleetd exits, including SIGKILL. No terminal scraping, history rewriting, global service or unsafe first-party Rust is introduced.
  • Runtime container images select the shared pinned IANA timezone data explicitly. Rust’s standalone server also retains that data in its distribution; standalone .NET products use their installed system timezone support. Browser assets, Element, Conduit and onboarding releases are shared build inputs, not separately maintained copies.
  • Managed and NativeAOT outputs use one C# implementation. Rust uses one ahead-of-time native implementation. None falls back to another backend.

Credential refresh copies only the selected model/provider configuration and login, never unrelated MCP servers, profiles or host permission overrides. Every native activation refreshes that login; removing host login removes the stale native copy. Corrupt/public/hard-linked/symlinked private state fails closed. Private HTTP/WebSocket transports explicitly avoid ambient proxies in every implementation. Structure checks and behavioral tests run separately. Matching directory layouts do not establish that the implementations behave alike.

Architecture and verification gates#

The file audit and per-file map cover every C# file, including manifests, internal tests, operator tools and framework-specific build inputs. The reproducible inventory checks explicit semantic owners without claiming that matching paths prove behavior.

scripts/verify-implementation-layout.mjs checks every product/application and 19 semantic package pairs, rejects superseded service-level source owners and keeps one UI and one common assertion bank. scripts/native-architecture.mjs checks the Cargo/.NET graphs, pure-domain boundaries, build/dev edges and application reach-through. Negative fixtures prove that violations are rejected.

npm run verify:parity -- /absolute/new-evidence-directory builds and exercises Managed C#, NativeAOT C# and Rust. The same installed-product assertions run against all selected products; native unit/adapter tests remain language-owned. Container, same-file SQLite and Knex migration tests run as additional checks.