lore: lore/implementation-loop/issue-1624 - #1688
Conversation
…er-agent-token Acceptance tests for selectReporterToken, a boot-time credential selector that replaces the per-call `LORE_INGEST_TOKEN ?? agentToken` fallback chain in index.ts. Three tests pin the invariant: - central cluster: LORE_INGEST_TOKEN is captured at construction, not read from env on every call, so a mid-run removal cannot fall back to agentToken - satellite: the agentToken thunk is returned directly, so rotations are still picked up per-call - satellite: LORE_INGEST_TOKEN appearing in the env after the token is selected is ignored — boot-time decision, not per-call The function does not exist yet; all three tests fail with "Cannot find module './select-reporter-token.js'". Strategy: parallel-change — see .lore/dod.md for the facets. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔍 Lore Spec Impact — advisoryThis PR touches 1 statement(s) across 1 spec(s), and 1 of them has validating tests this PR does not change. Feature Specification: Running Stations in Any Kubernetes Cluster · 1 statement(s)
FR5 — Reporting credentials for satellites only its test links changed — the statement text itself is unchanged
validated by 1 new statement(s) have no test link yet. Deterministic · graph @ |
…tial at boot Replaces the two inline `() => process.env.LORE_INGEST_TOKEN ?? agentToken` thunks (token and TelemetrySink) with a single `reporterToken` selected once at boot via `selectReporterToken(process.env, () => agentToken)`. Central clusters capture LORE_INGEST_TOKEN statically; satellites use the per-agent thunk so re-registration rotations are still visible. Eliminates the per-call fallback that caused the 2026-08-24 outage.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@lore review |
|
Lore is reviewing this PR — b7652aae-31d7-444d-8bf2-85dbdbab0ad3. Reply to any review comment to discuss or approve a fix (e.g. "ok, fix it"). Comment |
|
Inline placement was rejected by GitHub, so this review is posted as a single comment. Lore review — ApprovedCorrect, well-tested fix for the 2026-08-24 credential-shadowing outage; only cosmetic convention gaps remain. Must fix (0) · Consider (0) · Nits (3) Reply to any review comment to discuss or approve a fix (e.g. "ok, fix it"). Comment
|
|
Lore implementation-loop run failed (failed — node "dod" failed: BackoffLimitExceeded: Job has reached the specified backoff limit — The pod died rather than the work failing — a crash, an OOM, an eviction, or a Job deadline. Re-running is the right response; check pod events if it repeats.) — e536b555-642f-4765-9b0a-39acbdd9c250. |
The cluster-agent was choosing which credential to use on every call via
process.env.LORE_INGEST_TOKEN ?? agentToken. That per-call fallback is whatcaused the 2026-08-24 outage: a central-cluster agent that had
LORE_INGEST_TOKENmounted would correctly pick it up most of the time, but any satellite that
somehow acquired the variable after boot would shadow its own per-agent token
and 401 on every report — both ends typechecked, nothing in the logs until the
reaper cleaned up the stuck nodes.
The fix is in
apps/cluster-agent/src/claim/select-reporter-token.ts. Thefunction
selectReporterToken(env, getAgentToken)readsenv.LORE_INGEST_TOKENexactly once at call time and makes a permanent decision: if the token is
present the central path captures it in a static closure and returns that same
value forever, so later env mutations are irrelevant; if it is absent the
satellite path returns the
getAgentTokenthunk directly, so re-registrationrotations continue to be picked up per call. There is no fallback chain, and
the choice cannot change after boot.
apps/cluster-agent/src/index.tscallsselectReporterToken(process.env, () => agentToken)once during startup and binds the result toreporterToken. Boththe
ClaimLoopreporter and theTelemetrySinknow receive that singlereference instead of inlining the
??expression independently. Keeping twoseparate inlinings was an additional hazard: they could drift.
The three acceptance tests in
apps/cluster-agent/src/claim/select-reporter-token.test.tscover the threeinvariants the DoD names: the central capture survives an env delete after
selection, the satellite thunk reflects rotations made after selection, and a
satellite ignores
LORE_INGEST_TOKENthat appears in the env after the choicewas made. All three were written red first, then made green by the implementation.
This is FR5 of
specs/running-stations-in-any-k8s-cluster/spec.md. TheacceptedTokensrelay route inindex.ts(line 120) was deliberately leftunchanged — it accepts both tokens because agent run pods may present either,
and that multi-token accept path is covered by a separate requirement (FR8.1).
No deviation from the DoD strategy.