Skip to content

fix: #963 follow-ups — firmware read limit and telemetry/admission proof contention - #973

Draft
bloodf wants to merge 6 commits into
mainfrom
orq/tp2nlu/ship-13
Draft

bloodf wants to merge 6 commits into
mainfrom
orq/tp2nlu/ship-13

Conversation

@bloodf

@bloodf bloodf commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Draft until the Full Review verdict on the exact head.

#963 review follow-ups that did not reach main, because #963 was squash-merged at its pre-fix head:

  • Start-up firmware read limit (runtime/pause-driver-router.ts): the Anycubic start-up firmware read now runs only for a model in the Anycubic LAN model table with a qualified pair, so Kobra 3 (20024) and other bindings never trigger it. tests/node/fix-963b.test.ts fails on revert (it sees an unexpected firmware query).
  • Credential-proof slot contention (apps/farm/server/storage/postgres-connector-credential-acceptance.ts): each Connector credential has one proof slot shared by telemetry, signalling inboxes and context challenges. A telemetry upload kept it pending for at least 1 s, so a WebRTC admission arriving then got busy with retryAfterMs: 7000. The Connector refuses retries past its 8 s admission deadline, so the direct session closed and a print start after upload failed. Now an interactive request (signalling inbox, pause, context) that finds a pending telemetry challenge expires it and issues its own, in the same transaction under the slot's row lock.
    • Proofs stay single-use: either the telemetry batch commits first, or its proof finds the challenge expired and is denied with nothing committed. The Connector keeps the batch and resends it; telemetry is data, never a command.
    • Priority is one-way: telemetry never displaces another challenge, and interactive challenges never displace each other.
    • Cooldown, failure counters, signed envelopes, freshness and lifetimes are unchanged. No migration.
    • tests/node/fix-963c-proof-contention.test.ts runs against a disposable PostgreSQL with the real roles, for root and successor credentials, and fails on revert with busy/7000 ms.
  • Admission fairness (review round 1): a telemetry proof is now compared with the slot's current challenge before the shared cooldown. A superseded proof (its challenge retired by an interactive request) is denied at once, without waiting for or moving the cooldown, taking the admission lock or touching the failure counter. A lapsed current challenge is expired and denied the same way. Replays of the slot's current challenge still take the full path, so concurrent copies still get busy (atomic-telemetry test unchanged). The PostgreSQL test "a superseded telemetry proof never consumes cooldown reserved for the interactive proof" (root and successor credentials, both traffic types inside the cooldown window) is the regression detector: on revert it gets busy, retryAfterMs: 500 instead of denied. The journey is end-to-end coverage and passes either way.
  • Journeys (tests/journey/anycubic.spec.ts): wait for the inspector tile after a WebRTC reconnect, using the harness's existing wait, since main also timed out there. An interim commit paused telemetry during file operations, and the last commit removes that pause, so telemetry keeps flowing during upload, start and job end.

Validated on this head: tests/journey/anycubic-models.spec.ts and tests/journey/anycubic.spec.ts together, 14 passed (10.5 min), with playwright.journey.config.ts, bundled Chromium and loopback simulators. Focused node tests pass. The host's required checks must pass on this head before merging.

Known: other journey specs (moonraker, bambu, flashforge, fullfarmmanager) still pause telemetry the same way, and a comment in tests/journey/farm-app.ts (~119) still describes the old contention.

Refs #963

(cherry picked from commit 2a035022bc3b3c8a352f3063a1d5688f3c293ed4)
(cherry picked from commit 096452f544319c602f607c70ee91675d4352f095)
(cherry picked from commit 052911425880ce8adc59ef9d1aad647aa43a0f8c)
Telemetry uploads and signalling admission share one credential proof
slot. Each upload holds it pending for at least the 1 s cooldown, and an
admission that arrived then got busy for the rest of the telemetry proof
TTL, which can exceed the Connector's 8 s admission deadline.

A generic (interactive) issuance now expires a pending telemetry
challenge under the slot row lock and issues its own. The retired proof
is denied and commits nothing; the Connector resends the batch. Telemetry
never retires another challenge and generic challenges never replace
each other. No schema change.

(cherry picked from commit 2f0e94d581b84222d1634f12638b1994469a5ba5)
(cherry picked from commit 751f730d6fcc84cae4970884356629665fba04dc)

@bloodf bloodf left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the remaining admission fairness issue before merging 6715a5d. The shared cooldown is advanced before a telemetry proof is checked against the current challenge. Keep renewal and single-use guarantees intact while ensuring superseded telemetry cannot consume time reserved for an interactive proof. Extend the PostgreSQL regression to cover that ordering with both traffic types inside the cooldown window. The scoped journey passes with the proof fix reverted, so credit the PostgreSQL test for detecting the regression and the journey for end-to-end coverage.

A telemetry proof whose challenge was superseded by a later issuance (an
interactive admission retiring it) advanced next_attempt_at before it was
compared with the slot's current challenge, delaying the interactive proof
that owns the slot. Superseded proofs and lapsed current ones are now denied
before the cooldown, admission lock and failure counter are touched.
Renewal, single-use, row-lock order and one-way priority are unchanged.

Extends the disposable-PostgreSQL contention test (root and successor
credentials, real roles) with both traffic types inside the cooldown window;
it fails when this fix is reverted.

(cherry picked from commit b75de0bf4dbaffe08efc12b5cbab33632f70ad9a)

@bloodf bloodf left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The successor path still acquires the shared cryptographic admission slot and verifies the credential before the new superseded-proof check (around lines 361 and 514). Under concurrent superseded successor telemetry, those 32 slots can be occupied before interactive admission gets one. Please address that path while preserving single-use and concurrent replay semantics, and add a concurrent PostgreSQL regression. The new sequential root/successor test passes, but it does not exercise admission-slot contention.

This branch has not been deployed

No deployments
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