Skip to content

refactor(core): vercel-gateway decode into core, report fetch host-side (phase 8, network special) - #842

Merged
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/vercel-gateway
Jul 27, 2026
Merged

refactor(core): vercel-gateway decode into core, report fetch host-side (phase 8, network special)#842
iamtoruk merged 1 commit into
feat/core-extractionfrom
phase8/vercel-gateway

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

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 costUSD with no costBasis key (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):

  • The Symbol-keyed dateRange side-channel wasn't just ugly — it mutated the caller's shared SessionSource in place (enumerable, despite a comment claiming otherwise). A new golden arm fails against the draft and passes against both the oracle and the rewrite.
  • The project-in-records packing violated the bridge's records contract; with a bespoke adapter source.project is simply in scope.

Also fixed: a false privacy claim in the core observations header (day DOES flow into timestamp/dedupKey; the genuine containment is the envelope schema's date-time format, now pinned by a hostile-day smuggling arm) and three vacuous not.toContain assertions.

Oracle: strengthened goldens pass 13/13 identically against the restored pre-migration original; vercel-gateway.test.ts byte-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 root npm test 2465 passed, 5 skipped; tsc --noEmit clean.

Flagged, untouched: the arch gate's MACHINE_ID_ALLOWLIST justification comment ("hash-derived") is looser than reality for dedup keys — joins the schema-wide dedup-key follow-up.

…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.
@iamtoruk
iamtoruk merged commit d8ea608 into feat/core-extraction Jul 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant