Skip to content

fix(platform): shim the credential broker for work-lane agent turns - #3128

Merged
larryro merged 1 commit into
mainfrom
fix-agent-turn-credential-broker-shim
Sep 2, 2026
Merged

larryro merged 1 commit into
mainfrom
fix-agent-turn-credential-broker-shim

Conversation

@larryro

@larryro larryro commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Configuring a GitHub credential in Settings → Connectors and granting github on an automation (or task) agent's skills menu still left the agent with no credentials at run time — it would report it has no GitHub access.

Root cause

The config chain was intact end to end (SkillsMenu → node.connectors → stepper request → host → resolveTurnEquipmentEnv). The break was in the shim layer: the Tier-2 credential broker (core/node_only/sandbox/session_credentials.ts) makes three ctx calls, and none of them were answered by the agent-turn shim family (agentTurnShimHandlers ⊃ sandboxToolShimHandlers) both work lanes run under:

  • connector_credentials/queries:resolveCredentialRefInternal — only the conversations lane had a handler, and it returns an identity subset without the encrypted envelope, unusable for the decrypt path
  • sandbox/session_mutations:recordCredentialAccess — no handler anywhere
  • sandbox/session_queries:getSessionOwnerIdentity — no handler anywhere

The [ctx-shim] un-shimmed throws never surfaced because the equipment resolver deliberately downgrades broker failures to warnings (a credential gap must not kill a turn) — so every granted turn silently ran with an empty env overlay. Same failure shape as #3126: each half was tested, the chain was not, and the existing guard only walks the bridge entry points, not the turn-equipment entry.

Fix

  • domains/sandbox/shim.ts — add the three handlers beside the agent-secrets one: the full 0.4-shaped credential row (nullable columns become absent fields) via a new null-returning findCredentialForRef, the sandbox_credential_access audit insert (table shipped in migration 0017; agent secrets already write to it), and the session owner's git identity off the latest live session row (a synthetic system:automation owner resolves to null, as in 0.4).
  • domains/connector_credentials/service.ts — export findCredentialForRef; loadRowForResolve becomes a thin throwing wrapper over it.
  • domains/sandbox/shim.test.ts — parameterize the import-graph walker and add a second guard: every internal.* name reachable from core/node_only/sandbox/turn_equipment.ts must have a handler in agentTurnShimHandlers. This class of gap now fails in CI instead of shipping as a silent downgrade.
  • integration-check.ts — checkTurnEquipmentBroker: on real Postgres, a stored github bearer credential + a granted github connector resolve through the automation shim into GITHUB_TOKEN/GH_TOKEN, the git credential-helper env, the owner's git author identity (GIT_CONFIG_COUNT=3), and exactly one github/git audit row; an ungranted turn injects nothing.

Verification

  • bun run check 40/40; shim guard tests 4/4; backend integration 279/279 (was 277 — the two new checks).
  • Live E2E on the dev stack: a real GitHub PAT stored through the settings door, a one-node automation (type: agent, connectors: ["github"]) started in live mode — the run settled success with the agent replying GITHUB_OK:<login> from gh api user, the audit row landed, and the backend log shows zero broker warnings. The task lane heals with the same change (same handler family).

A github connector granted to a task or automation agent injected no
GITHUB_TOKEN: the Tier-2 broker's three ctx seams
(resolveCredentialRefInternal, recordCredentialAccess,
getSessionOwnerIdentity) were un-shimmed in the agent-turn handler
family, and the equipment resolver swallows broker failures into
warnings by design — so every granted turn ran without credentials and
the agent reported it had none.

Shim all three onto the 0.5 domain services (full credential row for
the reused decrypt path, the sandbox_credential_access audit insert,
and the session owner's git identity), add a turn-equipment
import-graph guard beside the bridge one, and prove the chain on real
Postgres: a stored github bearer credential resolves into
GITHUB_TOKEN/GH_TOKEN, the git credential helper env, the owner's git
identity, and one audit row.
@larryro
larryro merged commit 6eed31e into main Sep 2, 2026
48 checks passed
@larryro
larryro deleted the fix-agent-turn-credential-broker-shim branch September 2, 2026 03:28
Israeltheminer added a commit that referenced this pull request Sep 3, 2026
Three legs the port left returning nothing, each under a comment saying no
0.5 table existed. All three tables existed.

kind="website" answered []. Migration 0045 created app.websites with every
column 0.4's reader projected, and listWebsites already existed.

kind="mail-attachment" answered {attachments: [], truncated: false}, while
migration 0037 shipped conversation_id and mail_received_at_ms and the email
binder writes both. truncated:false means "the walk reached the end of the
mail index", so the stub was also making a false claim. The new reader gates
every row on conversationAssignmentAllows against the conversation's current
assignment, resolving the caller's role and team ids rather than taking them
as arguments — a listing that skipped that would serve the whole inbox.

Migration 0064 adds the arrival index. The only existing index leads with
conversation_id, so it orders by conversation, which is the shape #3035
recorded as rejected: a by-arrival page reads most of its budget to return
one row, and above the budget reports "most recent" from an arbitrary window.

The task and project legs also lost their zero-hit listing fallback, leaving
listedSource unreachable. Restored in both.

Adds the reachability gate the chat map never had: every internal ref
reachable from the turn now needs a handler, using the walker the sandbox
bridge already had rather than a second copy. That absence is how #3112's
and #3128's missing handlers shipped.
Israeltheminer added a commit that referenced this pull request Sep 3, 2026
Three legs the port left returning nothing, each under a comment saying no
0.5 table existed. All three tables existed.

kind="website" answered []. Migration 0045 created app.websites with every
column 0.4's reader projected, and listWebsites already existed.

kind="mail-attachment" answered {attachments: [], truncated: false}, while
migration 0037 shipped conversation_id and mail_received_at_ms and the email
binder writes both. truncated:false means "the walk reached the end of the
mail index", so the stub was also making a false claim. The new reader gates
every row on conversationAssignmentAllows against the conversation's current
assignment, resolving the caller's role and team ids rather than taking them
as arguments — a listing that skipped that would serve the whole inbox.

Migration 0070 adds the arrival index. The only existing index leads with
conversation_id, so it orders by conversation, which is the shape #3035
recorded as rejected: a by-arrival page reads most of its budget to return
one row, and above the budget reports "most recent" from an arbitrary window.

The task and project legs also lost their zero-hit listing fallback, leaving
listedSource unreachable. Restored in both.

Adds the reachability gate the chat map never had: every internal ref
reachable from the turn now needs a handler, using the walker the sandbox
bridge already had rather than a second copy. That absence is how #3112's
and #3128's missing handlers shipped.
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