fix: canonicalActor collapses the --/__ axes correctly; claim-verify uses ActorMatches (be-p7dzx, bundled be-vc51) (#5856)
* test(feat): red — canonicalActor collapses the --/__ axes: misses gascity slash identities and widens ActorMatches (bundled with be-vc51 authorize/verify split) (refs be-fh0g) * feat: green — canonicalActor collapses the --/__ axes: misses gascity slash identities and widens ActorMatches (bundled with be-vc51 authorize/verify split) (refs be-fh0g) * docs(identity): correct the five contract surfaces that still document the pre---- collapse rule canonicalActor stopped collapsing an exact "--" run when it started decoding that run to "/", but five places still tell a reader the old rule: a run of ".", "_" or "-" matches any other such run. That is now false for "--", and two of the five are public contract surfaces rather than internal comments -- the OpenAPI description a client reads, and the conformance text a backend implementor is expected to satisfy. Corrected in place, all saying the same thing: an exact "--" run decodes to "/" because that is gascity's session-name encoding of a rig-qualified agent's slash, so "a--b" matches "a/b" and no longer matches "a__b" or "a-b"; longer and mixed runs, "__" included, still collapse. issueops/releaser.go ExpectedAssignee's contract issueops/issueops.go the update-side cross-reference internal/httpapi/spec/openapi.v0.yaml wire contract (source of truth) internal/httpapi/apigen/types.gen.go regenerated via make api-gen backend/conformance/releaser_contract.go cross-backend contract text The conformance limb is annotated rather than re-pinned: the respelling it exercises is "-" -> "_", which this change does not affect, so it stays green either way -- which is exactly why CI could not catch the stale text. Adding a "--" limb there would pin new cross-backend behavior and is a wider change than correcting a contract description. This is the keep-in-sync obligation identity.go records under ga-5ksp5, applied to the documentation half. * docs(changelog): record the --/__ equivalence-class change under [Unreleased] The actor-matching change is user-visible and silent: it moves which stored spellings compare equal for ExpectedAssignee on release and update, and for claim/close/unclaim authorization. "gastown--mayor" starts matching "gastown/mayor" and stops matching "gastown__mayor" and "gastown-mayor". The entry says the widening is the intended fix -- "gastown--mayor" is the agent "mayor" on rig "gastown" while "gastown__mayor" is the dotted alias "gastown.mayor", and matching them was wrong -- and then states the part a reader actually needs to act on: any stored "--" spelling that is NOT a gascity slash encoding changes equivalence class with no error to notice. --------- Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
This commit is contained in:
parent
537d00b265
commit
f6a191fd64
13 changed files with 206 additions and 28 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
|
@ -23,6 +23,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
payload is unchanged. Under `--quiet` the audit now skips its queries
|
||||
entirely rather than running them to discard the output.
|
||||
|
||||
- **Actor matching decodes an exact `--` run to `/` instead of collapsing it to
|
||||
a generic separator** (be-p7dzx, bundled be-vc51). Identity comparison — used
|
||||
by `ExpectedAssignee` on release and update, and by claim/close/unclaim
|
||||
authorization — canonicalizes a run of `.`, `_` or `-` to one separator so the
|
||||
same identity spelled under different layers' conventions compares equal. An
|
||||
exact two-byte `--` run is now excluded from that collapse: it is gascity's
|
||||
session-name encoding of a rig-qualified agent's `/`, so it decodes to `/`.
|
||||
**Compatibility:** `gastown--mayor` now matches `gastown/mayor`, and stops
|
||||
matching `gastown__mayor` and `gastown-mayor`. That is the intended fix rather
|
||||
than a side effect — `gastown--mayor` is the agent `mayor` on rig `gastown`
|
||||
while `gastown__mayor` is the dotted alias `gastown.mayor`, so matching them
|
||||
was a widening — but any stored `--` spelling that is NOT a gascity slash
|
||||
encoding changes equivalence class silently, with no error to notice. Longer
|
||||
or mixed runs, `__` and `---` included, are unaffected and still collapse.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Disabling telemetry no longer strands the queued eventsData backlog
|
||||
|
|
|
|||
|
|
@ -214,6 +214,11 @@ func RunReleaserRefusesAForeignClaimUntilForced(t *testing.T, ctx context.Contex
|
|||
// SEPARATOR-INSENSITIVE AND NOTHING ELSE (canonicalActor, ga-5ksp5): a run of
|
||||
// ".", "_" or "-" matches any other such run, so an expectation spelled under
|
||||
// one layer's separator convention releases a claim stored under another's.
|
||||
// The one exception is an exact "--" run: it is gascity's encoding of a
|
||||
// rig-qualified agent's "/" and decodes to "/", so "a--b" matches "a/b" and
|
||||
// not "a__b" (ga-2vy9p2). This tier does not pin that limb — the respelling
|
||||
// exercised below is "-" -> "_", which is unaffected — but the contract text
|
||||
// must not claim a rule the implementation no longer has.
|
||||
// NOTHING ELSE IS FORGIVEN, and the padded limb is the half that says so: an
|
||||
// implementation that reached for strings.TrimSpace to make the respelled limb
|
||||
// pass would release on an expectation the caller never actually held.
|
||||
|
|
|
|||
|
|
@ -1610,7 +1610,7 @@ type ReleaseIssueRequest struct {
|
|||
//
|
||||
// A MATCH REPLACES THE OWNERSHIP FENCE, so `actor` need not be the holder. Sending it beside `force` is a 400: the two are answers to the same question and they disagree.
|
||||
//
|
||||
// THE COMPARISON IS SEPARATOR-INSENSITIVE AND NOTHING ELSE. A run of `.`, `_` or `-` matches any other such run, so `agent-a`, `agent_a` and `agent.a` are one holder — that is deliberate, so a caller naming the holder under a different layer's spelling is a match rather than a mismatch. NOTHING ELSE IS FORGIVEN: the value is not trimmed and not case-folded, so `" agent-a"` and `Agent-a` are both refusals. The server trims only far enough to tell a blank expectation from a real one and never sends the trimmed form on, so a caller that pads its expectation loses EVERY time rather than intermittently. Compose it from a holder a read gave you.
|
||||
// THE COMPARISON IS SEPARATOR-INSENSITIVE AND NOTHING ELSE. A run of `.`, `_` or `-` matches any other such run, so `agent-a`, `agent_a` and `agent.a` are one holder — that is deliberate, so a caller naming the holder under a different layer's spelling is a match rather than a mismatch. THE ONE EXCEPTION IS AN EXACT `--` RUN: that is gascity's session-name encoding of a rig-qualified agent's `/`, so it decodes to `/` instead of collapsing. `a--b` matches `a/b`, and no longer matches `a__b` or `a-b`. Those name different identities — `a--b` is the agent `b` on rig `a`, `a__b` is the dotted alias `a.b` — so treating them as one holder was a widening, and removing it is the point of the exception. Longer or mixed runs, `__` included, still collapse. NOTHING ELSE IS FORGIVEN: the value is not trimmed and not case-folded, so `" agent-a"` and `Agent-a` are both refusals. The server trims only far enough to tell a blank expectation from a real one and never sends the trimmed form on, so a caller that pads its expectation loses EVERY time rather than intermittently. Compose it from a holder a read gave you.
|
||||
//
|
||||
// THE EMPTY STRING IS A 400, and this is the one place this member disagrees with `UpdateIssueRequest.expected_assignee`, where an empty string is a real guard meaning "expected unassigned". Here "release a row nobody holds" describes no release at all; a caller that wants to assert a row is unheld is asking a READER a question, not asking this operation to do nothing. Absent, and only absent, selects the unconditional path.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -9493,7 +9493,14 @@ components:
|
|||
A run of `.`, `_` or `-` matches any other such run, so `agent-a`,
|
||||
`agent_a` and `agent.a` are one holder — that is deliberate, so a
|
||||
caller naming the holder under a different layer's spelling is a
|
||||
match rather than a mismatch. NOTHING ELSE IS FORGIVEN: the value
|
||||
match rather than a mismatch. THE ONE EXCEPTION IS AN EXACT `--`
|
||||
RUN: that is gascity's session-name encoding of a rig-qualified
|
||||
agent's `/`, so it decodes to `/` instead of collapsing. `a--b`
|
||||
matches `a/b`, and no longer matches `a__b` or `a-b`. Those name
|
||||
different identities — `a--b` is the agent `b` on rig `a`, `a__b`
|
||||
is the dotted alias `a.b` — so treating them as one holder was a
|
||||
widening, and removing it is the point of the exception. Longer or
|
||||
mixed runs, `__` included, still collapse. NOTHING ELSE IS FORGIVEN: the value
|
||||
is not trimmed and not case-folded, so `" agent-a"` and `Agent-a`
|
||||
are both refusals. The server trims only far enough to tell a blank
|
||||
expectation from a real one and never sends the trimmed form on, so
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage"
|
||||
storageissueops "github.com/steveyegge/beads/internal/storage/issueops"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
|
|
@ -56,11 +57,18 @@ func claimedBy(actor string) claimPostcondition {
|
|||
|
||||
// claimedAs is claimedBy for a claim whose request overrides the assignee or
|
||||
// status the bare claim would have written.
|
||||
//
|
||||
// The assignee check is identity-equivalence (storageissueops.ActorMatches),
|
||||
// not byte equality: the claim CAS treats a reclaim under a different
|
||||
// spelling of the actor it already holds as idempotent and authorizes it
|
||||
// without rewriting the stored spelling (ClaimIssueInTx's idempotent-reclaim
|
||||
// branch), so verify must recognize that same identity or it fails loudly on
|
||||
// a write the CAS legitimately authorized (be-vc51, ga-2vy9p2).
|
||||
func claimedAs(assignee string, status types.Status) claimPostcondition {
|
||||
return claimPostcondition{
|
||||
op: "claim",
|
||||
want: func(gotAssignee string, gotStatus types.Status) bool {
|
||||
return gotAssignee == assignee && gotStatus == status
|
||||
return storageissueops.ActorMatches(gotAssignee, assignee) && gotStatus == status
|
||||
},
|
||||
desc: fmt.Sprintf("assignee=%q status=%q", assignee, status),
|
||||
}
|
||||
|
|
@ -112,7 +120,11 @@ func guardedUpdatePostcondition(opts storage.UpdateIssueOptions, updates map[str
|
|||
return claimPostcondition{
|
||||
op: "guarded-update",
|
||||
want: func(assignee string, status types.Status) bool {
|
||||
if setsAssignee && assignee != newAssignee {
|
||||
// Identity-equivalence, not byte equality — same reason as
|
||||
// claimedAs above: a coordination write that sets assignee to a
|
||||
// respelling of an identity must verify against that identity,
|
||||
// not the exact spelling requested (be-vc51, ga-2vy9p2).
|
||||
if setsAssignee && !storageissueops.ActorMatches(assignee, newAssignee) {
|
||||
return false
|
||||
}
|
||||
if setsStatus && status != types.Status(newStatus) {
|
||||
|
|
|
|||
|
|
@ -256,3 +256,36 @@ func TestClaimUnclaimVerifiedEndToEnd(t *testing.T) {
|
|||
t.Fatalf("post-unclaim state: assignee=%q status=%q", assignee, status)
|
||||
}
|
||||
}
|
||||
|
||||
// TestClaimVerifyAcceptsRespelledReclaim proves the claim CAS's
|
||||
// idempotent-reclaim branch (issueops.ClaimIssueInTx: same actor,
|
||||
// already in_progress, succeeds without rewriting the stored spelling) does
|
||||
// not then fail its own verify-after-write re-read when the reclaim names the
|
||||
// held identity under a different spelling (be-vc51, ga-2vy9p2). Without the
|
||||
// fix, claimedAs's postcondition compares the re-read assignee to the
|
||||
// requested spelling byte-for-byte, so a CAS-authorized respelled reclaim
|
||||
// fails loudly with "did not land" even though it holds the issue.
|
||||
func TestClaimVerifyAcceptsRespelledReclaim(t *testing.T) {
|
||||
s, cleanup := setupTestStore(t)
|
||||
defer cleanup()
|
||||
ctx, cancel := testContext(t)
|
||||
defer cancel()
|
||||
s.serverMode = true
|
||||
|
||||
id := claimVerifyTestIssue(t, s)
|
||||
if err := rawClaim(t, s, id, "gastown__mayor"); err != nil {
|
||||
t.Fatalf("seed claim under one spelling: %v", err)
|
||||
}
|
||||
|
||||
if err := s.ClaimIssue(ctx, id, "gastown.mayor"); err != nil {
|
||||
t.Fatalf("respelled reclaim: %v", err)
|
||||
}
|
||||
|
||||
assignee, status, err := s.readClaimState(ctx, id)
|
||||
if err != nil {
|
||||
t.Fatalf("read claim state: %v", err)
|
||||
}
|
||||
if assignee != "gastown__mayor" || status != types.StatusInProgress {
|
||||
t.Fatalf("respelled reclaim must keep the stored spelling: assignee=%q status=%q", assignee, status)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,37 @@ func TestIssueOperationsClaimVerifyPostcondition(t *testing.T) {
|
|||
holds: [][2]string{{"carol", "open"}, {"carol", "in_progress"}},
|
||||
rejects: [][2]string{{"bob", "open"}},
|
||||
},
|
||||
{
|
||||
// be-vc51/ga-2vy9p2: the CAS authorizes a reclaim under a
|
||||
// different spelling of the same identity without rewriting the
|
||||
// stored spelling (issueops.ClaimIssueInTx's idempotent-reclaim
|
||||
// branch), so the postcondition must recognize the stored
|
||||
// spelling as the same actor rather than requiring a byte-exact
|
||||
// match against the requested one — and must still reject a
|
||||
// genuinely different identity (gastown.dog-3) or a widened
|
||||
// cross-axis spelling (gastown--mayor, the rig-qualified slash
|
||||
// axis, is not gastown__mayor, the dot axis).
|
||||
name: "bare claim accepts a respelled identity of the same actor (ga-2vy9p2)",
|
||||
request: publicops.UpdateRequest{Actor: "gastown.mayor", IssueID: "bd-1", Claim: true},
|
||||
wantVerified: true,
|
||||
wantDesc: `assignee="gastown.mayor" status="in_progress"`,
|
||||
holds: [][2]string{{"gastown.mayor", "in_progress"}, {"gastown__mayor", "in_progress"}},
|
||||
rejects: [][2]string{{"gastown--mayor", "in_progress"}, {"gastown.dog-3", "in_progress"}, {"someone-else", "in_progress"}},
|
||||
},
|
||||
{
|
||||
// Same asymmetry as above, at the guarded-update site
|
||||
// (claim_verify.go's guardedUpdatePostcondition): a coordination
|
||||
// write that sets assignee to a respelling of an identity must
|
||||
// verify against identity equivalence, not byte equality.
|
||||
name: "guarded assignee transfer accepts a respelled identity of the written value (ga-2vy9p2)",
|
||||
request: publicops.UpdateRequest{Actor: "alice", IssueID: "bd-1", ExpectedAssignee: assignee("bob"), Patch: publicops.IssuePatch{
|
||||
Assignee: publicops.Field[string]{Set: true, Value: "gastown.mayor"},
|
||||
}},
|
||||
wantVerified: true,
|
||||
wantDesc: `assignee="gastown.mayor"`,
|
||||
holds: [][2]string{{"gastown.mayor", "open"}, {"gastown__mayor", "in_progress"}},
|
||||
rejects: [][2]string{{"gastown--mayor", "open"}, {"bob", "open"}},
|
||||
},
|
||||
{
|
||||
name: "guarded status write",
|
||||
request: publicops.UpdateRequest{Actor: "alice", IssueID: "bd-1", ExpectedStatus: status(types.StatusOpen), Patch: publicops.IssuePatch{
|
||||
|
|
|
|||
|
|
@ -11,11 +11,32 @@ import "strings"
|
|||
// string, never the substitution itself (ga-wzl83). None of ".", "_", "-"
|
||||
// carries meaning in an identity string: each is always a positional
|
||||
// separator between a rig and a role/agent name, never part of either name.
|
||||
// Collapsing any run of them to one canonical separator lets two spellings
|
||||
// of the same identity compare equal without weakening comparisons between
|
||||
// Collapsing a run of them to one canonical separator lets two spellings of
|
||||
// the same identity compare equal without weakening comparisons between
|
||||
// genuinely different identities, whose non-separator characters still
|
||||
// differ (e.g. "gastown.mayor" vs "gastown.dog-3" stay distinct).
|
||||
//
|
||||
// A run that is the exact two-byte sequence "--" is a second, distinct axis:
|
||||
// gascity's session-name encoding (session_name.go) substitutes "--" for a
|
||||
// rig-qualified agent's "/" — a DIFFERENT identity from one substituting "_"
|
||||
// or "__" for a dotted alias's "." — so it decodes to a literal "/" instead
|
||||
// of collapsing into the generic "_" separator (ga-2vy9p2). Any other run,
|
||||
// including "__" and longer or mixed runs, still collapses to "_": those
|
||||
// keep meaning nothing but "here was some separator". A raw "/" already
|
||||
// passes through unchanged (it hits the default case below), which is what
|
||||
// makes the "--" decode land on the same canonical form: "gastown/mayor" and
|
||||
// "gastown--mayor" both canonicalize to "gastown/mayor", while
|
||||
// "gastown--mayor" and "gastown__mayor" no longer collapse to the same
|
||||
// value — collapsing them was a real widening: "gastown--mayor" is a
|
||||
// rig-qualified agent named "mayor", "gastown__mayor" is a dotted alias
|
||||
// "gastown.mayor"; treating them as the same actor was wrong regardless of
|
||||
// whether either happens to be held by the same principal today.
|
||||
//
|
||||
// Byte-scanned rather than rune-scanned so a 2-byte lookahead can detect an
|
||||
// exact "--" run: safe because '.', '_', '-' are single-byte ASCII that never
|
||||
// appear as a continuation byte of a multi-byte UTF-8 rune, so slicing on
|
||||
// them cannot split one.
|
||||
//
|
||||
// Empty stays empty: an actual absence of an actor must never canonicalize
|
||||
// to the same value as a non-empty one, or a caller comparing against an
|
||||
// unassigned issue would start matching everyone.
|
||||
|
|
@ -32,18 +53,24 @@ func canonicalActor(s string) string {
|
|||
}
|
||||
var b strings.Builder
|
||||
b.Grow(len(s))
|
||||
inSeparator := false
|
||||
for _, r := range s {
|
||||
switch r {
|
||||
case '.', '_', '-':
|
||||
if !inSeparator {
|
||||
b.WriteByte('_')
|
||||
inSeparator = true
|
||||
i := 0
|
||||
for i < len(s) {
|
||||
c := s[i]
|
||||
if c == '.' || c == '_' || c == '-' {
|
||||
j := i
|
||||
for j < len(s) && (s[j] == '.' || s[j] == '_' || s[j] == '-') {
|
||||
j++
|
||||
}
|
||||
default:
|
||||
b.WriteRune(r)
|
||||
inSeparator = false
|
||||
if s[i:j] == "--" {
|
||||
b.WriteByte('/')
|
||||
} else {
|
||||
b.WriteByte('_')
|
||||
}
|
||||
i = j
|
||||
continue
|
||||
}
|
||||
b.WriteByte(c)
|
||||
i++
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ func TestIdentityCanonicalizationParityWithValidation(t *testing.T) {
|
|||
{name: "mixed separators each collapse to one canonical separator", in: "gastown.dog-3"},
|
||||
{name: "leading separator is preserved as a separator, not dropped", in: ".mayor"},
|
||||
{name: "trailing separator is preserved as a separator, not dropped", in: "mayor."},
|
||||
{name: "exact double-hyphen separator decodes to the rig-qualified slash (ga-2vy9p2)", in: "gastown--mayor"},
|
||||
{name: "raw slash passes through unchanged", in: "gastown/mayor"},
|
||||
{name: "a hyphen run longer than two is not the exact slash spelling and falls back to generic collapse", in: "gastown---mayor"},
|
||||
}
|
||||
for _, tc := range canonicalCases {
|
||||
t.Run("CanonicalActor/"+tc.name, func(t *testing.T) {
|
||||
|
|
@ -57,6 +60,9 @@ func TestIdentityCanonicalizationParityWithValidation(t *testing.T) {
|
|||
{name: "genuinely different identities do not match", assignee: "gastown.mayor", actor: "gastown.dog-3"},
|
||||
{name: "both empty match", assignee: "", actor: ""},
|
||||
{name: "empty assignee never matches a non-empty actor", assignee: "", actor: "mayor"},
|
||||
{name: "double-hyphen and double-underscore spellings no longer widen to the same identity (ga-2vy9p2)", assignee: "gastown--mayor", actor: "gastown__mayor"},
|
||||
{name: "double-hyphen spelling matches its raw-slash identity (ga-2vy9p2)", assignee: "gastown--mayor", actor: "gastown/mayor"},
|
||||
{name: "raw slash and raw dot stay genuinely distinct identities", assignee: "gastown/mayor", actor: "gastown.mayor"},
|
||||
}
|
||||
for _, tc := range matchCases {
|
||||
t.Run("ActorMatches/"+tc.name, func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -80,11 +80,32 @@ func NotPinned(force bool) IssueValidator {
|
|||
// string, never the substitution itself (ga-wzl83). None of ".", "_", "-"
|
||||
// carries meaning in an identity string: each is always a positional
|
||||
// separator between a rig and a role/agent name, never part of either name.
|
||||
// Collapsing any run of them to one canonical separator lets two spellings
|
||||
// of the same identity compare equal without weakening comparisons between
|
||||
// Collapsing a run of them to one canonical separator lets two spellings of
|
||||
// the same identity compare equal without weakening comparisons between
|
||||
// genuinely different identities, whose non-separator characters still
|
||||
// differ (e.g. "gastown.mayor" vs "gastown.dog-3" stay distinct).
|
||||
//
|
||||
// A run that is the exact two-byte sequence "--" is a second, distinct axis:
|
||||
// gascity's session-name encoding (session_name.go) substitutes "--" for a
|
||||
// rig-qualified agent's "/" — a DIFFERENT identity from one substituting "_"
|
||||
// or "__" for a dotted alias's "." — so it decodes to a literal "/" instead
|
||||
// of collapsing into the generic "_" separator (ga-2vy9p2). Any other run,
|
||||
// including "__" and longer or mixed runs, still collapses to "_": those
|
||||
// keep meaning nothing but "here was some separator". A raw "/" already
|
||||
// passes through unchanged (it hits the default case below), which is what
|
||||
// makes the "--" decode land on the same canonical form: "gastown/mayor" and
|
||||
// "gastown--mayor" both canonicalize to "gastown/mayor", while
|
||||
// "gastown--mayor" and "gastown__mayor" no longer collapse to the same
|
||||
// value — collapsing them was a real widening: "gastown--mayor" is a
|
||||
// rig-qualified agent named "mayor", "gastown__mayor" is a dotted alias
|
||||
// "gastown.mayor"; treating them as the same actor was wrong regardless of
|
||||
// whether either happens to be held by the same principal today.
|
||||
//
|
||||
// Byte-scanned rather than rune-scanned so a 2-byte lookahead can detect an
|
||||
// exact "--" run: safe because '.', '_', '-' are single-byte ASCII that never
|
||||
// appear as a continuation byte of a multi-byte UTF-8 rune, so slicing on
|
||||
// them cannot split one.
|
||||
//
|
||||
// Empty stays empty: an actual absence of an actor must never canonicalize
|
||||
// to the same value as a non-empty one, or AssigneeMatches would start
|
||||
// accepting an empty actor against an assigned issue.
|
||||
|
|
@ -94,18 +115,24 @@ func CanonicalActor(s string) string {
|
|||
}
|
||||
var b strings.Builder
|
||||
b.Grow(len(s))
|
||||
inSeparator := false
|
||||
for _, r := range s {
|
||||
switch r {
|
||||
case '.', '_', '-':
|
||||
if !inSeparator {
|
||||
b.WriteByte('_')
|
||||
inSeparator = true
|
||||
i := 0
|
||||
for i < len(s) {
|
||||
c := s[i]
|
||||
if c == '.' || c == '_' || c == '-' {
|
||||
j := i
|
||||
for j < len(s) && (s[j] == '.' || s[j] == '_' || s[j] == '-') {
|
||||
j++
|
||||
}
|
||||
default:
|
||||
b.WriteRune(r)
|
||||
inSeparator = false
|
||||
if s[i:j] == "--" {
|
||||
b.WriteByte('/')
|
||||
} else {
|
||||
b.WriteByte('_')
|
||||
}
|
||||
i = j
|
||||
continue
|
||||
}
|
||||
b.WriteByte(c)
|
||||
i++
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,6 +159,9 @@ func TestCanonicalActor(t *testing.T) {
|
|||
{name: "mixed separators each collapse to one canonical separator", in: "gastown.dog-3", want: "gastown_dog_3"},
|
||||
{name: "leading separator is preserved as a separator, not dropped", in: ".mayor", want: "_mayor"},
|
||||
{name: "trailing separator is preserved as a separator, not dropped", in: "mayor.", want: "mayor_"},
|
||||
{name: "exact double-hyphen separator decodes to the rig-qualified slash (ga-2vy9p2)", in: "gastown--mayor", want: "gastown/mayor"},
|
||||
{name: "raw slash passes through unchanged", in: "gastown/mayor", want: "gastown/mayor"},
|
||||
{name: "a hyphen run longer than two is not the exact slash spelling and falls back to generic collapse", in: "gastown---mayor", want: "gastown_mayor"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
@ -182,6 +185,9 @@ func TestActorMatches(t *testing.T) {
|
|||
{name: "genuinely different identities do not match", assignee: "gastown.mayor", actor: "gastown.dog-3", want: false},
|
||||
{name: "both empty match", assignee: "", actor: "", want: true},
|
||||
{name: "empty assignee never matches a non-empty actor", assignee: "", actor: "mayor", want: false},
|
||||
{name: "double-hyphen and double-underscore spellings no longer widen to the same identity (ga-2vy9p2)", assignee: "gastown--mayor", actor: "gastown__mayor", want: false},
|
||||
{name: "double-hyphen spelling matches its raw-slash identity (ga-2vy9p2)", assignee: "gastown--mayor", actor: "gastown/mayor", want: true},
|
||||
{name: "raw slash and raw dot stay genuinely distinct identities", assignee: "gastown/mayor", actor: "gastown.mayor", want: false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
|
|
@ -288,7 +288,9 @@ type UpdateRequest struct {
|
|||
//
|
||||
// THE COMPARISON IS SEPARATOR-INSENSITIVE, exactly as
|
||||
// ReleaseRequest.ExpectedAssignee documents: a run of ".", "_" or "-"
|
||||
// matches any other such run, and nothing else is forgiven.
|
||||
// matches any other such run — except an exact "--" run, which decodes to
|
||||
// "/" as gascity's rig-qualified agent encoding, so "a--b" matches "a/b"
|
||||
// rather than "a__b" — and nothing else is forgiven.
|
||||
ExpectedAssignee *string
|
||||
// ExpectedStatus requires the current status to match. It must be nil when
|
||||
// Claim is true.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,14 @@ type ReleaseRequest struct {
|
|||
// "_" or "-" matches any other such run, so "agent-a", "agent_a" and
|
||||
// "agent.a" are one holder — that is deliberate, so a caller naming the
|
||||
// holder under a different layer's spelling is a match rather than a
|
||||
// mismatch (ga-5ksp5). NOTHING ELSE IS FORGIVEN: the value is not trimmed
|
||||
// mismatch (ga-5ksp5). THE ONE EXCEPTION IS AN EXACT "--" RUN: that is
|
||||
// gascity's session-name encoding of a rig-qualified agent's "/", so it
|
||||
// decodes to "/" rather than collapsing. "a--b" matches "a/b" and no
|
||||
// longer matches "a__b" or "a-b" — "a--b" is the agent "b" on rig "a"
|
||||
// while "a__b" is the dotted alias "a.b", so treating them as one holder
|
||||
// was a widening, and removing it is the point of the exception
|
||||
// (ga-2vy9p2). Longer or mixed runs, "__" included, still collapse.
|
||||
// NOTHING ELSE IS FORGIVEN: the value is not trimmed
|
||||
// and not case-folded, so " agent-a" and "Agent-a" are both refusals. The
|
||||
// validation below trims only far enough to tell a blank expectation from a
|
||||
// real one, and never writes the trimmed form back — the no-mutation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue