Skip to content

docs(agents): add AGENTS.md carrying the authorization rules PRs most often break - #209

Open
beardthelion wants to merge 3 commits into
mainfrom
docs/agents-md
Open

docs(agents): add AGENTS.md carrying the authorization rules PRs most often break#209
beardthelion wants to merge 3 commits into
mainfrom
docs/agents-md

Conversation

@beardthelion

@beardthelion beardthelion commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Adds a root AGENTS.md written for coding agents and human contributors alike, plus a pointer from CONTRIBUTING's PR guidelines. It carries only what a patch author cannot recover from the code alone: the owner-gate forms in use and the write routes that are non-owner by design, the path argument contract on authorize_repo_read, denial semantics, the deny-test expectations for new and removed routes, migration versioning, client denial surfacing, and what CI actually blocks on vs what is convention.

Two ground rules held while writing it: every named identifier, test, and CI claim was checked against current main, so the enforcement labels describe only what is merged today; and nothing already covered by README, CONTRIBUTING, SECURITY, or the PR template is repeated. The deny suite in review (#194, #195) is referenced with wording that stays true whether or not it has landed in a given checkout.

Docs-only: no runtime impact, no code or CI changes.

Summary by CodeRabbit

  • Documentation
    • Added a new coding-agent contributor guide covering authorization invariants, required denial-behavior tests for serving-path changes, signature/certificate verification checks, and operational rules for handling database migrations. It also documents expected client behavior when access is denied.
    • Updated the contribution guidelines to direct contributors to review the new authorization guidance before modifying endpoints, visibility, or migration workflows.

… often break

Encode the contributor-facing gate rules (the three owner-gate forms in
use and the by-design non-owner exceptions, path-scoped reads and the
listings contract, denial semantics, deny-test expectations, migration
versioning, client denial surfacing, MSRV and the exact CI gate set) in
a root AGENTS.md that coding agents load automatically, and point
CONTRIBUTING.md at it. Enforcement labels state only what is on main
today.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 332d8f1e-2958-4e2e-bbe3-62a170351837

📥 Commits

Reviewing files that changed from the base of the PR and between 8397a4a and e3f7d2d.

📒 Files selected for processing (1)
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • AGENTS.md

📝 Walkthrough

Walkthrough

Added AGENTS.md with authorization, serving-path, migration, denial-handling, and CI guidance. Updated CONTRIBUTING.md to require consulting it for endpoint, visibility, or migration changes.

Changes

Contributor security guidance

Layer / File(s) Summary
Security-surface contribution rules
AGENTS.md, CONTRIBUTING.md
Documents authorization invariants, route and denial-test requirements, signature verification, migration and client-denial rules, toolchain constraints, and the related pull request guideline.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related issues

  • Gitlawb/openclaude/1716 — Both changes update contributor guidance requiring review of AGENTS.md and CONTRIBUTING.md before pull requests.

Suggested labels: kind:docs

Suggested reviewers: jatmn

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning It covers summary and context, but misses most required template sections like kind of change, what changed, verification, and checklist. Rewrite the PR description using the repository template, including Kind of change, What changed, verification steps, and the Before you request review checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the docs-only addition of AGENTS.md plus a CONTRIBUTING pointer.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/agents-md

Comment @coderabbitai help to get the list of available commands.

@beardthelion beardthelion added the kind:docs Docs and comments only label Jul 16, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Line 18: Update the gated-handler testing guidance in AGENTS.md to require
denial tests based on each route’s authorization rule, rather than universally
requiring non-owner denial. Preserve non-owner tests only where non-owners are
unauthorized, and require tests for the identities that are actually
unauthorized for routes such as star_repo, replica actions, bounty actions, and
author-based closing, including exact denial statuses and non-leaking response
bodies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8c09ced-f890-411f-b65c-135fe8150aca

📥 Commits

Reviewing files that changed from the base of the PR and between ad7c2b2 and 4963910.

📒 Files selected for processing (2)
  • AGENTS.md
  • CONTRIBUTING.md

Comment thread AGENTS.md Outdated

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found issues that need to be addressed before this is ready.

Findings

  • [P1] Make the denial-test instruction match each route's actual authorization policy
    AGENTS.md:18
    This tells every new gated handler to reject a signed non-owner, but several routes documented immediately above intentionally authorize non-owners: any reader may star a readable repo, replica registration is bound to the replica DID, and bounty/close actions have their own role policies. A contributor following this mandatory rule will either assert denial for a valid request or add an incorrect owner gate to make the test pass, while potentially missing the identity that is actually unauthorized. Require denial cases based on the handler's specific authorization rule (retaining non-owner denial for owner-only routes), alongside the applicable anonymous/no-leak assertions.

  • [P2] Do not describe the repo-scoped read guard as covering handlers it explicitly exempts
    AGENTS.md:7
    The new invariant says every repo-scoped endpoint binds a caller before serving data, but authz_guard::every_repo_scoped_handler_is_gated currently exempts list_webhooks, list_replicas, and list_protected_branches in known_ungated; each handler only looks up the repo and returns its metadata. The following description of the guard does not name those live exceptions, so this security guide presents the existing private-repo metadata exposure as protected. Either land the gates, or call out the exact tracked exceptions and keep contributors from treating those surfaces as safe.

  • [P2] Correct the statement that the listed CI jobs block merges
    AGENTS.md:37
    The live main ruleset requires one approving review but has no required-status-check rule; the branch-protection API likewise has no required checks. The PR workflow does run the listed jobs, but a failing job does not itself block a merge under the current repository rules. Since this section is explicitly presented as CI reality, describe these as workflow checks (or make them required) rather than telling contributors they are merge-blocking.

Scope the denial-test guidance to each route's actual authorization
rule instead of a blanket non-owner assertion, since several
documented routes (star_repo, replica actions, bounty actions,
author-based closing) intentionally authorize non-owners.

Name the known_ungated exceptions (list_webhooks, list_replicas,
list_protected_branches) instead of implying full repo-scoped read
coverage.

Describe the listed jobs as workflow checks that run on every PR
rather than merge-blocking CI, matching the live main branch ruleset
(one required review, no required status checks).
@beardthelion

Copy link
Copy Markdown
Collaborator Author

Fixed in 8397a4a:

  • Line 18: reworded to scope the denial-test requirement per route instead of a blanket non-owner assertion, so it no longer contradicts star_repo/replica/bounty/close-action routes (used CodeRabbit's proposed wording).
  • Line 7: named the three known_ungated exceptions (list_webhooks, list_replicas, list_protected_branches) instead of implying full coverage; verified against the current authz_guard::every_repo_scoped_handler_is_gated allowlist.
  • Line 37: reworded to describe the listed jobs as workflow checks that run on every PR, not merge-blocking, matching the live main ruleset (one required review, no required status checks).

@beardthelion
beardthelion requested a review from jatmn July 24, 2026 21:34
Three rules a patch author cannot recover from the code alone, all three
found by review rounds on #224 and #236:

Anchor the verifying key outside the artifact. Deriving it from a field of
the object under verification proves self-consistency, not authenticity,
and identities here are permissionless. Found on #236 in the gl client and
again on #224 in the server-side twin, where a self-signed certificate
verified against an unauthenticated route.

Drive the accepting verdict in a test. #224's verify endpoint shipped with
sixteen tests, every one asserting the invalid path, which left it unable
to observe a forged artifact being accepted.

Treat a signed payload's field set as a versioned format. #224 grew it from
seven fields to thirteen with no discriminator and no fallback, so every
certificate issued before it now reports as tampered.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found issues that need to be addressed before this is ready.

Findings

  • [P1] Make the forged-certificate case a rejection test
    AGENTS.md:25
    This requires a handler to return valid for a well-formed but forged artifact, even though the preceding rule correctly says that an artifact self-signed by the DID it names must fail the independent issuer-anchor check. It also reverses the test rationale: invalid-only cases miss an implementation that rejects everything, not one that accepts everything. Following this guidance can make a verification regression test bless the exact untrusted certificate it needs to catch. Require a trusted, anchored artifact for the positive case and assert rejection for the fully populated forged artifact.

  • [P2] Rebase the guide and remove the retired ungated-handler exception
    AGENTS.md:7
    This is stale-base documentation drift: the branch predates the #94/#113 fixes, but it will add this guide cleanly to the current base. authz_guard::every_repo_scoped_handler_is_gated now has an empty known_ungated list, and its required-gate rows cover list_webhooks, list_replicas, and list_protected_branches (list_webhooks also has the owner gate). Leaving the exception here tells future contributors that those private-repository metadata surfaces are deliberately unprotected, contradicting the protections now on main and inviting their removal. Rebase and update the guide to describe the current gates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:docs Docs and comments only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants