From dfde24268e58444859daad06b22807e2c7fd823b Mon Sep 17 00:00:00 2001 From: Muse Date: Sat, 14 Nov 2026 11:59:19 -0600 Subject: [PATCH] docs(pm-stack): record #10140 fixture 5b pass + config-format root cause; guard heals config text format Fixture 5b (human Done move in Kaneo -> issue closes) initially failed: Kaneo applied status:done but never closed the issue. Root cause: syncLatestTaskValue string-compares integration.config text against JSON.stringify(JSON.parse(config)); the jsonb_set writes used by the containment fix and the guard heal leave jsonb-spaced text, silently aborting outbound state/title/description sync on all 4 integrations. - All 4 configs rewritten in compact JSON.stringify form (semantically identical); 5b re-run passes (#10308 closed by bot 17:51:21Z). - Guard now treats non-compact config text as drift and rewrites it compactly after healing (verified live both ways). - Doc: 5b row updated, caution on the re-apply SQL, new section with root cause + the dedicated Muse Automation account record (credentials by fleet-secret name only). --- pm-stack/KANEO-GITHUB-SYNC.md | 41 ++++++++++++++++++++++++++++++++++- pm-stack/kaneo-sync-guard.py | 17 +++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/pm-stack/KANEO-GITHUB-SYNC.md b/pm-stack/KANEO-GITHUB-SYNC.md index de5dedcc67..c9d42fd6d0 100644 --- a/pm-stack/KANEO-GITHUB-SYNC.md +++ b/pm-stack/KANEO-GITHUB-SYNC.md @@ -65,6 +65,13 @@ SET config = jsonb_set(config::jsonb, WHERE type = 'github'; ``` +**Caution (2026-11-14, #10140):** the `jsonb_set` write above leaves +`integration.config` in jsonb text form (spaces after `:` and `,`), +which silently disables Kaneo's outbound state/title/description sync +— see "Outbound sync depends on the config text format" below. After +using it, rewrite the config in compact `JSON.stringify` form (the +sync guard now does this automatically when it heals drift). + Do **not** simply delete the `pr_merged` workflow rule in the UI: in v2.47.0 deleting the rule falls back to `statusTransitions.onPRMerge || "done"`, which restores the bug. @@ -121,8 +128,40 @@ All on developing-today/code, verified from issue timelines + Kaneo DB: | 3 | Title-ref-only PR (#10201 ← PR #10220, title `(#10201)`) | Link formed — bot applied `status:in-review` at PR open (17:01:50Z) — merged 17:02:35Z; issue stayed OPEN, no `status:done`. Loose linking is live but contained by the `onPRMerge → in-review` rule. | | 4 | `Closes #n` PR (#10137 ← PR #10190, merged 17:04:11Z) | Closed natively by the merger 17:04:13Z; bot applied `status:done` 17:04:17Z (the `issue_closed → done` fallback). Legit path intact. | | 5a | Human close on GitHub (#10197, closed 17:06:26Z) | Linked Kaneo task completed (`task.status = done` in DB read-back). | -| 5b | Human Done move inside Kaneo → issue closes | NOT RUN in this pass: no Kaneo API key exists (`apikey` table empty) and creating one is a UI action. Covered by design (#10136 note, P2(iii)) and the 2026-10-24 setup proof (close-from-Kaneo was one of the four original sync proofs). Re-run when a key exists. | +| 5b | Human Done move inside Kaneo → issue closes | **PASS 2026-11-14 (second run)**: fixture #10308 ← task CODE-3715 moved to Done via the Kaneo API (dedicated automation account + API key, below). First run failed — bot applied `status:done` but never closed; root cause was the config text format (next section) plus the closure watchdog stripping the orphaned label. After the config fix: bot `status:done` 17:51:20Z, issue **closed by developing-today[bot] 17:51:21Z**, stable across a watchdog sweep. | | — | Branch-named PRs (`fixture/refs-epic-10199` → PR #10258, `fixture/refs-plain-10197` → PR #10259, both merged) | No link formed (the `{slug}-{number}` branch pattern keys on Kaneo task slugs, not GitHub issue numbers); targets stayed OPEN. | Fixtures #10106/#10107 from the original fix (2026-11-14 earlier) cover the title-ref-to-main and closes-to-main paths as well. + +## Outbound sync depends on the config text format (2026-11-14, #10140) + +Kaneo v2.47.0's outbound field sync (`syncLatestTaskValue`, used for +issue **state**, title and description) string-compares the stored +`integration.config` text against `JSON.stringify(JSON.parse(config))` +and silently aborts on any byte difference. Postgres `jsonb` text +output inserts spaces after `:` and `,`, so **any** write of the +config through `jsonb_set(...)::text` — including the re-apply SQL +above and the sync guard's original heal — disables Kaneo→GitHub +closing while leaving label sync (which compares parsed JSON) working. +Symptom: a task moved to Done applies `status:done` to the linked +issue but the issue never closes (and the closure watchdog then strips +the orphaned label as contradictory state). + +Fix applied 2026-11-14: all four GitHub integrations' configs were +rewritten byte-identical in meaning, in compact `JSON.stringify` +form. The sync guard now also treats non-compact config text as drift +and rewrites it compactly after healing. After any manual config +write, verify: `JSON.stringify(JSON.parse(config)) === config`. + +## Kaneo automation account (2026-11-14, #10140) + +A dedicated account exists for API automation so fixtures and sync +work never need a human's session: + +- User: **Muse Automation** (`claude-automation@developing-today.local`), + workspace role `owner` in Developing Today. +- API key: `muse-pm-automation` (created via the better-auth api-key + endpoint; verified with authenticated reads and the 5b fixture). +- Credentials live only in fleet secrets, by name: + `kaneo.muse-automation-password` and `kaneo.api-key-muse-automation`. diff --git a/pm-stack/kaneo-sync-guard.py b/pm-stack/kaneo-sync-guard.py index 96e1cebbf0..e80298a8f9 100644 --- a/pm-stack/kaneo-sync-guard.py +++ b/pm-stack/kaneo-sync-guard.py @@ -70,6 +70,12 @@ def main(): for key, val in st.items(): if val in FORBIDDEN_TARGETS and key not in EXPECTED: problems.append(f"{key} targets forbidden state {val!r}") + format_bad = raw.strip() != json.dumps( + cfg, separators=(",", ":"), ensure_ascii=False) + if format_bad: + problems.append("config text is not in JSON.stringify " + "compact form (breaks outbound state sync; " + "see KANEO-GITHUB-SYNC.md)") if not problems: print(f"OK {repo}: statusTransitions conform") continue @@ -89,6 +95,17 @@ def main(): f"'\"in-progress\"')::text WHERE id='{integ_id}'") after = json.loads(psql( f"SELECT config FROM integration WHERE id='{integ_id}'")) + # jsonb text form (spaces after ':' and ',') silently breaks + # Kaneo's outbound state/title/description sync: + # syncLatestTaskValue string-compares the stored config against + # JSON.stringify(JSON.parse(config)) and aborts on any byte + # difference (#10140, 2026-11-14). Always leave the config in + # that exact compact form. + compact = json.dumps(after, separators=(",", ":"), + ensure_ascii=False) + if "'" not in compact: + psql(f"UPDATE integration SET config = '{compact}' " + f"WHERE id='{integ_id}'") after_st = after.get("statusTransitions") or {} bad = [k for k, v in EXPECTED.items() if after_st.get(k) != v] if bad: