Skip to content

feat(training-agent): implement sync_principal and get_principal - #7938

Merged
bokelley merged 2 commits into
mainfrom
conductor/33-ship-7056-7057
Oct 6, 2026
Merged

bokelley merged 2 commits into
mainfrom
conductor/33-ship-7056-7057

Conversation

@bokelley

@bokelley bokelley commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements the experimental principal layer (sync_principal / get_principal) on the /sales training agent so the universal/principal storyboard runs instead of resolving N/A, and implementers have a live reference.

Closes #7056

  • Identity comes only from authenticated transport (API key → buyer_agent, WorkOS user → operator). Anonymous callers get AUTH_REQUIRED (HTTP 401 at the route); principal_id/agent_url/etc. in the body are refused. principal_id is a hash, never a credential.
  • sync_principal: replace-by-section reporting_destinations and declarations; dry_run (no persistence); expected_configuration_version and expected_principal_kind fences (CONFLICT); idempotent replay; []/{} clearing; immutable destination generations (prior_destination_refs) and retired_destinations; input validated against sync-principal-request.json with credential screening of location; all-or-nothing validation before any write.
  • Reporting destination proof is simulated: an active destination reads back action_required (setup.action: prove_control) and becomes ready after 5s on read; active: false destinations skip proof and read inactive. No outbound probe, and no comply_test_controller scenario (controller-backed principal fixtures stay with Fixture-dependent conformance for agent configuration lifecycle #7010).
  • Declarations: declared set echoed verbatim; accepted intersection, selected_async_adcp_version, and exclusions computed against the training agent's own support.
  • get_principal: recognized before configuration (no record created), current afterwards.
  • Advertises adcp.principal and protocol.principal; both tools added to the tool catalog (sales, gated off 3.0-compat like sync_agent_notification_configs); sync_principal was already in the idempotency registry.
  • customToolFor no longer caches result.kind: "failed" outcomes as idempotent replays.

Judgment calls / deviations from the brief

  • notification_configs is not advertised in supported_sections (only reporting_destinations and declarations). The capability schema requires capability_changes.notifications.registration_task: sync_principal once that section is advertised, and the required-clean agent_notification_configs storyboard hard-asserts sync_agent_notification_configs. Flipping it needs a storyboard/spec decision, so webhooks stay on the specialized task and a notification_configs section is rejected with UNSUPPORTED_FEATURE. Follow-up: let that storyboard accept either task, then add the section here.
  • Used the notification-config custom-tool pattern (not SDK protocol slots): the sales tenant runs through createAdcpServerFromPlatform, which has no protocol block for it.
  • No principal.changed webhook is fired for the simulated action_required → ready transition, so principal.changed is not offered.
  • Every authenticated caller is a recognized principal (unconfigured is never returned). Every holder of the shared public sandbox token is one principal, and state is last-writer-wins across machines (same as sync_agent_notification_configs). Documented in the file header.
  • No changeset: training-agent-only (check-changeset-protocol-scope passes).

Testing

  • npx vitest run server/tests/unit/training-agent-principal.test.ts (32 tests, incl. the customToolFor wrapper) and training-agent-agent-notification-configs.test.ts: pass.
  • universal/principal storyboard against local /sales: 11/11 steps, clean (all phases). agent_notification_configs storyboard still clean (3/3).
  • npm run typecheck; training-agent tool-catalog drift / dispatch smoke / account-change-feed / tenant URL tests pass. tenant-smoke "controller-seeded media buys" times out here but also fails on a clean origin/main in this sandbox.
  • Local pre-commit hook was bypassed once: fixed-trace-rollout-typecheck-wiring runs a full tsc against a hard-coded 30s limit and takes ~40s in this sandbox. The other hook steps were run by hand. The storyboard matrix is left to the authoritative CI workflow.

Follow-ups

🤖 Generated with Claude Code


Open workspace in Conductor

Adds the experimental principal layer to the /sales training agent so the
universal/principal storyboard executes instead of resolving N/A.

- Principal is resolved only from authenticated transport (API key ->
  buyer_agent, WorkOS user -> operator); anonymous callers get AUTH_REQUIRED
  and identity fields in the body are refused.
- sync_principal: replace-by-section reporting_destinations and declarations,
  dry_run, expected_configuration_version / expected_principal_kind fences,
  idempotent replay, section clearing, destination generations and retired
  destinations, schema-validated input with secret screening.
- Reporting destination proof is simulated: active destinations read back
  action_required, then ready; inactive destinations skip proof.
- get_principal: recognized identity before configuration, current readback
  after, including the declarations accepted intersection.
- Advertises adcp.principal and protocol.principal. notification_configs stays
  on sync_agent_notification_configs for now.
- customToolFor no longer caches kind: failed results as idempotent replays.

Co-Authored-By: Claude Sonnet 5.5 <[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 — clean additive experimental principal layer, no blocking or medium findings.

What I checked:

  • Changes are confined to server/src/training-agent/** (app-only). No static/schemas/source/**, docs/reference/**, dist/**, or migrations touched — so changeset, schema↔docs coherence, oneOf-discriminator, immutable-artifact, and 3.1.x patch-eligibility gates do not apply. App-only, no changeset required (correct).
  • normalizeLocation (principal.ts:193) implements the agent-reporting-destination normalization spec-faithfully (NFC, lowercase scheme+authority, canonical path separators, ASCII-authority rejection); carriesSecret covers the userinfo secret_rejection rule.
  • Request/response/capability shapes validate against sync-principal/get-principal/principal-state and the adcp.principal block (additionalProperties:false, required companions present).
  • Idempotency precedes the version fence; the custom-tool-helper failedResult guard correctly avoids caching kind:'failed' so a stale CONFLICT re-executes on retry, scoped to the new tool only.
  • hasActiveSubscriber reads the same session+documentId written by sync_agent_notification_configs; principalConfigurations wired into createSession/serialize/deserialize per the Map-field invariant. No external I/O, no timeout surface. Breaking-class: none (additive experimental surface).

Gate evaluation: No critical/high/medium findings (row 1 n/a). gated_paths: false (row 2 n/a) — review_decision: REVIEW_REQUIRED is irrelevant without a gate. high_risk: false (rows 3,5 n/a). No data-loss/schema/infra medium (row 4 n/a). No prior decision (row 6 n/a). No no-auto-approve team match (row 7 n/a). Zero medium findings (row 8 n/a). Falls through to row 9 → approve.

@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 — clean pass, no blocking or medium findings.

This PR adds an experimental, sales-tenant-only principal layer (sync_principal/get_principal) for the training agent reference seller, plus session storage, capability advertisement, and a scoped idempotency fix. The change is purely server/** platform code — no schema source, changeset surface, oneOf, or released-artifact changes — so none of the AdCP spec-governance hard gates apply.

Reviewed highlights:

  • Identity resolved only from transport; request-body identity fields rejected (principal.ts:227-229, 478-484).
  • Sections validate before any write; every failed(...) return precedes session.principalConfigurations.set (principal.ts:642), so the now-uncached kind:'failed' idempotency retry (custom-tool-helper.ts:689-690) cannot double-write.
  • Cross-task subscriber coherence uses the shared caller key + document id (principal.ts:437-446).
  • asSets/normalizeDestination read array/required fields only after schema validation, so no undefined-deref crash.

Gate checks: high_risk false; gated_paths false; review_decision APPROVED; no no-auto-approve team match. No critical/high/medium findings. Prior decision was also approve. Falls through to decision table row 9.

@bokelley
bokelley merged commit 838ff39 into main Oct 6, 2026
50 checks passed
@bokelley
bokelley deleted the conductor/33-ship-7056-7057 branch October 6, 2026 15:14
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: implement the principal layer (sync_principal / get_principal)

1 participant