feat(api): persist bound capability Run provenance#320
Merged
Yevanchen merged 2 commits intoJul 15, 2026
Merged
Conversation
AsperforMias
requested review from
KurosawaGeeker,
Yevanchen and
samzong
as code owners
July 14, 2026 15:37
3 tasks
3 tasks
Yevanchen
force-pushed
the
feat/bound-capability-run-provenance
branch
from
July 15, 2026 07:58
32ddfb4 to
401f6eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fix(api): revoke bound deployment capabilities). This is a stacked PR: it must be reviewed and merged after fix(api): revoke bound deployment capabilities #317. Its current comparison includes fix(api): revoke bound deployment capabilities #317 ancestry; after fix(api): revoke bound deployment capabilities #317 merges, the effective diff is the two commits in this PR.INSERT INTO session_run ... SELECT ... RETURNINGstatement that accepts the Run.Why
#317 makes the final Run insertion the authorization linearization point for a bound capability. Before this PR, a successfully accepted owner-billed Run did not retain the Deployment and binding that authorized it. Logs are not a durable billing/audit record: they may be sampled, expire, or be unavailable during an incident.
The provenance is a Run-level snapshot rather than Session metadata because one Session can contain multiple Runs. It contains no capability URL or signed bearer token.
Implementation
session_runcolumns through generated migration0001_bound-capability-run-provenance.sql; existing Runs remain readable withNULLprovenance.boundCapabilityRunProvenance(appId, runId), guarded by existing App ownership checks. Legacy/non-bound Runs returnnull; malformed partial snapshots fail closed.Verification
just db-reset-localjust test-file apps/api/tests/app-agent-bound-run-revocation.test.ts(4 pass, 0 fail)just test-file apps/api/tests/app-agent-capability-revocation-http.test.ts(5 pass, 0 fail)just test-package @mosoo/api(981 pass, 0 fail)just tc-package @mosoo/apijust tc-package @mosoo/dbjust graphql-codegen-checkjust checkgit diff --check0001migration to local Wrangler D1 and inspected the resultingsession_runcolumns.FORBIDDEN.session_runremained empty, so neither a Run nor provenance can be left behind.nullprovenance.Impact
null.ADD COLUMNoperations. The shipped0000_baseline.sqlis unchanged.Review
apps/api/src/modules/runtime/infrastructure/session-runs/session-run-write.repository.tsapps/api/src/modules/public-api/bound-capability-run-provenance.service.tspkgs/db/drizzle/0001_bound-capability-run-provenance.sqlapps/api/tests/app-agent-bound-run-revocation.test.ts