test(cli): pin the multi-installation projection precedence (TASK-019) - #1756
Merged
Merged
Conversation
samxu01
force-pushed
the
kai/task019-installation-projection-tests
branch
from
September 18, 2026 16:52
4ad2e75 to
910b2f9
Compare
A runtime token carries an identity, and one identity can hold several active installations; bootstrapAgentRecordFromEnv collapses that list into a single local record. Only the first link of the collapse (an active installation outranking an earlier DM row) had a test. Pins the remaining branches: first-among-several is positional, the fallback when no installation rows exist, the empty/missing/non-array shape, and identity.instanceId outranking the chosen row's. Mutation-proven: dropping the `status === 'active'` term from the find reds exactly one of the new cases and nothing else. Tests only, cli/__tests__ — the version guard watches cli/src, so no bump. TASK-019.
lilyshen0722
force-pushed
the
kai/task019-installation-projection-tests
branch
from
September 19, 2026 15:29
910b2f9 to
329a89a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the test half of TASK-019 — "daemon multi-installation projection: test inaccessible peer runtime precedence".
What the projection is
A runtime token carries an identity, and one identity can hold several active installations.
bootstrapAgentRecordFromEnv(cli/src/commands/agent.js:117) collapses that list into one local record, and the collapse is positional:Only the first link had a test (the existing "synthesizes a full record" case, where an
agent-adminDM row sits ahead of the installation). This pins the rest:AgentInstallation.find), so which pod a multi-installation seat projects is currently insertion order. Pinned so a change to that preference has to be deliberate.podId: null,instanceIdfrom the identity.identity.instanceIdoutranks the chosen row's, which only supplies a fallback.Mutation proof
The
status === 'active'term is load-bearing and I proved it rather than assuming it. Dropping it from thefindpredicate:Exactly one test reds — the case built for it (an active DM row, an inactive installation, then an active installation: with the term the third wins, without it the second does).
Measured while writing this, and it changes what a reader should worry about
The
statusterm never rejects anything the live endpoint serves: both auth paths querystatus: 'active'(backend/middleware/agentRuntimeAuth.ts:121for a User-row token,:186for an installation-bound token), andagentsRuntime.ts:440mapsstatus: inst?.status || 'active'. So the only reachable fallback is "no installation rows at all", not "a stale row". The inactive-row case is still pinned, labelled as unreachable today, because if that endpoint ever widens the failure is silent: a seat booting against a pod whose installation is not live.I checked the producer before writing the risk down. A first draft of this asserted the CLI could project an inactive installation row from the live endpoint; reading
agentRuntimeAuthshowed that is not reachable, so the test now says so instead of implying a defect.Verification
cd cli && npm test— 39 suites / 543 passed / 10 skipped, green (the six new cases included).npm run lint:cli— clean.cli/__tests__/attach.test.mjs(+89), a single commit910b2f9aonmain. No version bump:.github/workflows/package-version-guard.ymlchecks$pkg/srconly, so a test-only diff needs none.5c367a1aas a second commit — two files, and a merge-order coupling to an unrelated docs PR. Rebased--onto mainin place; thecli/diff is byte-identical (diffof the pre- and post-rebase patches is empty), so the cleared content is unchanged and this PR is now the one file its title claims. Whichever of docs(review-checklist): rule 26 — a derived default must be one its consumer accepts #1755 / test(cli): pin the multi-installation projection precedence (TASK-019) #1756 lands second is no longer anything at all. The head therefore moved4ad2e753→910b2f9aafter Vera cleared it: same patch, different parent, called out here rather than silently.inst.config?.runtime?.runtimeType || inst.runtimeType || '?'chain in the admin installations listing (agent.js:2663) — has no seam to test through, so pinning it means extracting the row formatter first. I asked @vera which surface TASK-019 meant. Her answer: she cannot retrieve66201and will not reconstruct it, so the row is decided on the code — the daemon projection has a real, testable precedence and this PR pins it; the admin listing is a display fallback with no seam. The row now records the original wording as unrecoverable.