Skip to content

cluster: approval check follow-ups (lock race, older follower, own log lines, converge on none) - #1666

Merged
davidtai merged 8 commits into
devfrom
cluster/approval-followups
Oct 29, 2026
Merged

davidtai merged 8 commits into
devfrom
cluster/approval-followups

Conversation

@davidtai

@davidtai davidtai commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to PR 1661 (merged into dev at 45f0c22). It fixes the medium and low findings of the second delta review of the cluster approval check. No change to the provider protocol or the coordinator API. Each fix is one signed commit with a row.

  1. Lock race and review finding 3 (5f4f464). The leader's approval check now decides again under the command lock, from the setup, record and the other Mac's status as they are then, with the same coordinator answer (asked at most once per check). ClusterApprovalSync.apply checks a save against the leader's own files and pairing before any part stops. A busy command lock waits for the next check, a minute later, instead of retrying at every tick.
  2. An older follower build (3306097). Each Mac reports approvalID always ("" for none). A status without the field (an older build), or no answer, is unknown: the leader does not compare it and does not converge.
  3. The ended part's own log lines (214c04f). The service records the rank-log offset where each part begins writing, and reads that part's last error line only from there. An earlier part's "coordinator could not be reached" line can no longer hide a quick end.
  4. converge(nil) (596fe33). When the leader holds a cluster approval it does not offer (it ended, or the cluster serves locally only), converging on none also saves the leader's setup without it. The log line is then true and the next check finds no difference.
  5. CI (8c638a5). The model-free onboarding checks (provider-swift/Tests/ClusterOnboardingChecks/run.sh, with leaderWaitsForThePartsAfterTheRegistration from PR 1661) now run as a step of the Cluster Metadata Checks job.

Before / After

flowchart LR
  subgraph Before
    A1[check: read setup, record, follower status] --> S1[step]
    S1 --> L1{command lock}
    L1 -->|busy| R1[retry next tick]
    L1 -->|held| X1[stop parts, then check, then change]
  end
  subgraph After
    A2[check: read setup, record, follower status] --> S2[step]
    S2 --> L2{command lock}
    L2 -->|busy| R2[retry at the next check, a minute later]
    L2 -->|held| D2[read again, decide again]
    D2 --> C2[leader's own check of a save]
    C2 -->|refused| N2[no part stops]
    C2 -->|accepted| X2[stop parts, change both Macs, start parts]
  end
Loading

Hooked up

New item Set at Read at
ClusterApprovalSync.apply ClusterService.checkApproval (under the command lock) -
ClusterApprovalCheck.peerApprovalID ClusterService.checkApproval (decide) ClusterApprovalCheck.macsDiffer, step
ClusterServiceStatus.approvalID ("" for none) ClusterService.status() ClusterApprovalCheck.peerApprovalID
ClusterService.childLogOffset, lastError(in:from:) ClusterService.supervise (part start: seekToEndOfFile) supervise (part end -> ClusterApprovalCheck.memberQuickEnds)
CI step Run cluster onboarding checks .github/workflows/ci.yml, job Cluster Metadata Checks runs provider-swift/Tests/ClusterOnboardingChecks/run.sh
every new row - CI Provider Unit Tests (scripts/run-provider-tests.sh), the onboarding checks in Cluster Metadata Checks

Rows

Row What it checks Mutation that fails it
ClusterApprovalWatchTests.noPartStopsForAnApprovalTheLeadersOwnCheckRefuses a save the leader's own check refuses stops, sends and starts nothing; a stop that fails changes and starts nothing; an accepted save stops once, saves both Macs, starts once stopping before the check
ClusterApprovalWatchTests.aFollowerThatDoesNotReportItsApprovalIsNeverTakenForOneWithout a status without approvalID (older build) and no answer are unknown: no difference, step keeps; "" is none and differs; the same ID does not reading an absent field as none
ClusterApprovalWatchTests.aPartsQuickEndsAreCountedFromItsOwnLogLinesOnly an earlier part's unreachable line is not read for the next part; the part's own line is; a log shorter than the offset is read whole reading the whole log
ClusterApprovalWatchTests.convergingOnNoneAlsoClearsTheLeadersApprovalThatIsNotOffered local-only leader holding an approval, other Mac holding none: converge on none clears both, and the next check finds no difference keeping the leader's approval
ClusterOnboardingChecks.leaderWaitsForThePartsAfterTheRegistration (now in CI) after a refused or a successful registration the screen waits for the parts before Done printing Done while the parts restart

Deviations

  • The lock race and the busy-lock back-off live in the service loop's thread and the per-user command lock file. They have no row of their own; apply, which they now call under the lock, has one.

Validation evidence

  • No build or test ran on the laptop (binding rule). CI on this PR is the validation.
  • 2026-10-29T04:25:30Z: pushed the branch (c32379f). CI run 40817707824 failed at 04:38:42Z: a name clash in lastError(in:from:) (tail declared twice), and the onboarding checks, run in CI for the first time, had 582 passed and 9 failed: seven expectations still ended the operations at the test request, before PR 1661's register.
  • 2026-10-29T04:39:22Z: pushed 165fe91 (both fixed). CI run 40818970772 passed at 05:04:52Z: Provider Unit Tests, Provider Tests, Provider Prompt Parity, Provider SDK Tests, Cluster Metadata Checks (with Run cluster onboarding checks), Docs Lint, Release Integrity.

Decisions for David

None.

🤖 Generated with Claude Code

davidtai and others added 6 commits October 28, 2026 23:22
Second delta review of PR 1661, item 3. When a coordinator-paired part
ended, ClusterService read the last "Error:" line of the whole rank log.
A part that ended without an error line of its own was then judged by an
earlier part's line, for example an earlier "coordinator could not be
reached", and its quick end was not counted.

The service now records the log offset where each part begins writing and
reads only from there (`ClusterService.lastError(in:from:)`). A log shorter
than the offset was replaced and is read whole.

Row: ClusterApprovalWatchTests.aPartsQuickEndsAreCountedFromItsOwnLogLinesOnly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…one"

Second delta review of PR 1661, item 2. A follower whose build does not
report `approvalID` in its status sent no field, which decoded as nil and
read as "no approval": the leader would then converge an offered pair to
none against a follower that may carry the approval.

Each Mac now reports `approvalID` always, "" for none.
ClusterApprovalCheck.peerApprovalID reads an absent field (an older build)
or no answer as unknown, so macsDiffer is false and nothing converges.

Row: ClusterApprovalWatchTests.aFollowerThatDoesNotReportItsApprovalIsNeverTakenForOneWithout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… not offered

Second delta review of PR 1661, item 4. When the leader still held a
cluster approval it does not offer (it ended, or the cluster serves locally
only) and the other Mac held none or another, the check converged on none:
it sent "none" to the other Mac and said "neither Mac carries one now", but
the leader kept its own, so the line was not true and every check found the
same difference again.

ClusterApprovalSync.converge(nil) now also saves the leader's setup without
the cluster approval it holds.

Row: ClusterApprovalWatchTests.convergingOnNoneAlsoClearsTheLeadersApprovalThatIsNotOffered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… before any stop

Second delta review of PR 1661, item 1, and review finding 3.

- ClusterService.checkApproval read the saved setup, the record and the
  other Mac's status and computed the step before it took the command
  lock, then acted on that step. A person's command could change the setup,
  the scope or the other Mac in between. The step is now decided again under
  the lock, from the setup, record and status as they are then, with the
  same coordinator answer (the coordinator is asked at most once per check).
- ClusterApprovalSync.apply runs the change: a save is first checked against
  the leader's own files and pairing (ClusterApprovalAttachment.attachment),
  so no part stops for an approval the leader refuses; then the parts stop,
  the change runs on both Macs, and the parts start again.
- A busy command lock no longer retries at every tick: the check backs off
  to the next minute and says so in the log.

Row: ClusterApprovalWatchTests.noPartStopsForAnApprovalTheLeadersOwnCheckRefuses
(refused: no stop, nothing sent or started; a stop that fails changes and
starts nothing; accepted: one stop, both Macs saved, one start). The lock
race and the back-off live in the service loop's thread and the per-user
command lock file; they have no row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The model-free onboarding checks (provider-swift/Tests/ClusterOnboardingChecks,
a real pseudo-terminal with scripted operations, compiled with plain
swiftc) ran only by hand, so leaderWaitsForThePartsAfterTheRegistration
(PR 1661) had no CI run. They now run as a step of the Cluster Metadata
Checks job, beside the other model-free cluster check runners. test.md says
so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…own follower ID

configuration.md "Coordinator-paired member": the Both or neither row names
"" for none and an older follower that does not report the field; the new
Changing row says the leader decides under the command lock, checks a save
against its own files before any stop, and waits a minute on a busy lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Error Error Oct 29, 2026 4:55pm UTC
d-inference-console-ui-dev Error Error Oct 29, 2026 4:55pm UTC
d-inference-landing Ready Ready Preview Oct 29, 2026 4:55pm UTC
darkbloom-status Ready Ready Preview Oct 29, 2026 4:55pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 29, 2026 4:55pm UTC

Request Review

@blacksmith-sh

This comment has been minimized.

…ect register

CI run 40817707824 on the follow-up branch:

- ClusterService.lastError(in:from:) named its byte window `tail`, which
  the existing line read a few lines below redeclared. Renamed to
  `window`.
- The onboarding checks, now run in CI for the first time, still expected
  the operations to end at the test request. Since PR 1661 a public-scope
  setup calls `register` after a test that passed; seven expectations now
  include it. The run had 582 passed, 9 failed; these were the 9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…chitecture

Docs Impact maps the changed cluster sources to docs/architecture/inference.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch had an error being deployed

2 failed and 3 active deployments
Preview – d-inference-landing — da628211 Deployed Oct 29, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — da628211 Deployed Oct 29, 2026 by vercel[bot]
Preview – darkbloom-status — da628211 Deployed Oct 29, 2026 by vercel[bot]
Preview – d-inference — da628211 Deployed Oct 29, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — da628211 Deployed Oct 29, 2026 by vercel[bot]
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.

1 participant