Skip to content

fix(daemon): a registry entry that does not read is not written over with only its claims - #592

Merged
7schmiede merged 2 commits into
mainfrom
fix/570-registry-unreadable
Nov 19, 2026
Merged

7schmiede merged 2 commits into
mainfrom
fix/570-registry-unreadable

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

read_raw in crates/devstack-daemon/src/registry.rs took an entry that stayed cut off after its retries, or JSON that is no object, for no entry. change() then wrote back only what the caller sets: the daemon's claims (set_claims_in) or a shift (set_shift_in). The entry lost its id and name, dropped out of list(), and its port claims no longer counted against another stack's lanes (#535).

  • read_raw returns an error for such an entry (InvalidData when it reads and does not parse), and says it in the log once, the "no object" case too (the comment promised that, the code did not).
  • change() passes the error on. Only a registration (register, which a daemon's start and the hub's "add stack" do) names the whole stack and may write an unparsable entry anew, so a broken file heals at the next start instead of blocking the stack for good.

No review card: no trust, concept, contract or term changes; the registry's file format is unchanged.

Bug fix

Cause An unreadable entry was read as absent, and a write of some fields then replaced it.
Bug class unreadable-read-as-absent
Proof New unit test a_write_of_some_fields_keeps_an_entry_that_does_not_read, red before the fix at set_claims_in(...).is_err() (truncated entry), green after; daemon unit tests 230/230. Not reproduced in a running stack (found in a review; a truncated entry needs a broken file).
Siblings Searched the JSON state files that load with a default on a parse error (hub: shared, notify, nodehost, agenthooks, mcpscope, transcript; build snapshot manifest): each is written whole by one owner, so nothing survives in them that a partial write would drop. Left as they are.
Guard The test covers a truncated entry, a JSON array and non-JSON, for the claims and the shift write and for a registration.

Decided on my own

  • A registration may replace an entry that does not parse (it heals at the daemon's next start); a shift or claims write may not.
  • devstack up --shift on such an entry now fails with "could not keep the shift in the registry of stacks: …" instead of writing a shift-only entry.

Closes #570

🤖 Generated with Claude Code

7schmiede and others added 2 commits November 19, 2026 12:42
…with only its claims

`read_raw` turned an entry that stayed cut off after its retries, or JSON
that is no object, into "no entry"; `change()` then wrote back only the
fields it sets (`{claims}` from `set_claims_in`, the shift from
`set_shift_in`), so the entry lost its id and name, dropped out of
`list()`, and its port claims no longer counted against another stack's
lanes (#535).

`read_raw` now returns an error for such an entry (`InvalidData` when it
reads and does not parse) and says it in the log, the "no object" case
too. `change()` passes it on, except for a registration: it names the
whole stack (id, name, file, repository), as a daemon's start does, and
may write the entry anew.

Closes #570

Bug-Class: unreadable-read-as-absent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its claims

With the previous commit, an entry that stopped parsing while its daemon
ran stayed so: `follow_claims` failed every 5 s, logged
`claims_not_written` each time, and the claims stayed unseen by other
stacks until the next start. The daemon holds the whole entry, its shift
too: `set_claims` now takes it, registers it anew on `InvalidData`, puts
the shift back, and writes the claims.

Code review before 0.51.0, finding 5.

Bug-Class: unreadable-read-as-absent
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede

Copy link
Copy Markdown
Member Author

Code review before 0.51.0, finding 5: an entry that stops parsing while its daemon runs no longer stays so. set_claims takes the daemon's whole entry and registers it anew (with its shift) before the claims (b34b53e, test the_daemons_claims_write_an_entry_that_does_not_parse_anew, red before at the call's error).

@7schmiede
7schmiede merged commit e708ab9 into main Nov 19, 2026
14 checks passed
@7schmiede
7schmiede deleted the fix/570-registry-unreadable branch November 19, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The registry writes an entry without its id over one it read as truncated

1 participant