Skip to content

feat/agentcore 2 principal - #6772

Closed
kyleseaman wants to merge 2 commits into
feat/agentcore-1-governancefrom
feat/agentcore-2-principal
Closed

kyleseaman wants to merge 2 commits into
feat/agentcore-1-governancefrom
feat/agentcore-2-principal

Conversation

@kyleseaman

Copy link
Copy Markdown
Contributor

Problem / Motivation

Why it matters

What changed (motivation → approach → change)

Tests

Manual verification

Screenshots / video

Related Issues

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Partition SessionPrincipal as {surface}+{raw_id} at turn start.
Injected cron/subagent envelopes skip bind. Existing
publish_turn_identity callers that omit surface/raw_id stay
byte-identical. No Gateway attach or AWS in this slice.
CLI identity comes from the process UID or token SID, not
environment usernames. Automated turns omit raw_id and publish
after session acquire so a concurrent human principal is not
cleared mid-stream. Live-credential retract belongs to the later
Gateway layer.
@kyleseaman
kyleseaman requested review from a team and patrigao and removed request for a team August 29, 2026 11:39
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Aug 29, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Opened by accident while trying to rename the AgentCore stack off the cursor/ prefix. The live stack remains #6594–#6602. Closing this duplicate.

@kyleseaman kyleseaman closed this Aug 29, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🔴 BLOCK

Premise-level review of 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Verification is complete. All consumer counts were run against the merged HEAD checkout; the review follows.

First-Principles-Verdict: BLOCK

Dashboard/queue principal plumbing feeds _run_chat parameters the same PR pins as never used — a dead-by-design pipeline, deletable with zero observable change.

What this change ships

Intent: record which human is speaking on each session so a later AgentCore login/token-vending layer can act as that user — an ADDITION (stack part 2). The PR description is the untouched template: every item below is undeclared.

  1. DM/1:1 channel turns store {channel}+{user_id} on the live session — deferred consumer (stack); nothing reads it yet
  2. Group/unified/unattended turns stay unbound and clear leftover principal metadata — justified boundary logic, same deferred caveat
  3. CLI binds cli+{os account} onto an ad-hoc provider.principal attribute — zero consumers
  4. Dashboard/queue/rewind/regenerate/linked-Slack stamp identity into _run_chat, which ignores it — zero consumers, pinned dead
  5. _directive_user_origin now requires the positive is_dashboard_user claim, not "no app" — undeclared behavior change rides along
  6. Helper seams with no callers: clear_session_principal, retract_principal_credentials, inherit_parent_principal, derive_session_principal_for_injected, reject_tool_input_identity — zero consumers each
  7. CRON_NOTIFY_PREFIX/AUTO_NUDGE_PREFIX move into constants.py — justified (platform import layering)
  8. InboundMessage.bind_principal provenance flag; drain replays never bind the opener — justified within the scheme
  9. session.md/messaging.md describe subagent-inherit and tool-input rejection that no production code invokes — doc claims ahead of wiring
  10. Empty PR description — undeclared intent

Blockers

Dashboard principal stamping terminates in a sink the PR itself pins shut. Grepped _principal_surface|_principal_raw_id in chat_runner.py: consumed at exactly 2 places — the signature and a recursive self-forward (chat_runner.py:5092). The publish site says "Dashboard turns stay unbound" and calls publish_turn_identity(state.sessions, session_key) bare; test_linked_slack_surface_stays_unbound and test_chat_runner_does_not_bind_steer_capable_dashboard_turns pin that even stamped values are discarded, and session.md's own table says Dashboard is unbound for a security reason that forbids ever binding these turns. Zero option: delete dashboard_principal_kwargs, queue_bind_kwargs, consumed_queue_principal, the three _ChatSlot principal_* params, _run_chat's two params, and the ~9 call sites (chat_handlers, chat_regenerate, chat_rewind, openai_compat, slack/handler linked-thread) — every pinned behavior survives byte-identical.

Watch

  • The is_dashboard_user tightening of _directive_user_origin changes directive handling for loopback internal-secret callers — real hardening, but undeclared, and inconsistently applied: api_chat_slot_queue_edit (chat_handlers.py:3221 hunk) still derives it from not bool(request.get("app")).
  • The zero-consumer helper cluster (item 6; grepped each name in src/: 0 production callers apiece, two self-documented as "nothing calls it") plus SessionManager.retract_principal_credentials (an empty method) ships surface only the next stack PR uses — acceptable staging only if that PR is imminent; session.md meanwhile claims subagent inheritance and tool-input rejection that don't happen.
  • Channel binds and CLI bind write _Session.principal / provider.principal that nothing reads (get_principal: 0 production callers) — the declared stack consumer makes this deferred, not speculative, but nothing in this PR is exercisable.

Subtractions

  • Delete the dashboard plumbing named in the blocker (the blocker carries it).
  • Drop the message parameter of principal_bind_kwargs (agent_identity.py:137, first line del message) — every caller passes text it never reads; the function reduces to {"surface":…, "raw_id":…} if raw_id else {}.
  • Defer derive_session_principal_for_injected + is_injected_envelope + AUTO_NUDGE_PREFIX to the PR that consults them: grepped is_injected_envelope in src/ — its only caller is derive_session_principal_for_injected, whose production callers number 0; the bind path decides on raw_id alone.

[FIRST-PRINCIPLES-REVIEWED] 07a2ea0

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All the evidence is in. The channel-side design (core-derived subjects, fail-closed exclusivity, injected-envelope skip, annotate-not-replace) is coherent; the problems are the incomplete dashboard-bind reversal and a fail-open provenance default.

Design-Verdict: CONCERNS

Sound principal model, but commit 2's dashboard-bind reversal left the spec contradicting itself and orphaned identity plumbing the next stack PR will misread.

Watch

  • The spec tells two opposite stories about the dashboard. The new session.md table says "Dashboard | unbound", yet a later paragraph in the same section says "Dashboard chat (chat_runner._run_chat) binds surface="dashboard" … only when _directive_user_origin is true" — a leftover from the first commit that the second commit's reversal didn't update. Code matches the table: dashboard_principal_kwargs is harvested at ~8 call sites, stamped on queue items, threaded into _run_chat — and terminates in parameters nothing reads (_run_chat publishes without bind; get_principal has zero callers). The gateway-attach PR's author reads the wrong half and either assumes the dashboard binds or rewires the orphaned plumbing without re-litigating the multi-writer objection your own comment documents. Reconcile the spec to one story and either delete the dashboard harvest/thread or label it explicitly provenance-only.
  • The two bind gates fail in opposite directions. ChannelTurn.exclusive_principal defaults False (closed), but InboundMessage.bind_principal defaults True (open) — every future synthetic injector must remember to opt out, and a forgotten bind_principal=False on a DM-routed synthetic silently mints {channel}+{user_id} for machine-authored text, which becomes acting under that user's JWT once the credential layer lands. Prefer fail-closed: set it True only at the raw-webhook constructors.
  • The PR description is an entirely unfilled template for a 1.9k-line change to identity semantics across twelve surfaces; the design rationale exists only in commit bodies and code comments.

[DESIGN-REVIEWED] 07a2ea0

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 07a2ea0

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad — this comment is updated in place on each push.

Review details

Both candidates hinge on the same unconfirmed caller: a genuine human turn reaching the changed /api/chat (or /api/completions, regenerate, rewind, edit-resend, queue-edit) lines over the internal-secret loopback "person" path — the only path where token_auth leaves is_dashboard_user absent (token_auth.py:2231, no set before return await handler).

For every confirmed real caller the flip does not occur:

  • Browser dashboard users get is_dashboard_user=True on cookie auth (token_auth.py:2282/2368/2713), so dashboard_user_origin → True, matching old not bool(app).
  • App tokens set request["app"], so both predicates → False.
  • The peer/cross-session send flow calls _run_chat directly via handlers/session_control.py, which this diff does not change.

I opened mcp_core.py, loopback_http.py, cli_commands.py, and the send/peer handlers and could not derive a concrete production caller that posts a human directive-bearing turn to these endpoints via the internal-secret loopback path with no app and no cookie. Without that, candidate 1's outcome (user-surface directive refused) and candidate 2's outcome (edit-vs-append _directive_user_origin divergence) have no concrete input that occurs in practice — both resolve to "if a caller were to," which is the drop condition.

Separately, the dashboard principal-binding half has no current consumer: _run_chat publishes unbound unconditionally (chat_runner.py:5524, asserted by test_linked_slack_surface_stays_unbound), and set_principal only stores _Session.principal metadata that no shipped path reads (token vending is a later stack PR) — so even a mis-stamp produces no observable wrong outcome today.

No findings.

[OPUS-REVIEWED] 07a2ea0

Verdict parsed from the review's SHA-scoped output markers for commit 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 07a2ea0a6531d7ecdd6f60bd33eed006b2f8c1ad: <one-sentence reason>

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