Repository navigation
test(k8s-sandbox): pin fast-tier availability per transport - #640
Conversation
rossoctl#245's remaining acceptance item: "a test pins fast-tier availability per transport, so a fourth transport cannot silently ship without one -- the same discipline transport.ts applies to `truncated`." PR rossoctl#606 landed the two-tier split and the required `SandboxTransport.fastTier` field; the discipline it claimed was only half in place. Two holes, each proven by mutation first. 1. The latch wrapper could answer for what it wraps. conformance.ts said it pinned that "a wrapper (the capacity latch wraps BOTH tiers) cannot quietly answer for the thing it wraps", but the only assertion read the UNWRAPPED object. Hardcoding `fastTier: 'persistent-channel'` in capacity-latch.ts passed all 181 tests. That wrapper is what `extension.ts` hands every tool on a harness turn, so the value a caller actually reads was unasserted. The battery now asserts it through `createCapacityLatch().watch()` as well -- placed in the battery, not in capacity-latch's own tests, because forwarding must hold for whichever transport is latched and this is the only list of all of them. 2. Enrolment itself was unpinned. A required field makes OMITTING the claim a compile error, not DECLARING one and never being held to the battery -- type-correct and unasserted, which is the state this divergence was already in. A fourth transport declaring `persistent-channel` with no conformance file passed everything. fast-tier-coverage.test.ts pins the declaration sites against the enrolments, in the loud-throw source-reading idiom output-cap-coupling.test.ts uses for the Go constants: the correspondence is N declarations against N enrolments, which no type expresses. Its second case guards the guard -- with the battery's assertions deleted, TransportCapabilities.fastTier would become a field every factory fills in and nothing reads. Mutations, all killed; M1 survived before this change: M1 latch hardcodes a tier instead of forwarding 3 tests fail M2 KubectlTransport claims 'persistent-channel' 2 fail M3 battery drops the raw-transport assertion 1 fail M4 battery drops the through-the-latch assertion 1 fail M5 fourth transport declares a tier, never enrols 1 fail, naming it M6 fastTier renamed across src/ loud-throws The reader anchors on the ENCLOSING `export function`, not the file's first: both transport files open with an argv builder, so taking the first export would name a helper no conformance file imports and report a failure that is the reader's own -- worse than no test, since it trains the next person to edit the expectation. Two comments corrected rather than left overclaiming: capacity-latch.ts no longer says the forwarding is "never asserted", and FastTier's doc states that the discipline takes two tests and why each covers only half. Acceptance items 1 and 2 were already satisfied (rossoctl#606, and 934b613 enrolling persistentExecInPod with `producer-side-cap`). Item 4, measured per-file-op latency before/after on the gRPC path, has no "after" to measure: `rpc Exec` is one command per RPC, so that path still has no fast tier by design (run-leaf.ts:1040-1048 documents why splitting the tiers there would be worse). What changed is that the fact is now readable off the seam. Spec: the transport design's wire-semantics section gains a per-transport fast-tier bullet and table mirroring the existing `producerStop` one, and the test-layer table's Conformance row is corrected from "both" to all three. Fixes rossoctl#245 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
LGTM. Running the latch-forwarding assertion through the battery is the right place for it, and I checked the declarer/enrolment correspondence at this head: there are 3 literal declarers, each imported in a runConformance file, and the latch forwards. One suggestion: the enrolment reader can be satisfied by a plain import rather than an actual battery run. One nit. Both are inline.
Author: cwiklik (MEMBER — maintainer)
Areas reviewed: TypeScript (k8s-sandbox tests, src comments), Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing
| const src = readFileSync(resolve(HERE, file), 'utf8'); | ||
| // The battery's own definition, not a run of it. | ||
| if (!/\brunConformance\(/.test(src) || file === 'conformance.ts') continue; | ||
| for (const m of src.matchAll(/^import \{([^}]*)\} from '\.\.\/src\/([\w-]+)\.js';$/gms)) { |
There was a problem hiding this comment.
suggestion: readEnrolled adds every named import from ../src/*.js in any file that calls runConformance, not the constructors the battery actually runs over. Example: tests for a fourth transport added to grpc-relay-transport.test.ts (which already calls runConformance for gRPC) and importing FourthTransport would count it as enrolled with no battery run, which is the M5 hole again. It also over-collects today (DEFAULT_EXEC_TIMEOUT_S, SandboxCapacityRefusedError, …). Consider tying enrolment to the call itself: extract the identifiers used inside the factory passed to runConformance(...), or have each conformance file name its constructor explicitly so the reader can match on that. Keep the loud-throw.
| // The assertion the issue asks for: "a fourth transport cannot silently ship without | ||
| // one". Reported as the full list rather than per-case, so a failure names the | ||
| // transport that was added and the file that must run the battery over it. | ||
| const missing = readDeclarers().filter((d) => !readEnrolled().has(d.name)); |
There was a problem hiding this comment.
nit: readEnrolled() re-scans the directory and re-reads every file once per declarer inside filter. Hoist it: const enrolled = readEnrolled();.
Summary
Closes the remaining acceptance item on #245: "a test pins fast-tier availability per transport, so a fourth transport cannot silently ship without one — the same discipline
transport.ts:24-32applies totruncated."PR #606 landed the two-tier split and the required
SandboxTransport.fastTierfield. The discipline it claimed was only half in place. Two holes, each proven by mutation before anything was written.1. The latch wrapper could answer for what it wraps
conformance.tssaid its fast-tier case pinned that "a wrapper (the capacity latch wraps BOTH tiers) cannot quietly answer for the thing it wraps" — but the only assertion read the unwrapped object. HardcodingfastTier: 'persistent-channel'incapacity-latch.tspassed all 181 tests.That wrapper is what
extension.tshands every tool on a harness turn (watchwraps both tiers), so the value a caller actually reads was unasserted. The battery now asserts it throughcreateCapacityLatch().watch()too.Placed in the battery rather than in
capacity-latch's own tests deliberately: forwarding must hold for whichever transport is latched — including a fourth — and the battery is the only list of all of them.2. Enrolment itself was unpinned
A required field makes omitting the claim a compile error. It does nothing about declaring one and never being held to the battery — type-correct and unasserted, which is the state this whole divergence was already in. I added a fourth transport declaring
persistent-channelwith no conformance file: everything passed.fast-tier-coverage.test.tspins the declaration sites against the enrolments, in the loud-throw source-reading idiomoutput-cap-coupling.test.tsandrefusal-vocabulary-coupling.test.tsuse for the Go constants. Same reason: the thing being pinned is a correspondence no type expresses — N declaration sites against N enrolments. Its second case guards the guard, since with the battery's assertions deletedTransportCapabilities.fastTierwould become a field every factory fills in and nothing reads.Mutation testing
All killed. M1 survived before this change — it is the hole that motivated it.
KubectlTransportclaimspersistent-channelFourthTransport (src/fourth-transport.ts)fastTierrenamed acrosssrc/One reader detail worth flagging: it anchors on the enclosing
export function, not the file's first. Both transport files open with an argv builder (buildKubectlArgs,buildPersistentKubectlArgs), so taking the first export would name a helper no conformance file imports and report a failure that is the reader's own — worse than no test, because it trains the next person to edit the expectation instead of the code.Acceptance items
extension.ts:111-117)producer-side-cappersistentExecInPodenrolled by934b6130On item 4. There is no "after" to measure.
sandbox.proto'srpc Execis one command per RPC, so the gRPC path still has no fast tier by design, andrun-leaf.ts:1040-1048documents why splitting the tiers at that call site would be worse rather than better: naming onlystreamTransportlets the fast tier fall through to its default,persistentExecInPod, which spawns a localkubectl exec— and a leased pool sandbox is reached over the relay (ADR-0024), so there is no kubectl path to it and no pod this process could exec into. Closing that gap needs a long-lived shell on the wire, not a flag at the call site. What #245 changed is that the fact is now readable off the seam (selected.transport.fastTiersays'per-call-exec'), which is what makes the measurement meaningful once there is a second transport to put beside it. I would rather say that plainly than publish a before/after where both numbers are the same path.Comments corrected rather than left overclaiming
capacity-latch.tsno longer says the forwarding is "never asserted" — it now is.FastTier's doc comment states that the discipline takes two tests, and why the required field and the battery each cover only half.Spec
The transport design's wire-semantics section (§8) gains a per-transport fast-tier bullet and table, mirroring the
producerStopone directly above it — the same shape of fact belongs in the same place. The test-layer table's Conformance row is corrected from "bothKubectlTransportandGrpcRelayTransport" to all three, which has been stale since934b6130.Verification
packages/k8s-sandbox: 186 passed / 11 skipped (was 181 — 3 latch assertions across the three transports, plus 2 coverage tests)tsc --noEmitclean ink8s-sandbox,harnessandsandbox-relayprettier --checkclean on all five filessandbox-relay'stier-affinity.integration.test.tsfails locally (wants Redis on:6379). I confirmed by stashing that it fails identically on cleanupstream/main, so it is pre-existing and not from this change.make lint/make teststill die atpnpm install(ERR_PNPM_IGNORED_BUILDS) on this machine, so the gates were run directly.Fixes #245
Assisted-By: Claude Code