Repository navigation
gate: refuse a publish into a repository whose claim this session does not hold - #28
Merged
Merged
Conversation
…s not hold `agentsync gate --hook` answers a Claude Code PreToolUse payload. For gitpush, ghmerge, ghrelease, ghpr, ghissue, ghrun and ghrel it resolves the target repository and denies when another session holds the claim (naming holder and expiry) or when nobody does. It allows when this session holds it, including through an organisation claim, and allows whenever it cannot read: payload, claims directory, remote, session identity. lease.Store.Covering lists the leases about a repository: itself, its organisation, or the bare name. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled
force-pushed
the
gate-publishing-on-claim
branch
from
November 12, 2026 15:25
8c7fcc1 to
0f07f81
Compare
…sing, push target, unreadable leases) - decide denies when ANY other session holds a live lease covering the target, whatever this session holds; a bare "optimize" no longer outranks another session's live "go-numerics/optimize". - Acquire treats a bare name and an owner/name ending in it as overlapping, in both orders. - Command parsing uses gitsafe's shellcmd (quoted heredocs, comments, statement split); inside a statement a gated program word anywhere, unquoted, counts, and a quoted word is read as a command only after bash/sh/zsh/eval. A cd inside parentheses does not outlive them; redirections are not arguments. - gitpush follows branch.<b>.pushRemote, remote.pushDefault, branch.<b>.remote and the push URL. - Covering fails on an unreadable lease, which the gate reads as "cannot read": allow, with a note. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…i-line quote state - A gated program counts only as the COMMAND (after assignments and wrappers sudo/timeout/xargs/nice/env/..., reserved words), or inside bash -c/eval, $(...) and backticks: `go test ./cmd/ghmerge`, `cat ~/.local/bin/gitpush` and `echo ghmerge` are no longer denied. - $(...) and backticks inside double quotes are run as commands. - `#` comment stripping tracks quote state across lines. - README: the gate guards against mistakes, not adversaries. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Why
The claim was advisory and nothing read it where it matters. Two recorded occurrences: 2026-09-02, and 2026-11-12, when go-scikit's claim on go-numerics/optimize expired at 12:54, another session claimed it, and at 16:02-16:14 go-scikit pushed and merged go-numerics/optimize#62 without claiming again. No damage; nothing refused it.
What
agentsync gate --hookreads a PreToolUse payload on stdin (modelled onrecur --hook: decision in the JSON, exit always 0).echo gitpushis left alone): gitpush, ghmerge, ghrelease, ghpr, ghissue, ghrun, ghrel.cd X &&is followed.owner/repoor GitHub URL argument (or--repo/-repo/-R), else the remote of the cwd /cd/-Cdirectory (gitpushuses the remote it is given, default origin).lease.Store.Covering).ghrelease backfill.agentsync gate <owner/repo>...answers the same question by hand.Session identity
Same as
claim/whoami(owner()), plus what only a hook has:AGENTSYNC_OWNER, else the payload'ssession_id, elseCLAUDE_CODE_SESSION_ID. With none, allow (owner()'sunidentified-<host>would match nothing and refuse everything).Known limits
ghpr review/ghissuecomments by a reviewer session in a repo claimed by the author are also refused; the reviewer claims it or messages the holder.flagpackage like every other verb; moving agentsync to cobra is a separate change.Wiring (NOT done here; the user's decision)
Add to
~/.claude/settings.json:{"hooks": {"PreToolUse": [{"matcher": "Bash", "hooks": [{"type": "command", "command": "agentsync gate --hook"}]}]}}(merged into the existing
PreToolUsearray), after installing the release withGOBIN=~/.local/bin go install github.com/go-agentsync/agentsync/cmd/agentsync@latest.Tests
Holder allowed (all seven programs), another holder refused with name/expiry/note, no claim refused, expired own claim refused, expired foreign claim ignored, organisation and bare-name claims, unreadable store / non-JSON / no identity / unresolvable remote / backfill all allow, non-publishing commands and non-Bash tools untouched, target resolution table, identity precedence,
Covering.gofmt,go vet(linux, darwin, windows),go test -raceclean.🤖 Generated with Claude Code