Repository navigation
collectors: resolve the scoped grant before the environment (OPS-1120) [ZC: WW.3.S] - #2091
Conversation
|
@kody start-review Reorders resolveCollectorToken to store-first, refuses service-token-shaped environment values outside strict-injected mode, and wires the previously-unrun resolve-collector-token suite into the collectors vitest config. No token values or secrets in the diff. |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
Automatic approval held Kody's assessment:
|
This comment has been minimized.
This comment has been minimized.
`resolveCollectorToken` read the environment first and returned immediately, so a value sitting in the environment beat the reviewed Infisical grant and nothing proved where it came from. It now asks the consumer's scoped Infisical binding first, per name, and consults the environment only for a name the store did not answer. An environment value shaped like an Infisical service token (`st.<id>.<secret>`) is now refused outside `COLLECTOR_STRICT_INJECTED_SECRETS=1`, because this synchronous resolver cannot read that token's own metadata to prove whose narrow grant it is. Strict-injected mode is a delivery channel (the injector already read the store), so it is exempt. The documented static producer tokens (`<PRODUCER>_INGEST_TOKEN`, `USAGE_INGEST_TOKEN`) are app bearers rather than Infisical grants and keep resolving from the host bootstrap store; a production smoke test over the server collector env resolved every producer name unchanged. Also wires `scripts/__tests__/resolve-collector-token.test.mjs` into the collectors vitest config. That suite existed but no runner included it (the main config excludes `scripts/__tests__/**` and the collectors config listed three other files), so the token precedence contract it pins had been gating nothing. Its service-token fixture is built at runtime so no token-shaped literal enters the tree.
d80c56e to
b4db6db
Compare
|
@kody start-review Store-first resolveCollectorToken, service-token-shaped env refusal outside strict-injected mode, and the previously-unrun resolve-collector-token suite wired into the collectors vitest config. Docs: AGENTS.md provenance line. |
…d name Review findings on the store-first change. Two fixture cases in `scripts/__tests__/run-session-token-collector.fixture.mjs` still asserted the old environment-first contract and failed under `test:collector-runtime`; they now assert the store value wins and that the environment is trimmed and returned only after the store answers empty. A refused service-token-shaped environment value is now deferred instead of thrown at once, so one poisoned candidate name cannot block a valid `USAGE_INGEST_TOKEN` under a later name; the refusal is raised only when no name yields a usable value.
This comment has been minimized.
This comment has been minimized.
`COLLECTOR_STRICT_INJECTED_SECRETS` was compared with exact `=== "1"`, so a padded value silently dropped the process into the non-strict path: extra scoped reads and a spurious shape refusal. It is trimmed like the token values now, with a test.
|
@kody start-review Two fixed (runtime fixture store-first assertions; deferred refusal so a poisoned name cannot block a valid later candidate) and one more fixed since (whitespace-padded COLLECTOR_STRICT_INJECTED_SECRETS now trimmed). The performance and env-control findings are declined with reasons in their threads. Suites: 120 vitest + 75 fixture checks. |
This comment has been minimized.
This comment has been minimized.
The critical findings behind this request are resolved.
`deferredFailure ??=` kept only the first deferred error, so a second refused name or a scoped-read failure behind a shape refusal was silently dropped and diagnosing took one run per problem. The resolver now keeps the two kinds apart: a failed scoped read is thrown in preference to a shape refusal because it is the more actionable error, and when no value resolves the refusal names every refused candidate at once.
|
@kody start-review Last finding fixed: deferred failures are now kept in two slots, a scoped-read failure outranks a shape refusal, and every refused name is named at once. All threads resolved. Suites: 122 vitest + 75 fixture checks. |
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Fixes OPS-1120is not claimed here: those two sites keep the issue open. Refs OPS-1120.Resolves collector ingest tokens store-first for OPS-1120.
resolveCollectorTokennow consults this consumer's scoped Infisical binding before the environment for each name in order, so a reviewed grant cannot lose to a value merely present in the environment. Environment values shaped like an Infisical service token are refused outsideCOLLECTOR_STRICT_INJECTED_SECRETS=1, because the synchronous resolver cannot prove the grant from metadata; static producer app bearers continue to work from the host bootstrap store when the scoped store has no answer. Strict injected-secrets mode skips the runtime lookup entirely, and deferred store failures are rethrown only when no name yields a value. Docs inAGENTS.mdupdated with provenance order. Tests added inscripts/__tests__/resolve-collector-token.test.mjscovering store-first precedence, environment fallback, service-token refusal/allowance, strict-mode bypass of lookup, and deferred failure handling, and the file was added to the collectors Vitest config. Test execution, deployment, and runtime verification are unverified. Open automated review findings remain unresolved: strict-mode bypass of service-token shape refusal, and whitespace-padded strict flag silently disabling strict mode.Resolves collector ingest token via scoped store grant before environment fallback for OPS-1120. Environment values remain trimmed fallback only when the store has no usable value.
Behavior
Tests
Summary
Updates collector token resolution to check the scoped secret-store grant before the environment (OPS-1120). Lookup failures are now tracked separately from environment shape refusals, so a scoped-read infrastructure error outranks a shape refusal and all refused candidate names are reported together when no usable value resolves.
Changes
Verification
Tests added but no run results, deployment, or runtime verification were reported in the provided context. Automated code review reported no issues. Operational behavior beyond the added unit coverage remains unverified.