Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

review: constrain ticketKeyFromRef to the claim/cos conventions (no false live-claim)

Adam Eivy531b9534497a
diff --git a/server/services/issueReconcile.js b/server/services/issueReconcile.js
index 15a87aaa54..80ddc9068f 100644
--- a/server/services/issueReconcile.js
+++ b/server/services/issueReconcile.js
@@ -87,20 +87,27 @@ export function issueNumberFromRef(refName) {
/**
* Extract the JIRA ticket KEY a git ref claims, or null. JIRA claim branches use
- * the ticket KEY directly (no `issue-` prefix), so both conventions carry the raw
- * key as a whole path segment:
- * - human / TUI: `claim/<KEY>` (KEY after `claim/`)
- * - CoS sub-agent: `cos/<task>/<KEY>/<agent>` (KEY as the 3rd segment)
- * A KEY looks like `PROJ-1234` (project code + `-` + number). Matching any whole
- * segment that IS a JIRA key covers both conventions and remote-tracking refs
- * (`refs/remotes/origin/claim/<KEY>`) in one pass — the KEY shape is distinctive
- * enough that a non-key segment (`main`, `claim`, `feat`) can't collide.
+ * the ticket KEY directly (no `issue-` prefix), so — unlike the distinctive
+ * `issue-<num>` token — the parser must anchor on the CLAIM CONVENTION itself, not
+ * merely on "a segment shaped like a key". Otherwise an unrelated branch that
+ * happens to end in a key (`wip/PROJ-42`, `feat/PROJ-42`) would register a false
+ * live-claim and suppress a genuine zombie forever. Recognizes exactly the two
+ * conventions the claim-issue-jira flow creates:
+ * - human / TUI: `claim/<KEY>` (KEY immediately after `claim/`)
+ * - CoS sub-agent: `cos/<task>/<KEY>/<agent>` (KEY as the segment after `cos/<task>/`)
+ * A KEY looks like `PROJ-1234` (project code + `-` + number) and must be a whole
+ * segment (terminated by `/` or end-of-ref). Remote-tracking refs
+ * (`refs/remotes/origin/claim/<KEY>`) match the same way — the leading
+ * `refs/…/origin/` is just more segments before `claim/`.
* @param {string} refName
* @returns {string|null}
*/
export function ticketKeyFromRef(refName) {
- const m = /(?:^|\/)([A-Z][A-Z0-9]+-\d+)(?=\/|$)/.exec(refName || '');
- return m ? m[1] : null;
+ const ref = refName || '';
+ const claim = /(?:^|\/)claim\/([A-Z][A-Z0-9]+-\d+)(?=\/|$)/.exec(ref);
+ if (claim) return claim[1];
+ const cos = /(?:^|\/)cos\/[^/]+\/([A-Z][A-Z0-9]+-\d+)(?=\/|$)/.exec(ref);
+ return cos ? cos[1] : null;
}
/**
diff --git a/server/services/issueReconcile.test.js b/server/services/issueReconcile.test.js
index 926378ec85..8777f5d513 100644
--- a/server/services/issueReconcile.test.js
+++ b/server/services/issueReconcile.test.js
@@ -95,6 +95,14 @@ describe('ticketKeyFromRef', () => {
expect(ticketKeyFromRef('feat/some-feature')).toBeNull();
expect(ticketKeyFromRef('')).toBeNull();
});
+ it('does NOT match a key-shaped segment outside the claim/cos convention (no false live-claim)', () => {
+ // A branch that merely ENDS in a key must not register a live claim — else a
+ // real zombie would be suppressed forever.
+ expect(ticketKeyFromRef('wip/PROJ-42')).toBeNull();
+ expect(ticketKeyFromRef('feat/PROJ-42')).toBeNull();
+ expect(ticketKeyFromRef('PROJ-42')).toBeNull();
+ expect(ticketKeyFromRef('cos/PROJ-42')).toBeNull(); // missing the <task> segment
+ });
});
describe('isJiraStartedStatus', () => {