refactor(core): vercel-gateway decode into core, report fetch host-side (phase 8, network special) - #842
Merged
Conversation
…de (phase 8, network special)
COMPLETES Phase 8 of the @codeburn/core extraction: 36/36 provider identities
(including qwen) now decode in core.
The row -> call mapping moves to packages/core/src/providers/vercel-gateway/
verbatim: day/model/cost defaults, the all-zero skip BEFORE the dedup key is
burned, the `vercel-gateway:<day>:<model>` key with add-after-skip semantics,
`${day}T12:00:00.000Z` timestamp synthesis ('' for a missing day), and the
`${day}:${model}` session id. The decoder is pure over supplied rows: no fs,
env, clock, or network.
Everything network stays host-side and byte-identical: the authenticated
/v1/report fetch, the AI_GATEWAY_API_KEY / VERCEL_OIDC_TOKEN reads, both stderr
warnings, discovery, `network: true`, and the gate that yields nothing when the
scan has no date range.
Adapter shape adjudication: the draft used createBridgedProvider and needed two
contortions to fit it — a Symbol-keyed dateRange stashed on the shared
SessionSource, and `project` packed into the records payload then unpacked by a
decode wrapper (the bridge passes neither the date range nor the source to the
mapping step). The Symbol injection also mutated the caller's discovered source
object, an observable behavior change. Rejected both; this provider now uses a
plain bespoke adapter like antigravity/kiro, which the bridge's own header
already documents as the escape hatch for providers it was not built to cover.
No change to bridge.ts, parser.ts, pricing-pass.ts, or session-cache.ts.
Emitted key shape is unchanged and gated by key-set assertions: `costUSD` is
present and there is NO `costBasis` key, so parser.ts keeps passing the
gateway's own dollar figure through instead of repricing it.
Validator fixes on top of the draft:
- Dropped the Symbol side-channel and the packed-payload decode wrapper.
- Corrected a false claim in the core observations header: it said the raw `day`
was never emitted, but `day` is spliced verbatim into the timestamp, into
startedAt/endedAt, and into the dedup key. The envelope's date-time constraint
is what actually bounds it; a new smuggling arm pins that a hostile `day`
fails envelope validation.
- Added golden arms for both stderr warnings, for the no-date-range arm making
no fetch at all, and for the provider not mutating the discovered source.
Verification: the strengthened goldens were run against the pre-migration
provider restored in place and pass identically (13/13). Swapping the all-zero
skip and the dedup burn fails tests at both the core and CLI layers.
Core 509 tests, CLI 2470, root 2470 — all green.
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.
Phase 8 network special (tracking #809) — this completes Phase 8: all 36 provider identities (35 tail + qwen) now decode in
@codeburn/core.vercel-gateway's row→call mapping moves into core (dedup add-after-skip, all-zero skip before key burn — mutation-proven at both layers, timestamp/sessionId synthesis, defaults); the authenticated report fetch, auth env reads, stderr warnings, and the no-dateRange gate stay host-side. The emitted key shape keeps
costUSDwith nocostBasiskey (parser's verbatim pass-through), gated by key-presence assertions.Validation rejected the draft's two bridge contortions and rewrote the CLI side as a plain ~12-line bespoke adapter (the antigravity/kiro escape hatch the bridge's own header names):
Symbol-keyeddateRangeside-channel wasn't just ugly — it mutated the caller's sharedSessionSourcein place (enumerable, despite a comment claiming otherwise). A new golden arm fails against the draft and passes against both the oracle and the rewrite.project-in-records packing violated the bridge's records contract; with a bespoke adaptersource.projectis simply in scope.Also fixed: a false privacy claim in the core observations header (
dayDOES flow intotimestamp/dedupKey; the genuine containment is the envelope schema'sdate-timeformat, now pinned by a hostile-daysmuggling arm) and three vacuousnot.toContainassertions.Oracle: strengthened goldens pass 13/13 identically against the restored pre-migration original;
vercel-gateway.test.tsbyte-unchanged; discovery/display/auth code zero diff hunks.Gates: core 509/509 (heap-flag caveat:
import-smoke's spawned build needs--max-old-space-size=8192— pre-existing, flagged for a separate fix); CLI suite and rootnpm test2465 passed, 5 skipped;tsc --noEmitclean.Flagged, untouched: the arch gate's
MACHINE_ID_ALLOWLISTjustification comment ("hash-derived") is looser than reality for dedup keys — joins the schema-wide dedup-key follow-up.