Result::expect_err requires the Ok variant to implement Debug for its
panic message. ControlSnapshot intentionally does not derive Debug;
match on the Result instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Per R19 item 1: control.cc reads keep the byte-exact canonical check;
history.cc stays lenient. The literal e8d8747-era check (decoded value
re-encodes to exactly the stored bytes) can't be restored unmodified,
though: cultcache-rs-derive's DatabaseEntry::serialize always emits
every slot up to the type's current maximum key, so a record written
before a field existed (the additive-slot tolerance this same cut
added, see additive_slot_does_not_break_stored_records) can never
re-encode to its own stored length, let alone match it byte-for-byte.
That is schema growth, not tampering.
decode_record_canonical reads the stored msgpack array's slot count
via msgpack_array_len and only requires a byte-exact match when it
equals the current schema's slot count. A shorter (genuinely older)
record is exempted from the byte match (decode-time tolerance already
governs whether it is accepted at all); a full-arity record must be
exactly what Idunn's own serializer would have written, which is what
makes Soul's claim 1 attack -- re-encoding an existing field with a
wider msgpack integer width, same value, more bytes, same slot count
-- visible again.
read_transaction_record takes a `canonical` flag so the one function
serving both stores can enforce it for control.cc and skip it for
history.cc. Soul's test is flipped to
soul_live_record_in_foreign_encoding_is_refused_by_control_read.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
plan_id is a content digest, not a signature: a stored plan's
binding_blob can be edited after freeze (here, widening
allowed_programs from ["cargo"] to ["sh"]) and recomputing plan_id
produces a self-consistent, validate()-passing record. admit() was the
only check that ever refused that pair, and removing it let an edited
binding reach the phase engine with no admission at all.
Per R19 item 3: this is the recipe/binding admission boundary, not the
terminal-history coupling R4/R11/R12 cut -- re-admitting a resident
plan on every read (restart included) is what lets Idunn run as root at
all. Soul's test is flipped to assert refusal on both validate() and
parsed_inputs(): soul_stored_plan_with_inadmissible_binding_is_refused_on_every_read.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
replace_transaction archives a transaction to history.cc the instant it
turns terminal instead of writing the terminal value back to control.cc.
resume_one_transaction's post-advance progress check treated the
resulting absence from control.cc as "transaction disappeared", a fatal
error that serve's `?` propagated -- so every ordinary completion ended
the daemon process once under Restart=always, strictly worse than the
incident this cut exists to fix.
Soul's test is flipped to assert success: soul_terminal_completion_inside_resume_is_ordinary_progress.
Per Soul falsification claim 3 / R19 item 4.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Four tests, no source changes:
- soul_live_record_in_foreign_encoding_is_accepted_by_control_read
- soul_stored_plan_with_inadmissible_binding_passes_every_read_check
- soul_terminal_completion_inside_resume_returns_an_error_serve_propagates
- soul_real_crash_window_leaves_a_live_record_that_the_archive_filter_cannot_see
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
additive_slot_does_not_break_stored_records: encodes a DeploymentTransaction
the way a binary predating post_fencing_abort (key 34) would have -- a
34-element tuple instead of 35 -- and asserts ControlSnapshot::read accepts
it. This is the exact shape that made e8d8747 necessary; the read path now
tolerates it without a schema lift.
terminal_write_archives_in_the_same_primitive_and_moves_its_command: drives
replace_transaction to a terminal write and asserts the transaction (and,
being the command's only transaction, the command too) leaves control.cc
and lands in history.cc with identical semantic content.
archive_resume_completes_a_crash_between_append_and_delete: fixtures the
half-finished state (history already has the record, control.cc still
does too) and asserts one more call finishes the delete without
duplicating the history entry.
read_history_for_command_is_lenient_about_unreadable_records: a corrupted
transaction payload and a foreign-schema transaction in history.cc are
both reported as unreadable without blocking the read of the command
actually asked about.
98 pre-existing tests plus these 4 pass: 102 passed; 0 failed.
Once replace_transaction archives a terminal transaction, submit's
--wait loop and status can no longer find its command in control.cc.
Both now fall back to a lenient scan of history.cc when the command is
absent from the live snapshot: read_history_for_command decodes what it
can and reports anything it cannot as an UnreadableHistoryRecord rather
than failing the whole read, because a corrupted or foreign archived
record is display-only and must never block an operator from seeing
the outcome of everything that did archive cleanly.
decode_record, read_transaction_record and ControlSnapshot's strict
path now name type, key and schema_id in their error context, which is
what a crashloop's journald line needs to be diagnosable.
Unfiltered `status` (no command id) still lists live commands only;
history is consulted only for a named command that is no longer live.
Widening the unfiltered listing to walk all of history.cc as well is
left for a follow-up if an operator asks for it.
replace_transaction is already the one commit primitive every phase
transition, same-phase persist, and abort completion funnels through.
When next.is_terminal() it now appends the record (and, if it was the
last resident transaction of its command, the command too) to a new
sibling store history.cc and deletes it from control.cc, instead of
writing it back in place. The append and the delete are each their own
CAS (insert_entry_if_absent / delete_batch_if_unchanged), so a crash
between them leaves the record resident-but-archived, which is not a
fault: resume_one_transaction now routes any transaction already
terminal in control.cc through the same primitive before scheduling
anything else, and the append is a no-op the second time.
No new store, flag, or unit-file change: history_store_path derives
history.cc from the existing state-store path (sibling file, same
directory).
Per R11 (rulings-wave-1.md): archive rather than delete-with-no-record,
so idunn status/up --wait keep an observable outcome after a
transaction leaves the live set. The lenient reader for those two CLI
paths, and the tests, are the next commits in this pass.
Remove validate_durable_authority, the v2->v3 transaction schema lift
(migrate_transactions_to_current_schema, the v2 branch of
read_transaction_record, DEPLOYMENT_TRANSACTION_SCHEMA_V2), the
byte-exact re-encode check in decode_record, and the read-time
binding.admit() re-admission in DeploymentPlan::parsed_inputs.
Verified on the live host: zero v2 envelopes exist anywhere, 511 v3,
and the only store any live unit names is
/var/lib/gamecult/idunn/control.cc, so the v2 lift added in e8d8747 is
now dead weight rather than a compatibility path. Byte-exactness only
ever caught e8d8747 itself and protects nothing else: control.cc is
unsigned and written only by Idunn under flock. Read-time admission was
a second admission authority racing freeze-time compile_deployment_plan.
Per rulings R4/R11/R12 (rulings-wave-1.md): this is deletion-only, no
replacement added yet. decode_record now names the offending record in
its error context instead of asserting canonical re-encode.
Odin's stored correlation outlives the incarnation that wrote it, so a target
being replaced -- Odin above all, which writes its own -- routinely finds one
describing the Expected it is superseding. Idunn treated that as a
contradiction and failed the deployment, and only the superseded process could
have refreshed it, so the deployment that would have fixed the target was the
one thing the stale record prevented.
It is now read as absence. That says nothing about trust: the record is
unauthenticated at that point and is used only to decide it is about something
else, which is the same conclusion an attacker gets for free by publishing
nothing. Everything after it is fully authenticated.
Two more copies of the same "first bootstrap" assumption are aligned with the
rule that replaced it. Whether Odin may be observed directly is decided once,
where the question is whether any Odin can report; the presence authentication
and the warming refresh were re-deciding it with the narrower "has an Odin ever
been admitted" test and contradicting that caller.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Continuity restarts a release; it cannot repair one. When the admitted release
will not start, rescheduling it forever keeps the target permanently occupied
-- and a target with a live transaction accepts no deployment, so the one
action that could fix it is exactly the one that is locked out. Odin sat in
that state through 196 restarts.
It now stops after three attempts and says so, leaving the target free. The
count is kept against the admitted generation id, so a restart that succeeds
admits a new generation and starts the count over rather than carrying old
failures forward.
The yield to continuity is conditioned on the same count. Handing a deployment
back to a continuity that has already given up is not caution, it is closing
the last door: there is nothing left to yield to.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Warming presence reaches Idunn as Odin's signed topology correlation, with one
exception for Odin's own first bootstrap. That exception was scoped too
narrowly: it asked whether an Odin had ever been admitted, when the question
that matters is whether an Odin can currently report.
A continuity restart of Odin cannot be observed through Odin -- the incumbent
that would do the observing is the process being restarted. Neither can a
deployment made while the admitted Odin has no usable correlation. Both sat
waiting for evidence that could not arrive, and continuity restarted the
target into that wait every few seconds.
The rule is now the one that justified the bootstrap case in the first place:
direct observation exactly when "observed through Odin" is unavailable, and
only ever for this one target. Every other target still waits for Odin, which
is what makes Odin the root of the chain.
Also adds the projection-presence check continuity uses to tell a projection
that still describes a dead incarnation from one already demoted.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Continuity's projection repair required a fresh workload observation, so it
could only run while the target was healthy. But a demoted projection is one
of the reasons a target stops being healthy: aborting a deployment restores
the incumbent's Expected without its activation, and a target that cannot see
its own activation cannot publish presence, so it exits -- and no observation
is ever available to authorise the repair. Odin crashlooped exactly this way
after a failed redeploy, with continuity restarting it into the same wall
every few seconds and no path out.
Nothing in the repair is inferred from the live process. Expected, activation
and lease all come from the admitted generation, and the workload observation
used is the one Idunn recorded when it admitted them, so this republishes what
Idunn already decided rather than ratifying whatever happens to be running.
It now runs before anything is asked of the workload.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Idunn refuses an Odin publisher sequence at or below the highest it has seen
for a target, which is what stops an old signed correlation being replayed.
The watermark counted every transaction, including ones that failed.
A failed transaction was never built upon: the deployment was abandoned and
its projection withdrawn. Carrying its readings forward only raises the bar
for the next attempt, and with Odin restarting a withdrawn correlation's count
that made a target which had failed once into a target that could never deploy
again. Odin does not reuse a sequence, so forgetting the readings of an
attempt that came to nothing weakens nothing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CultCache opens the `.lock` sibling whenever it opens a store, so a 0640 lock
denies a workload's read exactly as a 0640 store does -- and the lock is
created fresh under Idunn's UMask=027 on every publish, so setting the store's
mode alone was not enough. Odin's candidate got past the write lease and then
died on the projection for this reason.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adding `post_fencing_abort` was a schema change, not a new optional field.
The control store refuses noncanonical bytes -- a record must re-encode to
exactly what is stored, which is what makes tampering visible -- so every
transaction written before the field existed re-encodes with one extra key and
reads as tampered. Deploying the previous commit took the daemon down in a
crashloop on its own control store; it was rolled back within minutes.
A v2 record is now decoded by key, which tolerates the absent one, and lifted
with no post-fencing abort, because a transaction written before the field
existed cannot have had one. Byte-exactness cannot apply across a version
boundary -- the bytes are a different schema by definition -- so the lift
leans on the full semantic validate() instead, and everything downstream sees
only the current shape. A startup pass then rewrites stale records as v3 by
compare-exchange, so the store converges rather than keeping two shapes for as
long as retention holds the oldest terminal transaction.
Verified against the live control store rather than a fixture: 41 real v2
records migrated on start, and the post-fence abort then released a
transaction that had been wedged in Leasing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A transaction past Fencing had no terminal path. begin_pre_fencing_abort is
gated on phase < Fencing, so every later error went to record_resumable_error
and retried forever. That is right while a candidate can still recover, and a
trap once it cannot: Idunn launches candidates as transient units with
Restart=no, so a failed one never comes back, and the transaction holds its
target with every later command queued behind it. There was no operator verb
to clear one and no server-side expiry.
So a candidate that is permanently stopped -- unit failed, or gone from
systemd entirely -- now aborts. The withdrawal runs in the one order that
never leaves two writers: route, then write lease, then the process, then the
projection. Reconciling the projection restores the incumbent's admitted
Expected where there is one, which is what lets continuity bring the incumbent
back after fencing stopped it; where there is none, the failed Expected is
withdrawn.
The transaction is released only once every one of those is durably complete,
which is what the cleanup evidence is for.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The reachability check only accepted o+x, but the other correct shape for a
runtime root is 0750 group-owned by the state group -- and that is the shape
the write-lease hardening already assumes, since it derives the record's group
from this directory. Checking only o+x would have refused the configuration
that makes the lease readable.
The workload's uid is allocated by DynamicUser and owns nothing, so traversal
can only come from the state group or from other. Both are now accepted, and
a directory group-owned by some *other* group still is not.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The first deployment of any routed target could never succeed, and wedged
itself permanently on the way down.
The route preflight bind-mounts its candidate over config_path to run
`nginx -t` in a private mount namespace. When that path does not exist yet,
systemd materializes the mount point and leaves an empty file on the host.
Read as content, that made the baseline "change" during validation, failing
the transaction -- and every retry then saw a zero-length fragment where the
transaction expected none and reported an unadmitted incumbent, which no
amount of retrying could clear.
A fragment with no bytes grants no route, so it is now read as absence. That
makes the preflight idempotent whether or not systemd materialized the mount
point, and lets a first deployment retry cleanly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The topology store is Idunn's published surface -- every managed target reads
it to verify its own Expected incarnation against the Idunn anchor -- but
Idunn runs with UMask=027, so each publish left it 0640 root:root and a
DynamicUser workload got EACCES. Odin's candidate died on exactly that.
Fixing the mode by hand does not hold, because every publish writes a new
file. Integrity here comes from the signatures over the records, not from the
mode, so the published copy is now explicitly readable after each write.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CultLib's backing store reports an unreadable file as an empty store, so a
workload that cannot traverse to its runtime bundle sees zero records rather
than a permission error. Odin reported "runtime authority store must contain
exactly one record" and Heimdall simply concluded it held no write lease and
warmed forever. Neither names the actual fault, and both cost real time.
The cause is that `ReadOnlyPaths=` binds the leaf into the unit's namespace
but grants no traversal above it, so a runtime root under a 0700 parent is
unreachable to a DynamicUser. Idunn now checks the whole chain when it writes
the bundle and says exactly which directory is closed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A target whose tests enrol a service identity could not be built at all.
CultLib's Linux protector binds the seed to /etc/machine-id, the build image
carries none, and the runner is --read-only, so Odin's suite failed every
step with "Linux machine-id is unavailable".
Mounting the host's machine-id would let a build container protect a seed
that unwraps on the host, which is exactly the property the binding exists to
deny. So each frozen workspace now gets its own identity, derived from the
workspace path and mounted read-only: stable for the life of a build, and
useless anywhere else including this host.
Also moves Idunn's topology store to /var/lib/gamecult/idunn-projection. It
is Idunn's published surface -- every managed target must read it to verify
its own Expected incarnation -- and it was sitting inside Idunn's private
0750 root where no workload could traverse to it. Odin's own daemon already
named that directory in its tests.
Odin's three roots become writable for the same reason Heimdall's are: a
target Idunn cannot write is a target it cannot deploy.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A routed RUDP target was admissible but unprojectable. `admit` has an
explicit arm for (route_required, Rudp, nginx-stream-udp) against an
`rudp://` stable endpoint, and the nginx driver already writes
`listen ... udp reuseport` for it -- but `endpoint_scheme` lumped Rudp in
with Private and refused to name a scheme, so `expected_projection` bailed
before any routed RUDP candidate could be described.
Odin is the only routed RUDP target and it is the bootstrap target: nothing
else in the estate can warm until Odin is admitted, and Odin could not be.
Private keeps bailing, which is correct -- `route_required` is false for it,
so a private target never reaches this function.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Deploying Heimdall proved the migration order backwards. A candidate's
warming presence -- the evidence Idunn requires before fencing an incumbent
-- is observed through Odin's authenticated runtime topology correlation.
advance_warming has exactly one exception: target == "odin" while no Odin
is admitted may warm on directly observed presence. Every other target
waits for Odin to publish.
So with the previous generation's Odin still running, a Heimdall candidate
starts, serves on its assigned bind, publishes health, and warms forever.
It never fails and never promotes. That is not a defect; it is the
observation chain being rooted somewhere I had not looked. It also explains
why Odin has the only recipe in the estate that was ever kept current.
The document said "migrate the authority's own dependencies last". Odin is
not a dependency to defer, it is the root, and the entry now says so.
The wait also recorded no reason, so a candidate could sit in Warming
indefinitely with nothing to read -- the fourth coarse-signal case today.
It now records what it is waiting for and why the wait cannot resolve
without Odin.
Noted alongside: health published over RUDP to the previous generation's
--rudp-health-bind goes nowhere, since the current serve has no such flag.
That produces a steady stream of timeouts in the candidate's journal and is
not the reason promotion stalls.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The launch-contract assertion carried the same empty-User clause I removed
from observe_unit an hour ago -- a second copy in a second checker, failing
for the same reason: systemd reports the identity it allocated for a
DynamicUser unit, so User is never empty for a running workload.
It also bundled thirty conditions behind one message. "The launch contract
differs from the admitted launch" leaves an operator bisecting by hand
against a workload that has already exited, and that is exactly how the
last two rounds went. Each clause now carries a name and the failure says
which one.
That is the third time today a check knew precisely what was wrong and
reported something too coarse to act on: the sealing gate recorded a brake
reason status never printed, the isolation contract hid one property among
twenty-one, and this hid one among thirty. A control plane that cannot say
which invariant it is enforcing costs more than the invariant is worth.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The credential check required the delivered file to be owned by the
workload's uid and gid with mode exactly 0400. systemd does not deliver
credentials that way and never has: it writes them root:root, closed to
group and world, and grants the workload's dynamic uid read access through
a POSIX ACL. Observed directly on systemd 257 rather than inferred:
-r--r-----+ 1 0 0
user::r-- user:64459:r-- group::--- mask::r-- other::---
64459 was the running workload's uid, so the invariant the check wanted --
readable only by the workload identity -- holds exactly. It just holds
through an ACL rather than through ownership, so the assertion failed for
every credential Idunn has ever delivered.
Now asserts what the file mode can actually carry: root-owned, unaliased,
no group or world access. The workload-only grant is the ACL's, which is
systemd's to enforce rather than ours to re-derive; saying so plainly in
the comment beats an assertion that looks strict and cannot pass.
Second unsatisfiable contract in this observer today, after the empty-User
assertion. Both asserted a shape systemd does not produce, and both failed
after every other property matched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The workload isolation contract required `User` to be empty. systemd
populates that property with the identity it allocates for a DynamicUser
unit -- the unit name, or a generated `_du…` when the unit name is too long
-- so it is never empty for a running workload. Every workload Idunn starts
failed the check it had just satisfied in every other respect, reported as
"systemd workload isolation properties differ from the Idunn contract"
with no indication of which property differed.
Confirmed against systemd directly rather than reasoned about: a transient
unit with DynamicUser=yes and nothing else reports
User=idunn-user-probe-2869674. All twenty other asserted properties matched
exactly.
The clause could not have distinguished an allocated identity from a pinned
one anyway, since both surface the same way. The invariant it reached for --
the workload does not run as a persistent named account -- is carried by
`dynamic_user` and by Idunn never emitting a User property at all. The
observed value is still recorded, as evidence of which identity ran.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The migration procedure told operators to dry-run a target, and no dry-run
existed. `up` needs a running daemon and a state store, so the only way to
find out whether a binding was well-formed was to install it and see
whether `serve` refused to start -- on the host, with the authority down.
`idunn validate --recipe PATH [--binding PATH]` runs the same
TargetDeclaration::parse and OperatorBinding::admit the daemon runs at
load. It opens no store, contacts no host, and actuates nothing.
Owner: the existing control-plane CLI, no new module or target. Consumer:
whoever authors a binding, starting with this migration. Invariant: a
binding installed on the host admits against its target's recipe. It
replaces the install-and-see loop rather than adding a layer.
Verified against the real estate: Odin, CodexConnector and Ghostlight
recipes all parse. Negative paths checked too, because a validator that
only ever passes is worse than none -- an unknown recipe field (the
privilege-escalation shape), a missing --recipe, and an unreadable file
all fail with the reason.
A test asserts validate stays declarative and refuses --deploy-command,
matching the guarantee cli_exposes_only_declarative_commands makes for the
rest of the surface. 64 passed / 18 failed, against a 63/18 baseline: one
added pass, no new failures, and the 18 remain the known Windows
absolute-path cases. cargo check for x86_64-unknown-linux-gnu is clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
IdunnDaemonHealthTrustBindingRecord and its schema constant moved to
cultnet-rs (GameCult/CultLib@c13b6ba). odin-core now imports them from
cultnet_rs instead of defining them, and idunn-daemon/provisioning.rs
pulls all six provider-health symbols from cultnet_rs directly, merged
into its existing cultnet_rs use block. Dropped the odin-core path
dependency from idunn-daemon/Cargo.toml — nothing in the crate reaches
odin_core:: anymore. Bumped the CultLib git rev across all six
consuming manifests to the new commit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This had been sitting uncommitted in the worktree. It is real work rather than
stray edits: RouteBinding gains stable_socket and an NginxStreamUdp driver so a
route can be actuated over UDP, control_plane and drivers grow the Idunn-owned
projection and bounded RUDP transport, and crates/odin-daemon arrives as a new
member of the workspace.
The deployment recipe comes with it, including the required_gitlinks fix the
core-stack repoint made necessary: it named vendor/cultnet-rs, which no longer
exists now that CultNet comes from CultLib, so Idunn would have refused to admit
the target. The list is empty because Odin has no submodules left; the core
stack is pinned by revision in Cargo.lock inside the frozen source tree.
Everything except odin-daemon builds here. odin-daemon reads systemd listen
file descriptors through std::os::fd and cannot compile on Windows by design, so
Linux CI is its first real witness. muninn and sleipnir pass 162 tests; the one
failure expects an Unreliable media channel that no CultNet lineage has ever
declared, and predates this.
Committed rather than left in flight. rustfmt reports 94 files across the repo,
which predates this work, so formatting is left for its own pass instead of
being buried in a 4,000-line diff.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>