Skip to content

test(k8s-sandbox): pin fast-tier availability per transport - #640

Merged
cwiklik merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/245-fast-tier-availability
Oct 27, 2026
Merged

cwiklik merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/245-fast-tier-availability

Conversation

@cwiklik

@cwiklik cwiklik commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

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-32 applies to truncated."

PR #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 before anything was written.

1. The latch wrapper could answer for what it wraps

conformance.ts said 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. 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 (watch wraps both tiers), so the value a caller actually reads was unasserted. The battery now asserts it through createCapacityLatch().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-channel with no conformance file: everything passed.

fast-tier-coverage.test.ts pins the declaration sites against the enrolments, in the loud-throw source-reading idiom output-cap-coupling.test.ts and refusal-vocabulary-coupling.test.ts use 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 deleted TransportCapabilities.fastTier would 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.

# Mutation Result
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 A fourth transport declares a tier, never enrols 1 fail, naming FourthTransport (src/fourth-transport.ts)
M6 fastTier renamed across src/ Loud-throws, not a vacuous pass

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

# Item Status
1 Extension can be given a fast tier and a stream tier independently Done in #606 (extension.ts:111-117)
2 A container-exec persistent channel passes the battery declaring producer-side-cap Already done — persistentExecInPod enrolled by 934b6130
3 A test pins fast-tier availability per transport This PR
4 Measured per-file-op latency before/after on the gRPC path Not deliverable — see below

On item 4. There is no "after" to measure. sandbox.proto's rpc Exec is one command per RPC, so the gRPC path still has no fast tier by design, and run-leaf.ts:1040-1048 documents why splitting the tiers at that call site would be worse rather than better: naming only streamTransport lets the fast tier fall through to its default, persistentExecInPod, which spawns a local kubectl 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.fastTier says '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.ts no 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 producerStop one directly above it — the same shape of fact belongs in the same place. The test-layer table's Conformance row is corrected from "both KubectlTransport and GrpcRelayTransport" to all three, which has been stale since 934b6130.

Verification

  • packages/k8s-sandbox: 186 passed / 11 skipped (was 181 — 3 latch assertions across the three transports, plus 2 coverage tests)
  • tsc --noEmit clean in k8s-sandbox, harness and sandbox-relay
  • prettier --check clean on all five files

sandbox-relay's tier-affinity.integration.test.ts fails locally (wants Redis on :6379). I confirmed by stashing that it fails identically on clean upstream/main, so it is pre-existing and not from this change. make lint / make test still die at pnpm install (ERR_PNPM_IGNORED_BUILDS) on this machine, so the gates were run directly.

Fixes #245

Assisted-By: Claude Code

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 ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: readEnrolled() re-scans the directory and re-reads every file once per declarer inside filter. Hoist it: const enrolled = readEnrolled();.

@cwiklik
cwiklik merged commit 453c78d into rossoctl:main Oct 27, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ST: the gRPC transport has no persistent fast channel — file ops pay a round trip and a process each

2 participants