-
Notifications
You must be signed in to change notification settings - Fork 9
Agent identity: session tokens, Bearer-only API, honest history attribution #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HamptonMakes
wants to merge
2
commits into
main
Choose a base branch
from
hampton/agent-token-identity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
db/migrate/20260815170755_add_session_minting_to_coplan_api_tokens.co_plan.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # This migration comes from co_plan (originally 20260815000000) | ||
| class AddSessionMintingToCoplanApiTokens < ActiveRecord::Migration[8.1] | ||
| def change | ||
| # Session tokens are minted from a long-lived parent token, so a machine | ||
| # keeps one secret and each agent run gets its own short-lived identity. | ||
| # Revoking the parent has to revoke everything it minted, hence the link. | ||
| # | ||
| # Guarded: databases set up via db:schema:load while main's schema.rb | ||
| # carried these columns without a migration (and dev databases that ran | ||
| # the agent-collaboration branch) already have them. | ||
| unless column_exists?(:coplan_api_tokens, :parent_id) | ||
| add_column :coplan_api_tokens, :parent_id, :string, limit: 36 | ||
| end | ||
| unless index_exists?(:coplan_api_tokens, [:parent_id, :revoked_at]) | ||
| add_index :coplan_api_tokens, [:parent_id, :revoked_at] | ||
| end | ||
| unless foreign_key_exists?(:coplan_api_tokens, column: :parent_id) | ||
| add_foreign_key :coplan_api_tokens, :coplan_api_tokens, column: :parent_id | ||
| end | ||
|
|
||
| # Which agent this token speaks for ("Claude", "Amp"). Attribution rows | ||
| # written with the token inherit it, the same way comments carry a | ||
| # per-comment agent_name. | ||
| unless column_exists?(:coplan_api_tokens, :agent_name) | ||
| add_column :coplan_api_tokens, :agent_name, :string | ||
| end | ||
| end | ||
| end |
12 changes: 12 additions & 0 deletions
12
db/migrate/20260815170756_add_agent_name_to_plan_history.co_plan.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # This migration comes from co_plan (originally 20260815000001) | ||
| class AddAgentNameToPlanHistory < ActiveRecord::Migration[8.1] | ||
| def change | ||
| # Comments already record which agent acted for a user (author_id is the | ||
| # human, agent_name is the agent). Versions and events stored only | ||
| # actor_type, so the history tab rendered an agent's edit as the human's. | ||
| # Existing rows stay nil — they were written before the distinction was | ||
| # captured and cannot be attributed retroactively. | ||
| add_column :coplan_plan_versions, :agent_name, :string | ||
| add_column :coplan_plan_events, :agent_name, :string | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # This migration comes from co_plan (originally 20260815000002) | ||
| class AddAgentProvenance < ActiveRecord::Migration[8.1] | ||
| def change | ||
| # Identity facts (harness, harness version, model, …) live on the token, | ||
| # captured at mint time — schemaless, because the set of facts worth | ||
| # recording grows faster than anyone wants to migrate three tables. | ||
| add_column :coplan_api_tokens, :metadata, :json | ||
|
|
||
| # Attribution rows keep agent_name as the display string, and point at | ||
| # the token for everything else. actor/author stays the human. | ||
| add_column :coplan_plan_versions, :api_token_id, :string, limit: 36 | ||
| add_column :coplan_plan_events, :api_token_id, :string, limit: 36 | ||
| add_column :coplan_comments, :api_token_id, :string, limit: 36 | ||
|
|
||
| add_index :coplan_plan_versions, :api_token_id | ||
| add_index :coplan_plan_events, :api_token_id | ||
| add_index :coplan_comments, :api_token_id | ||
|
|
||
| add_foreign_key :coplan_plan_versions, :coplan_api_tokens, column: :api_token_id | ||
| add_foreign_key :coplan_plan_events, :coplan_api_tokens, column: :api_token_id | ||
| add_foreign_key :coplan_comments, :coplan_api_tokens, column: :api_token_id | ||
| end | ||
| end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a Bearer-authenticated agent calls
POST /api/v1/plans,PlansController#createstill invokesPlans::Createwith onlyuser, and that service hardcodes version 1 asactor_type: "human"without anagent_name. Consequently, every agent-created plan permanently attributes its initial content to the human, contradicting the new identity model and the documented promise that every version is stamped; passapi_author_type,api_user_id, andapi_agent_namethrough the creation path as well.AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.