Skip to content

fix(training-agent): report platform activations in get_signals readback - #7769

Merged
bokelley merged 2 commits into
mainfrom
fix/signals-readback-platform-deployments
Sep 29, 2026
Merged

bokelley merged 2 commits into
mainfrom
fix/signals-readback-platform-deployments

Conversation

@bokelley

@bokelley bokelley commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7767

Root cause

handleGetSignals (server/src/training-agent/task-handlers.ts) built each signal's deployments from a single session.signalActivations.get(${segmentId}:${getAgentUrl()}) lookup. The lookup only matched an activation to the training agent's own agent URL. activate_signal stores a platform destination under ${segmentId}:${platform}, so it was never found. Readback therefore always returned the not-live agent deployment. That fails signal_marketplace/governance_approved at get_signal_deployment_readback, which activates to { type: "platform", platform: "pinnacle-dsp" } and then checks signals[0].deployments[0].is_live and activation_key.

The storyboard is correct: deployments[] is where a signal is deployed (docs/signals/tasks/get_signals.mdx), and core/deployment.json has a platform variant. The fix is in the agent, and the storyboard is unchanged.

Fix

  • get_signals readback: reports every live activation of the signal from the caller's session. Each entry has the core/deployment.json fields for its variant: type, platform or agent_url, account when set, is_live: true, activation_key, and deployed_at. The most recent activation is at deployments[0]. The agent's own deployment is still appended, not live, with estimated_activation_duration_minutes: 0, when nothing activated it. The output is byte-identical to before for a signal that was never activated or was activated only on the agent's own URL.
  • Isolation: readback reads only the session that activate_signal wrote to. Both use the same sessionKeyFromArgs derivation, so this change doesn't widen what a caller can see. A new test checks that one account's platform activation doesn't show up in another account's readback.
  • activate_signal key: activations are now keyed per destination account (${segment}:${destination}#${account}). Two seats on the same platform become two deployments instead of one overwriting the other. Destinations without an account keep the old key shape. Activation and deactivation match stored entries by their recorded segment, destination type, destination id and seat account, not by key. An activation persisted under the older key shape is therefore replaced on re-activation and removed on deactivation, never orphaned or duplicated.
  • activate_signal guard: returns INVALID_REQUEST (field: destinations[i].platform or agent_url) for an empty destination identifier. Previously a platform destination with an empty platform was stored under the agent URL with destinationType: 'platform'. The new readback would have exposed that as a corrupt deployment.
  • The the-trade-desk fixture in the platform-destination test is renamed to pinnacle-dsp, per the fictional-names rule.

This changes only the training agent. There are no schema, task-definition or normative-doc changes, so there's no changeset (check-changeset-protocol-scope.cjs passes).

Tests

New in server/tests/unit/training-agent.test.ts (activate_signal handler):

  • activated platform signal shows is_live true in subsequent get_signals: the issue's repro. It activates shopgrid_category_buyer to pinnacle-dsp/acme-seat, then asserts the exact platform deployment at [0] and that the not-live agent deployment is still reported.
  • reports every live deployment, most recent first, and drops deactivated ones: an agent activation plus two seats on one platform, in most-recent-first order. After one seat is deactivated, only the other seat and the agent remain.
  • replaces and deactivates platform activations persisted under the legacy account-less key: persisted-session compatibility. It fails when the destination matcher is disabled.
  • does not report one account's platform activation in another account's readback: the cross-account isolation check.
  • rejects a platform destination without a platform identifier.

Three of the new tests fail on main. The isolation test passes on both, which is expected because it guards against a regression.

Local runs:

  • npx vitest run --config server/vitest.config.ts src/ tests/unit/training-agent tests/unit/comply-test-controller.test.ts tests/unit/storyboards.test.ts: 39 files, 1526 tests passed
  • npm run typecheck: passed
  • node --test tests/test-coverage-registration.test.cjs: 3/3 passed
  • The pre-commit server-unit shards passed

Storyboards (TENANT_PATH=signals, dist/compliance/latest)

Storyboard Before (main) After
signal_marketplace 8P 8P
signal_owned 5P 5P
signals_baseline 4P 4P
signals_baseline/get_signals_async 9P 9P
signal_marketplace/governance_approved (unrouted) 0P/1S 0P/1S
signal_marketplace/governance_denied 4P 4P
get_signals_pagination_integrity 5P 5P
schema_validation_signals 5P 5P
error_compliance_signals 9P 9P
wholesale_feed_signals 5P 5P
wholesale_feed_signals_scope_isolation 4P 4P

No single-tenant storyboard reads back a platform activation today, so the unit tests are the direct regression guard.

Routed check with #7768's harness (local only, nothing pushed to #7768)

I applied #7768's storyboard-runner-options.ts and run-storyboards.ts changes locally and uncommitted, then ran signal_marketplace/governance_approved:

Setup Without this fix With this fix
Routed, @adcp/[email protected] as is 3P/1F/3S 3P/1F/3S
Routed, with diagnostic bypasses for adcp-client#3061 and #3062 6P/1F: get_signal_deployment_readback fails with "Expected true, got false" and "Field not found at path: signals[0].deployments[0].activation_key" 7P, clean

On rc.50 as is, the governance steps are skipped (adcp-client#3061), so activate_signal_approved never runs and the readback has nothing to find. The fix can't change that row.

The bypasses were diagnostic only and were reverted afterwards:

  • For adcp-client#3061, I dropped the storyboard's root requires_capability in the local dist/compliance/latest copy.
  • For adcp-client#3062, I stripped adcp_version/adcp_major_version before the agent's payload-hash recompute.

With both bypasses in place, get_signal_deployment_readback is the only remaining failure, and this PR fixes it.

Out of scope, noticed

report_usage validates signal_agent_segment_id with session.signalActivations.get(segmentId), but activations are keyed ${segment}:${destination}, so that lookup can't match. It's unchanged here and worth its own issue.

🤖 Generated with Claude Code

get_signals built each signal's deployments from a single point lookup
keyed on the training agent's own agent URL, so an activation to a
platform destination (or any other agent) was never reported. That
fails signal_marketplace/governance_approved at
get_signal_deployment_readback once the storyboard runs routed.

Readback now projects every live activation of the signal recorded in
the caller's account-scoped session, most recent first, with the
agent's own deployment still reported (not live) when nothing activated
it. activate_signal keys activations per destination account so two
seats on one platform are distinct deployments, and rejects platform or
agent destinations with an empty identifier instead of storing them
under the agent URL.

Closes #7767

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Sep 29, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — training-agent fix for get_signals readback missing platform activations.

The change makes the readback iterate the account-scoped session, filter live activations, and conform to core/deployment.json. The fix is well-tested (server/tests/unit/training-agent.test.ts) and touches only server-side task-handler logic — no protocol surface (static/schemas/source/), no docs/reference/, no dist artifacts, and no changeset-requiring surface, so no changeset is needed.

Medium findings

  • server/src/training-agent/task-handlers.ts — activation-key-shape change silently no-ops deactivation for session state persisted before the deploy (non-blocking, single medium).

Only one medium finding, no blocking (critical/high) findings, high_risk is false, gated_paths is false, and the author is not on a no-auto-approve team. Rows 1–8 do not fire (a single medium is below the 3-medium threshold and is not in a data-loss/schema/infra category), so the outcome falls through to row 9: approve.

… shape

Sessions persist across deploys, so an activation stored under the older
account-less key would survive a deactivate issued under the new
per-seat key, and a re-activation would duplicate it in readback.
activate_signal now replaces and removes stored activations by their
recorded segment, destination type, destination id, and seat account.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve

PR #7769 fixes get_signals readback to report platform activations in the sandbox training agent, touching only server/src/training-agent/task-handlers.ts and its unit test. No schema, task-definition, or normative-doc surface is modified, so the absent changeset is correct per the changeset-scope rule.

Reviewer confirmed a clean pass — no Critical/High/Medium findings. Verified: readback correctness, account-scoped multi-tenant isolation, empty-identifier guard, legacy-key migration, and the fictional-names rename.

Gate checks:

  • No no-auto-approve team match (row 7 does not fire).
  • gated_paths: false — row 2 does not apply even though review_decision is REVIEW_REQUIRED.
  • high_risk: false — rows 3/5 do not apply.
  • No medium findings — rows 4/8 do not apply.
  • Prior decision was approve — row 6 does not apply.

None of rows 1–8 fire; falls through to row 9 → approve.

@bokelley
bokelley merged commit 843f56c into main Sep 29, 2026
52 checks passed
@bokelley
bokelley deleted the fix/signals-readback-platform-deployments branch September 29, 2026 22:34
bokelley added a commit that referenced this pull request Sep 30, 2026
…vations (#7773)

report_usage validated signal_agent_segment_id with
session.signalActivations.get(segmentId), but activate_signal stores
activations under `${segment}:${destination}` (and, since #7769,
`${segment}:${destination}#${seat}`). The bare-segment lookup never
matched, so usage for any activated signal was rejected with
SIGNAL_NOT_FOUND.

report_usage now matches stored activations by their recorded segment
through the same signalActivationMatches helper activate_signal uses for
replacement and deactivation. A usage record identifies a signal only by
account and segment (the schema has no destination field), so any live
deployment of the segment in the record's account session satisfies it.
Unknown, deactivated and other-account segments keep the same uniform
SIGNAL_NOT_FOUND.

Co-authored-by: Claude Opus 5.5 (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.

Training agent get_signals readback omits platform-destination activations, so signal_marketplace/governance_approved readback fails

1 participant