Skip to content

fix: v6.0 GA preship deep fixes — root-cause patterns 1–6 + matrix harness - #1119

Merged
bokelley merged 12 commits into
mainfrom
bokelley/preship-deep-fixes
Apr 30, 2026
Merged

bokelley merged 12 commits into
mainfrom
bokelley/preship-deep-fixes

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Pre-ship deep-fixes branch for v6.0 GA. Six commits driven by empirical matrix evidence (LLMs scaffolded agents from skills, hit specific failure patterns). Each fix targets the level the bug actually lived at — framework, skill, or harness.

Matrix delta: 0/4 pre-fix (100% harness-contaminated) → 3/4 post-fix (75%, with the 1 remaining failure being real seller-skill behavioral signal, not framework or harness noise).

Fixes

Framework

  • createAdcpServer removed from @adcp/sdk/server top-level (breaking — refactor!). LLMs were latching onto the @deprecated-tagged top-level export instead of the v6 createAdcpServerFromPlatform path. Now lives only at @adcp/sdk/server/legacy/v5, which re-exports the full top-level surface so v5 adopters do a single import-line swap.
  • Default InMemoryStateStore is now a module-singleton. Was the actual root cause of "Pattern 3 SI session loss." serve(() => createAdcpServer({...})) invokes the factory per request, and the destructured default stateStore = new InMemoryStateStore() evaluated per call — silently dropping every ctx.store.put(...) between requests. Adopters who write the obvious code now get cross-request persistence as the skills always promised. Production deployments still pass their own store (Postgres, Redis) and are unaffected. Regression test in test/server-state-store-extensions.test.js.
  • HITL guard on createMediaBuy/syncCreatives returns — framework rejects hand-rolled {status: 'submitted', task_id} envelopes with a clear error pointing at ctx.handoffToTask(fn). Bare submitted-shape returns skipped the task registry; buyers polled task_ids the framework never registered.
  • autoStoreResources now warns when records are skipped because the keying id field (signal_agent_segment_id, product_id, etc.) is missing — silent skip masked misshaped publisher responses.

Skills + docs

  • Signals skill: explicit GetSignalsResponse['signals'] typing on the example so signal_agent_segment_id can't be silently omitted.
  • SI skill: removed phantom SponsoredIntelligencePlatform import and invalid 'sponsored-intelligence' specialism (SI is a protocol, not a specialism in AdCP 3.0). Skill now redirects to v5 createAdcpServer from @adcp/sdk/server/legacy/v5 with explicit ctx.store.put('session', ...).
  • call-adcp-agent skill: documented MCP Streamable HTTP Accept: application/json, text/event-stream requirement (raw fetch() gets 406 before any AdCP framing).
  • Repo-wide sweep of createAdcpServer imports — 5 docs + 3 skills + 9 internal JSDoc + 3 examples/test-agents + matrix harness prompt + test-agents tsconfig subpath aliases. Migration doc updated to reflect actual hard-removal.

Harness

  • agent-skill-storyboard.ts --transcript <path> — captures Claude's full stream-json transcript per pair (thinking, tool calls, partial messages). scripts/manual-testing/diagnose-pair.sh wraps it for single-pair deep dives.
  • killPort() hardened — sweeps orphaned tsx adcp-agent-* zombies that survived a parent pkill against the matrix runner. Without this, prior matrix runs left port holders and new agents got EADDRINUSE while the harness's waitForPort was fooled by the old agents.
  • Spawned agents get NODE_ENV=development — createAdcpServerFromPlatform refuses to mint a default in-memory task registry outside {test,development} (production safety). Inheriting the parent shell's env meant every v6 agent's serve() factory threw at boot → serve.ts returned 500 → grader misreported as auth_required. Empirically confirmed by isolating an SI v5 agent (passed) and a seller v6 agent (boot crash) on the SAME bearer token.

Test status

  • 889/889 server-side tests pass (one new HITL guard test, one new state-store regression test).
  • SI baseline storyboard PASSES end-to-end via diagnose-pair.sh after the singleton fix.
  • Matrix v4 against the 4 affected patterns: 3 pass, 1 partial (seller — real behavioral gaps documented as v6.1 follow-up).

Commits

```
2120059 fix(harness): set NODE_ENV=development on spawned agents
c23a9b0 fix: default stateStore is now a module-singleton (Pattern 3 root cause)
f59fdea docs: sweep createAdcpServer imports after v6.0 breaking change
e9c08e1 test: add per-pair LLM transcript capture + diagnose-pair wrapper
cbafdcc fix: round-2 preship deep fixes from Emma matrix patterns
a41eb1e refactor!: remove createAdcpServer from @adcp/sdk/server top-level
```

Test plan

  • Run `npm test` locally — confirm 889/889 server-side green
  • Run `npm run compliance:skill-matrix -- --filter signal_marketplace,signal_owned,si_baseline,sales_guaranteed --parallel 2 --timeout-ms 1800000 --keep-workspaces` and confirm 3/4 pass with seller as the lone partial
  • Confirm `scripts/manual-testing/diagnose-pair.sh skills/build-si-agent/SKILL.md si_baseline 30` PASSES end-to-end
  • Verify `@adcp/sdk/server` no longer exports `createAdcpServer` (only `@adcp/sdk/server/legacy/v5` does)
  • Confirm changelog reflects the BREAKING change in row 3 of the migration doc

Follow-ups (NOT blocking GA)

Filed as separate v6.1 issue: 5 seller-skill behavioral coverage patterns surfaced by the matrix (TERMS_REJECTED, PACKAGE_NOT_FOUND, pending_creatives → pending_start transition, property_list/collection_list field placement, sync_accounts emphasis).

🤖 Generated with Claude Code

bokelley and others added 8 commits April 30, 2026 14:01
LLMs scaffolding agents from skills consistently picked createAdcpServer
despite the @deprecated JSDoc tag and v6 examples. Empirical evidence
from Emma matrix run 2: agents narrate "server.ts wires createAdcpServer
from @adcp/sdk/server" while the canonical v6 example sits unread at
the top of every skill.

The escape hatch now lives only at @adcp/sdk/server/legacy/v5, which
re-exports the full top-level surface so a v5 adopter's migration is
a single-line import swap.

BREAKING CHANGE: createAdcpServer is no longer exported from
@adcp/sdk/server or @adcp/sdk. Import from @adcp/sdk/server/legacy/v5
instead, or migrate to createAdcpServerFromPlatform.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Five surgical fixes for Emma matrix pattern reproductions — three
skill corrections + two framework guards.

Signals skill: type the example signals array as
GetSignalsResponse['signals'] so signal_agent_segment_id can't be
silently omitted. The handler return type already enforces the
contract; the example was the only loose link.

autoStoreResources: log a warning when records are skipped because
the keying id field is missing. Silent skip masked a misshaped
publisher response that left buyers unable to reference resources
on a downstream mutating call.

SI skill: removed the phantom SponsoredIntelligencePlatform import
and the invalid 'sponsored-intelligence' specialism declaration
(SI is a *protocol* in AdCP 3.0, declared via supported_protocols;
AdCPSpecialism enum doesn't include it). Skill now redirects to
the v5 createAdcpServer handler-bag from @adcp/sdk/server/legacy/v5
with explicit ctx.store.put('session', ...) for session state.
SI specialism + auto-hydration of req.session is a v6.x follow-up.

call-adcp-agent skill: documented the upstream MCP transport quirk
— Streamable HTTP requires Accept: application/json,
text/event-stream; raw fetch with only application/json gets 406
before any AdCP framing runs. Pointed at @modelcontextprotocol/sdk
client which sets the header correctly.

createMediaBuy HITL guard: framework now rejects hand-rolled
{status: 'submitted', task_id} returns from sales/creative
specialism handlers with a clear error pointing at
ctx.handoffToTask(fn). Hand-rolled submitted-shape returns
skipped the task registry, leaving buyers polling task_ids the
framework never registered.

Test coverage: 96/96 in server-decisioning-from-platform.test.js
including the new guard test. Existing handoff paths
(ctx.handoffToTask, sync success arms) untouched — guard fires
only on the bare submitted-shape literal that no test currently
exercises.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When a matrix pair times out, terminal output is gone — no way to
read what the LLM was producing when the wall hit. Two changes:

1. agent-skill-storyboard.ts: new --transcript <path> flag.
   Switches the claude invocation to
   `--output-format stream-json --verbose --include-partial-messages`
   and tees stdout (one JSON event per line) to the file while still
   inheriting to terminal so a live watcher can follow along.

2. diagnose-pair.sh: thin wrapper that picks ONE pair, gives it 30
   minutes (configurable), captures full transcript +
   --keep-workspace, dumps everything under
   .context/diagnose/<storyboard>-<timestamp>/.

Together: when matrix flags a pair as timed out, run
`diagnose-pair.sh <skill> <storyboard> 30` to reproduce with full
visibility — read every thinking block and tool call to see
whether the LLM was 90% done or stuck in a confusion loop.

No changeset: harness change, not a published file.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Repo-wide cleanup pass: every adopter-facing surface (skills,
docs, examples, test agents) and every internal JSDoc @example
that still imported createAdcpServer from @adcp/sdk or
@adcp/sdk/server now points at @adcp/sdk/server/legacy/v5 (the
only path that still exports it).

Convergent finding from four-expert review of the prior commits:
the dx-expert flagged that the matrix harness prompt itself
still taught the broken import — every matrix pair was being
told to write code that wouldn't compile. The harness prompt
is now path-agnostic (lets the skill drive) and includes
explicit guidance not to import createAdcpServer from the old
paths.

Migration doc: row 3 in the cheatsheet now reflects the actual
hard-removal (was previously documented as @deprecated
deferred-removal), and the sed example covers both old import
paths (@adcp/sdk and @adcp/sdk/server).

23 files changed: 5 docs + 3 skills + 1 migration doc + 9
internal JSDoc + 3 examples/test-agents + 1 matrix harness + 1
tsconfig (added subpath aliases for local typecheck).

888/888 server tests pass. test-agents typecheck clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ctx.store silently lost state across requests when adopters used the
documented serve(() => createAdcpServer({...})) factory pattern. Each
request invoked the factory, the destructuring default
`stateStore = new InMemoryStateStore()` evaluated per call, and the
brand-new in-memory store dropped every prior ctx.store.put.

Matrix v3 reproduced this with a textbook-perfect LLM-built SI agent:
si_initiate_session put session state in ctx.store; the next request's
si_send_message got null back and returned RESOURCE_NOT_FOUND. The
skill told adopters to use ctx.store; the framework lied about
persistence.

Module-singleton default fixes it. Adopters who write the obvious code
get cross-request persistence as the skills already promise.
Multi-tenant and production adopters always pass their own stateStore
(Postgres, Redis) so they're unaffected. Tests that need isolation
already opt into a fresh InMemoryStateStore explicitly.

Regression test in test/server-state-store-extensions.test.js: two
factory invocations must share ctx.store and a value put through one
must be readable through the other. Test fails on the broken default,
passes on the singleton fix. 889/889 server-side tests green.

Also hardens harness's killPort() to sweep orphaned `tsx adcp-agent-*`
zombies that survived a parent pkill against the matrix runner —
prevents cross-run port contamination that produced false
auth_required signals.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Matrix v2/v3 mystery solved. Three of four pairs reported
`auth_required` even though they wired `verifyApiKey` correctly.

Root cause: agents using `createAdcpServerFromPlatform` (v6 path)
throw at boot if `NODE_ENV` isn't `test` or `development` — the
default in-memory task registry refuses to mint outside those envs
to prevent silent task loss in production. The harness inherited the
parent shell's env (no NODE_ENV set) and spawned the agent without
overriding it. Every v6 agent's serve() factory then threw on first
request, serve.ts mapped the throw to 500, and the grader's status
detector reported the non-200 as `auth_required` (misleading but
explains the symptom).

Empirical confirmation: a v3 SI agent (v5 path, no TaskRegistry
requirement) curl'd OK with bearer auth and returned tools/list.
A v3 seller agent (v6 path) curl'd with the SAME bearer key
returned 500 + `buildDefaultTaskRegistry` stack trace pointing
at the env requirement.

Fix is one line in the harness's startAgent: pass
`NODE_ENV: 'development'` in the spawned process env.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Merge in main's three new commits (oneOf-cascade compaction, v3
request-shape validation, changeset reframe). Two conflicts:

- skills/call-adcp-agent/SKILL.md: main reformatted the
  Symptom→Fix table to compact-Markdown style; this branch added a
  '406 Not Acceptable' row pointing buyers at @modelcontextprotocol/sdk
  for the Streamable HTTP Accept-header requirement. Kept both —
  adopted main's compact format and inserted the 406 row in the same
  recovery-tier slot (between transient and correctable).
- src/lib/version.ts: generated `generatedAt` timestamp drift between
  the two branches' last builds. Re-ran `npm run sync-version` after
  resolving so the timestamp is fresh and reproducible.

267/267 tests pass on the merged code (state-store extensions,
decisioning from-platform, request validation, oneOf-cascade,
create-adcp-server). No semantic conflicts between main's validation
work and this branch's framework/skill/harness fixes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
CI's `npm run format:check` fails on prettier mismatches in 10 files
on this branch. Auto-formatted via `npx prettier --write`. Pure
formatting — no semantic changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley bokelley changed the title v6.0 GA preship deep fixes — root-cause patterns 1–6 + matrix harness fix: v6.0 GA preship deep fixes — root-cause patterns 1–6 + matrix harness Apr 30, 2026
bokelley and others added 4 commits April 30, 2026 17:09
The earlier `createAdcpServer` sweep edited `docs/llms.txt` directly,
but the file is regenerated from `scripts/generate-agent-docs.ts`.
CI's `npm run ci:docs-check` runs `generate-agent-docs` and diffs
against the committed file — every PR was failing because the
generator's source string still pointed at `@adcp/sdk` (the old,
removed import path).

Updated the source string in `generate-agent-docs.ts:537` to point
at `@adcp/sdk/server/legacy/v5` and regenerated. ci:docs-check now
passes locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
CI's `typecheck-skill-examples` job caught a syntax error in
skills/build-signals-agent/SKILL.md block #1: stray closing brace
plus broken indentation on the `signals: SignalsPlatform = {...}`
member. Cleaned up the indentation and removed the extra brace.

The fix exposed 5 pre-existing type errors in the same block that
the syntax error had been masking (the script classified the
broken block as a fragment instead of compiling it). Those errors
— `AccountStore.upsert/list` signature drift, `activateSignal`
return-type union vs `ActivateSignalSuccess`, `ctx.store` missing
on the v6 `Ctx`, and the `MySignals × DecisioningPlatform`
specialism-constraint failure — pre-date this branch and aren't
caused by the syntax fix. Baselined them via the script's
`--update-baseline` flag so the CI gate keeps catching new
regressions while the existing drift is tracked separately.

Filing a follow-up issue for the signals example type cleanup.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
LLMs read skills before writing code. The signals skill example
shipped with 5 type errors masked by a syntax error — adopters who
copied the example produced agents that didn't typecheck. Cleaned
each:

- accounts.upsert / accounts.list — both optional on AccountStore;
  omitted them. The framework returns UNSUPPORTED_FEATURE for
  buyers calling sync_accounts / list_accounts on stateless
  signal marketplaces.
- activateSignal returning adcpError(...) — return type is
  Promise<ActivateSignalSuccess>, errors throw. Switched to
  `throw new AdcpError('SIGNAL_NOT_FOUND', { recovery, message })`.
- ctx.store.put — v6 RequestContext has no `store` field. Replaced
  with a publisher-internal Map for the example. Multi-tenant
  publishers partition by ctx.account.id.

After fixes, baseline tightened: 212 → 207 entries (5 errors that
no longer reproduce in the signals example).

Multi-tenant footgun warn-once on default stateStore. The
module-singleton default is correct for single-tenant agents but
silently shares state across tenants in multi-tenant deployments.
createAdcpServer now emits a one-time logger.warn pointing
adopters at PostgresStateStore for production. Process-scoped
guard so factory-pattern adopters don't spam logs every request.
v6.0.1 plans to upgrade this to a NODE_ENV=production hard
refusal mirroring buildDefaultTaskRegistry.

Tests: two new cases in server-state-store-extensions —
warn-once behavior + no-warn when explicit stateStore. 42/42 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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