0016: Restructure Project for Two-line Development
Status
Accepted
Obsoletes ADR-0002: Use Single-Crate Project entirely — both its single-crate clause and its publication clause. Arose from the AI-First Development design, and records the part of it that reaches the repositories themselves: AIFIRST-05, AIFIRST-06, AIFIRST-11, AIFIRST-13, AIFIRST-14, AIFIRST-27, AIFIRST-28, AIFIRST-36, AIFIRST-38, AIFIRST-42 and AIFIRST-48. Amended in place for the architect's repository, flor-bounds. This record fixes the structure of the three repositories; how code is generated and checked around that structure — the generation environment and the CIs — is designed separately.
Context
ADR-0002 structured flor as one Cargo crate holding a library and every binary, and published that crate to crates.io. Both halves were reasoned for a single development line over a small codebase with no external consumer, and it said so: a workspace was discarded as "unnecessary complexity", and publication was justified by docs.rs, by community credibility, and by holding the name.
Both premises are gone.
The codebase acquires a real consumer, and it consumes one unit at a time. Florete is now built by two implementation lines over one spec. flor is the decision-driven line — human-designed, reviewed diff by diff; flor-dist is the spec-driven line — agent-generated, agent-reviewed, released and maintained. A unit is a crate whose public API is a contract kept apart from its body: by people, on the decision-driven line, or by the architect — the agent that keeps the contracts people delegate — on the spec-driven one. Either line supplies a crate satisfying that API as the unit's body. Substitution is the moment the product stops being built over the generated body of one unit and starts being built over the reviewed one. That requires a unit's body to be pinnable without dragging the rest of flor with it, and it requires the two bodies to be interchangeable inside one dependency graph.
The publication clause was never carried out, and what it promised has since been retracted. ADR-0002's own consequence already withdrew cargo install flor as a supported installation path, on the C0 Installer design. What was left standing — publish to hold the name and to render docs.rs — is a reservation with nothing nameable to put in it.
Decision
flor becomes a Cargo workspace holding a crate for every unit whose contract people keep. One crate per such unit, whether or not the reviewed line has implemented its body yet: a crate whose functions are unimplemented still yields a complete public API, which is what a contract has to be before either line builds against it. A contract or a body in flor depends on contracts people keep alone, so nothing in flor refers to another repository. Which code is a unit, which is an SD crate — code several consumers share, each part of its API used by one of them, kept in flor-dist with its API no contract — and which is ordinary code bound only by the spec, the contracts it calls and the suite, is recorded per milestone in that milestone's decomposition.mdx rather than here.
flor-bounds holds the contracts the architect keeps, with their tests. Every SD contract is there — only an internal contract, one whose every party is inside the build, can be SD, of any kind, an API among them — each API as a crate whose functions are unimplemented. The architect alone writes it, and tags a contract at every change. It is a separate repository sharing no history with the others.
flor-dist holds the generated bodies and the integration, and it assembles and packages every executable. It is a separate repository sharing no history with the others. The suite belongs to neither body: it is every test of ours, append-only, each owned with the contract it tests — a unit's API tests beside its contract, in flor or in flor-bounds, and in flor the edge tests over the product's edge and the golden fixtures, which generation reads as part of the spec. A unit's contract is its crate in whichever of the two repositories its keeper writes, and its interface is taken from a pinned revision wherever it is needed.
The assembly is flor-dist's root manifest, and every dependency of the product is declared there. It selects bodies alone. Each unit is declared once in its [workspace.dependencies], by the source of the body the product takes — its local crate while the body is generated, the flor source at the tag it is pinned to once the body is reviewed — and so is every third-party crate, with its version requirement. Generated crates refer to units and third-party crates by name only — never by a source or a version of their own. A dependency declared inside a reviewed crate names flor's own crate for the unit, so where that unit's body is generated, a [patch] entry over the flor source redirects it to the local crate; the redirection applies to the whole graph. Substitution and reverse substitution are each an edit to the root alone — the unit's source, and its [patch] entry where one exists — and the root is a standing inventory of which bodies are generated now. Contracts take no part in the assembly: CI checks each body against its contract, by the public-API diff against the contract's pinned revision and by the contract's tests.
Each unit resolves to exactly one package in the graph of every executable, in every build configuration — enforced mechanically rather than trusted. Pins therefore stay per unit: units that depend on one another are forced to a common revision by the check, and units that do not are left independent.
Binaries belong to flor-dist because they are integration, not because a unit may not be one. Where a binary's own logic has to be reviewed it becomes a unit like any other, with its crate in flor. A workspace build produces its own bin targets and not a dependency's, so such a unit reaches the product through a one-line main in flor-dist over its entry point — assembly rather than implementation, and human-owned like the manifest around it. What differs from a library unit is where its contract lies: in the command line it owns, stated in the guide and held by golden fixtures and the suite, rather than in an API a public-API diff holds.
Generation codes against a unit's interface, never against its body. A build of flor-dist checks out the whole trees of flor and flor-bounds, so bodies and tests are within the generating agent's reach, and the boundary is held by instruction rather than by keeping them out: behaviour generated code relies on that a contract does not state is filed as a finding. That holds for every unit, substituted ones included — they are what generated code calls, and so where coding against observed behaviour would do its damage. A contract may still be tagged before its body exists, so the generated line builds against a frozen API while flor fills it in; only the assembly move waits for a working implementation. The suite is in reach the same way and held the same way: generation reads its golden fixtures and not the rest, and records any read of the rest with its reason, as a finding.
Each repository has its own CI, and no pipeline runs backwards. flor's CI covers what flor can build alone, a DD contract's API tests among it, run against DD's bodies. flor-dist's CI runs the whole suite over pinned revisions of flor and flor-bounds, against whichever body the assembly selects — only flor-dist builds the product. Hosting is not building: nothing in the build of flor or flor-bounds depends on flor-dist.
In flor-dist, what decides, judges or packages is human-owned. The root manifest that carries the assembly and every dependency, the CI configuration, and the release and packaging plumbing are written and reviewed by humans, however much of the code around them is generated. A gate the generated line can rewrite judges nothing, and a suite owned by humans is worth nothing if its executor is not.
Third-party dependencies are approved by humans, through the same mechanism as units. Declaring one is an edit to the root manifest, so a generated crate that needs a crate not yet declared proposes it as a finding, and a human declares it. A reviewed crate's own third-party dependencies are declared in flor and reviewed with the diff that adds them. Versions move within the declared requirements; the lockfile records them and is not reviewed. What judges the resolved graph beyond that belongs to the CI's design.
A contract moves between flor and flor-bounds by a sequence of its own. The receiving keeper takes it into its repository and tags it, its tests going with it — people reviewing it when it comes to them; whatever reads the contract takes it from there; the old copy is deleted last. A body moves to DD only under a contract people keep, so a unit whose contract is the architect's moves its contract first.
Nothing is published to crates.io. Not the unit crates, not the product, and no reservation crate. No registry name is held, and cargo install flor is not a supported path.
Rationale
We considered five structures for the code:
-
Keep the single crate and export a curated
pubsurface from it.
Discarded because pinning that crate drags the entire implementation intoflor-dist, which is exactly what substituting one unit at a time must avoid, and it couples every unit's version to every other's. -
One repository per unit.
Discarded because a workspace already tags and versions its members separately, so this multiplies repositories, CI configurations and issue trackers for nothing the workspace does not give. -
Two long-lived branches, or two directories, in one repository.
Discarded on the review regimes rather than on taste. The decision-driven line requires a person's review of every diff, and the spec-driven line is reviewed by agents alone, no person reading its code, so one repository means one CI, one CODEOWNERS and one set of branch protections covering opposite rules — every change needs classifying, and a misclassification is silent. Separately, generated history is regeneration-shaped: wholesale per-unit rewrites in the same log would degradegit log, blame and bisect for the careful history that depends on them. A merge between the two lines is not a merge in any case — once the agent has restructured anything, it either conflicts on nearly every file or succeeds textually while breaking semantically. -
Two repositories, the architect's contracts in one of them.
Discarded because inflorevery change to them would wait on a person's review, and inflor-dista body's author and its contract's keeper would share a repository, kept apart only by a guard inside it. Write access is granted per repository, so an agent's identity can be narrowed to one, while a path inside a public repository has no restriction short of review. -
Per-unit crates in
florfor the contracts people keep and inflor-boundsfor the architect's, withflor-distassembling the graph and packaging the product — as chosen.
Accepted because it is the smallest structure in which substitution is an edit in one place, the boundaries between the lines and between the keepers are mechanical rather than disciplinary, and nothing a generated body is held to — its contract, the suite, the reviewed bodies it calls — is written where that body is.
A crate boundary is also the only boundary that holds here. pub(crate) is visible throughout its crate, so a module boundary is advisory; in a codebase where one line is never read by a human, an advisory boundary erodes without anyone noticing. A crate boundary is checked by the compiler.
Why the assembly is a place rather than a rule. A unit names a contract, not an implementation, so which line satisfies it is not a property of the depending code and must not be written into it. Putting that decision in one manifest is what makes substitution reversible by the same edit that performed it, what lets a reviewed unit sit above generated ones instead of dragging reviewed implementations down its whole subtree, and what gives the DD-authored share a place to be read off rather than counted by hand.
Why every dependency is declared at the root. A dependency declared inside a generated crate would let that crate choose its own supplier: a path to a generated implementation, written into its manifest, routes around a substitution from a file no human reads. Declaring units and third-party crates alike in the human-owned manifest closes that, and it keeps one mechanism for both — choosing a third-party crate is a judgement about whom to trust, of the same kind as choosing which line supplies a unit, so it is made in the same place by the same people. Reviewing the lockfile instead was rejected: it would put a human on every version bump, reintroducing review on the generated line through the back door.
Why the graph invariant is enforced. Nothing about the assembly is safe by construction. Cargo will resolve two revisions of one unit without complaint; the compiler objects only where a type crosses between the copies, and where none does, the product runs with two of the unit and two of whatever state it holds. The invariant is the cheap mechanical answer, and it lets pins stay per unit — the alternative, pinning flor wholesale, imposes the constraint the dependency graph does not, and is paid for by dragging every unit's unreleased work along with each bump. It is stated over each executable's graph rather than over the lockfile, because a lockfile lists every workspace member whether or not anything links it — including a generated implementation kept after its substitution until it is deleted last.
Mechanisms verified before recording, in throwaway workspaces rather than argued from the documentation:
- a git dependency resolves a crate inside a workspace in another repository by package name alone, with no subdirectory path. Substitution needs no registry.
- a
[patch]entry over theflorgit source redirects a unit to a generated crate inflor-distacross the whole graph — whether the unit is declared among the root's workspace dependencies and inherited by name, or declared inside a reviewed crate as a plain path dependency internal toflor's own workspace. The executable's graph then holds one package for that unit and types unify across the seam; removing the entry substitutes the reviewed crate everywhere at once. - different units resolve at different tags of the same git source, so per-unit pinning is available.
- two revisions of one unit also resolve, silently: the build succeeds and the program runs with both copies unless a type crosses between them.
cargo tree -dreports that duplicate at identical package versions, discriminating by source, and names which dependent pulled each side — so the invariant is both checkable and diagnosable.- after a substitution, the lockfile still carries the generated implementation as a workspace member beside the reviewed crate that replaced it, while the executable's graph holds only the reviewed one — which is why the invariant is stated per executable.
- a workspace build produces its own bin targets and not those of a git dependency, which is why a binary-shaped unit reaches the product through a
maininflor-distrather than directly. - a git dependency checks out the whole repository tree at each pinned revision, directories outside any crate included — which is why bodies and the suite are within a generating agent's reach whenever it builds
flor-dist. - a crate of conformance tests held in
florand written against a unit's API, run fromflor-dist— bycargo test -pon that crate, or through a harness calling it — exercises the body the assembly selects, with one package for the unit in the graph. A test crate with dev-dependencies of its own cannot be tested as a non-member, which leaves the harness as the general route.
Not verified: the same routes over a second git source. An SD contract's tests are written in flor-bounds against the contract's own crate, so to exercise the generated body from flor-dist they need a [patch] over the flor-bounds source beside the one over flor; no throwaway workspace has tried it.
On publication, we considered reservation crates holding flor and florete, publishing the product crate to occupy the name, publishing the unit crates as ADR-0002 intended, and publishing nothing. We publish nothing.
The reservation question reduces to naming a use, and there is none: not the installer, which retracted cargo install flor; not the unit crates, which are internal APIs for building our own software and would become an accidental SDK that the real one later has to compete with and disambiguate; not the generated product, which serves no user through a registry and would put agent-generated code there under an implied promise. What is left is a third-party SDK that does not exist and would plausibly be named for what it is. Holding two names for years behind placeholder READMEs is squatting, which the registry's policy disfavours and which we would have to keep explaining, in a project whose public argument is about doing things properly.
What ADR-0002 wanted from publication is either not bought by publishing units or cheaply had elsewhere: credibility comes from every repository being public, and cargo doc renders the same API. Its surviving benefit — that other Florete repositories can depend on the library — is precisely what now happens, at unit granularity and by tag rather than by version.
Consequences
Benefits:
- A unit's reviewed body can be pinned on its own, and substitution is an edit to the root alone, reversible by the same edit until the generated body is deleted.
- Crate boundaries are compiler-enforced, which is the only enforcement available on a line nobody reads.
- Both implementations of a unit keep one package name, so no substitution needs a rename or an adapter.
- A reviewed unit may sit anywhere in the graph, above generated units as well as beneath them, so what gets reviewed is decided by consequence rather than by depth.
- Every dependency of the product, internal or third-party, is decided in one human-owned file.
- Each review regime and each keeper gets a repository of its own — people's contracts and reviewed bodies, the architect's contracts, generated bodies — with its own CI and protections, instead of one of each covering contradictory rules; and no body's author can write the contract it is held to.
Trade-offs:
- The versioning overhead ADR-0002 was written to avoid, now paid for a reason it did not anticipate.
- The spec and the suite span the repositories, so a suite change and the generated-line change it accompanies are two pull requests in two repositories — friction on exactly the path that must not be skipped, and an author on a
florbranch needs a product build fromflor-distto watch a new test fail against SD's body or at the product's edge. An SD contract and its body sit in different repositories as well, so an API's churn crosses two. - Tags accumulate without rhythm, so the tag list is not a changelog and something else has to be.
- A duplicated unit is diagnosed rather than prevented; without the check it reaches a release silently.
- A generation that needs a new third-party crate waits for a human to declare it. That is accepted: it is the one supply-chain choice that needs a judgement.
- A version bump within a declared requirement is reviewed by nothing, so a compromised release of a crate already declared passes until something outside review catches it.
- The generation boundary is held by instruction and audited after the fact, not prevented. A reliance nobody reports couples generated code to a reviewed body until a refactor breaks it, and what catches the break then is the suite. The suite's hidden part sits in the same tree and is held the same way, a read recorded with its reason (AIFIRST-28); A0 is where both are measured.
- docs.rs, discoverability and the small credibility of a published crate are forgone. Someone else may take
flororflorete, and an SDK later wanting that exact name will need another one. That is a bounded, nameable cost. Revisit when a third-party SDK is actually designed.
One release version still identifies the whole installed set, by another mechanism. ADR-0002's single crate is what made flor, flor-vertex, flor-coordinator and rete carry one number, and the Installer and Coordinator designs rest on that property rather than on the crate. It survives relocated: every executable is built and released together from flor-dist at the product release version, which is what a host reports and what a release note names. Unit crate versions stay in 0.x and are an implementation detail of how that build is assembled — the outcome the installer design already anticipated when it wrote that should packaging ever split the crate, the release version remains the user-facing identity.