From c48c4f446a57231756a33e7cfe88d3ced708bc27 Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 16:57:42 -0500 Subject: [PATCH 01/10] Add scripts/sync-port.sh for the next port sync It reproduces this merge's deterministic resolutions on a fresh branch and leaves only the judgment files conflicted. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit 50b853e9e08d17cd9266fda99371e3faf142adaf) --- FORK.md | 2 +- scripts/sync-port.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 scripts/sync-port.sh diff --git a/FORK.md b/FORK.md index d69d904c..7399a522 100644 --- a/FORK.md +++ b/FORK.md @@ -3,7 +3,7 @@ This fork is the pinned source for the pstack plugin on Adam Vellequette's Claude Code and Codex lanes. Lauren Tan's official pstack (`cursor/plugins/pstack`) is the source of truth for content; `ericlitman/open-pstack` supplies the Claude Code and Codex translation. - **Install ref:** branch `adam/release`. `main` mirrors `ericlitman/open-pstack` and carries no local change. -- **Sync rule:** a deliberate diff, never a blind pull. Merge upstream `main` into `adam/release`, read the diff, re-run the checks, then reinstall. +- **Sync rule:** a deliberate diff, never a blind pull. On a branch cut from `adam/release`, run `scripts/sync-port.sh `: it merges the port release, resolves every file that needs no judgment, stamps the version, and lists the files left to read. Resolve those, add the `CHANGES.md` section the static check requires, re-run the checks, open the PR, then reinstall. - **Design brief:** `~/.agents/harness/docs/design/pstack-front-door.md`. ## Local patches diff --git a/scripts/sync-port.sh b/scripts/sync-port.sh new file mode 100755 index 00000000..52d01741 --- /dev/null +++ b/scripts/sync-port.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Merge a port release into the fork's release branch with the deliberate-diff rule in FORK.md. +# +# scripts/sync-port.sh e.g. v1.16.0 1.16.0-adam.20261101 +# +# Run on a branch cut from adam/release with the `upstream` remote (ericlitman/open-pstack) +# fetched. The merge's natural base is the last port release the fork merged, so every file +# the fork squash-imported since then conflicts. The script resolves what needs no judgment: +# a file whose fork copy equals the previous port release's copy takes the new release's copy, +# and the rest re-merge three-way against that previous release. It stamps the fork version +# on the manifests and UPSTREAM.md, then lists the conflicts left for a person to read. +set -eu +tag="$1"; version="$2" +prev="$(sed -n 's/^| open-pstack version | `\([0-9.]*\)[^`]*` |$/\1/p' UPSTREAM.md)" +[ -n "$prev" ] || { echo "UPSTREAM.md has no open-pstack version row"; exit 1; } +prev="v$prev" +git rev-parse -q --verify "$tag^{commit}" >/dev/null || { echo "unknown tag $tag; fetch upstream --tags"; exit 1; } +git rev-parse -q --verify "$prev^{commit}" >/dev/null || { echo "unknown previous release $prev"; exit 1; } +ours="$(git rev-parse HEAD)" +git merge --no-commit --no-ff "$tag" >/dev/null 2>&1 || true +for f in $(git diff --name-only --diff-filter=U); do + o=$(git rev-parse -q --verify "$ours:$f" 2>/dev/null || echo none) + p=$(git rev-parse -q --verify "$prev:$f" 2>/dev/null || echo none) + t=$(git rev-parse -q --verify "$tag:$f" 2>/dev/null || echo none) + if [ "$o" = "$p" ] || [ "$o" = "$t" ]; then git checkout --quiet "$tag" -- "$f"; git add -- "$f"; continue; fi + if [ "$p" = "$t" ]; then git checkout --quiet "$ours" -- "$f"; git add -- "$f"; continue; fi + tmp=$(mktemp -d) + git show "$ours:$f" > "$tmp/ours"; git show "$prev:$f" > "$tmp/prev" 2>/dev/null || : > "$tmp/prev"; git show "$tag:$f" > "$tmp/tag" + if git merge-file -p -L fork -L "$prev" -L "$tag" "$tmp/ours" "$tmp/prev" "$tmp/tag" > "$f"; then git add -- "$f"; fi + rm -rf "$tmp" +done +for f in .claude-plugin/marketplace.json plugins/pstack/.claude-plugin/plugin.json plugins/pstack/.codex-plugin/plugin.json; do + git show "$tag:$f" > "$f" + sed -i '' -E "s/(\"version\": \")[^\"]+(\")/\1$version\2/" "$f"; git add -- "$f" +done +# The port owns its provenance files; the fork records itself in FORK.md and one CHANGES.md section. +for f in NOTICE.md CHANGES.md; do git show "$tag:$f" > "$f"; git add -- "$f"; done +git show "$tag:UPSTREAM.md" > UPSTREAM.md +sed -i '' -E "s/^(\| open-pstack version \| \`)[^\`]+(\` \|)/\1$version\2/" UPSTREAM.md; git add -- UPSTREAM.md +left="$(git diff --name-only --diff-filter=U)" +if [ -z "$left" ]; then echo "merged $tag with no conflicts left; read the diff, then commit"; else + echo "merged $tag; resolve these by hand, then commit:"; echo "$left"; fi +echo "then: add a CHANGES.md section for $version, update FORK.md's sync record, run bun run static, typecheck, test" From 975a1a643da7e8bcef0dfa0fee0153562278d1be Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:27:33 -0500 Subject: [PATCH 02/10] Register scripts/sync-port.sh as a non-runtime path in the verifier The live gate classifies every path a PR changes and refuses an unmapped one; the operator script is not a shipped surface. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit 1c6b00cd417c13ec39f7e65879c60c78ff9fb287) --- .claude/skills/verify-open-pstack/features/registry.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.claude/skills/verify-open-pstack/features/registry.json b/.claude/skills/verify-open-pstack/features/registry.json index 3a2b370f..c9e2c808 100644 --- a/.claude/skills/verify-open-pstack/features/registry.json +++ b/.claude/skills/verify-open-pstack/features/registry.json @@ -83,6 +83,6 @@ ".gitignore", ".mergify.yml", "docs/**", "assets/**", "plugins/pstack/skills/poteto-mode/scripts/bootstrap.test.ts", "plugins/pstack/skills/poteto-mode/scripts/check-plan.test.ts", - "plugins/pstack/skills/poteto-mode/scripts/resolve-codex-transcript.test.ts", "scripts/release.py", "scripts/release_test.py" + "plugins/pstack/skills/poteto-mode/scripts/resolve-codex-transcript.test.ts", "scripts/release.py", "scripts/release_test.py", "scripts/sync-port.sh" ] } From 3377cae5e407c1c6b8b1180927e6dcb0cf2abf77 Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:32:08 -0500 Subject: [PATCH 03/10] Refuse to sync over local changes or a merge that never started The script swallowed every merge failure, so a refusal to overwrite local edits still reached the unconditional manifest and provenance rewrites. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit 1215fecb14e71bcb30c28b06a53d199af0fd919e) --- scripts/sync-port.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/sync-port.sh b/scripts/sync-port.sh index 52d01741..c863e724 100755 --- a/scripts/sync-port.sh +++ b/scripts/sync-port.sh @@ -11,13 +11,18 @@ # on the manifests and UPSTREAM.md, then lists the conflicts left for a person to read. set -eu tag="$1"; version="$2" +[ -z "$(git status --porcelain)" ] || { echo "the checkout has local changes; commit or stash them first"; exit 1; } prev="$(sed -n 's/^| open-pstack version | `\([0-9.]*\)[^`]*` |$/\1/p' UPSTREAM.md)" [ -n "$prev" ] || { echo "UPSTREAM.md has no open-pstack version row"; exit 1; } prev="v$prev" git rev-parse -q --verify "$tag^{commit}" >/dev/null || { echo "unknown tag $tag; fetch upstream --tags"; exit 1; } git rev-parse -q --verify "$prev^{commit}" >/dev/null || { echo "unknown previous release $prev"; exit 1; } ours="$(git rev-parse HEAD)" -git merge --no-commit --no-ff "$tag" >/dev/null 2>&1 || true +log="$(mktemp)" +if ! git merge --no-commit --no-ff "$tag" > "$log" 2>&1 && [ -z "$(git diff --name-only --diff-filter=U)" ]; then + echo "merge of $tag did not start:"; cat "$log"; rm -f "$log"; exit 1 +fi +rm -f "$log" for f in $(git diff --name-only --diff-filter=U); do o=$(git rev-parse -q --verify "$ours:$f" 2>/dev/null || echo none) p=$(git rev-parse -q --verify "$prev:$f" 2>/dev/null || echo none) From 40050630a4dfff4c8fd9a230eaff508a372d87a3 Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:32:08 -0500 Subject: [PATCH 04/10] Map the fork's operator scripts and make the cloud test follow the branch's policy The verifier refused any PR touching front-door.py, cloud-setup.sh or the cloud test as unmapped. The cloud test asserted a passive kit, which the branch has not shipped since October 5; it now asserts the installed skill matches the source byte for byte. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit ba74600e42d7f47fda0bd226394141a44602ecd2) --- .claude/skills/verify-open-pstack/features/registry.json | 2 +- tests/cloud-setup-test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.claude/skills/verify-open-pstack/features/registry.json b/.claude/skills/verify-open-pstack/features/registry.json index c9e2c808..60a14179 100644 --- a/.claude/skills/verify-open-pstack/features/registry.json +++ b/.claude/skills/verify-open-pstack/features/registry.json @@ -83,6 +83,6 @@ ".gitignore", ".mergify.yml", "docs/**", "assets/**", "plugins/pstack/skills/poteto-mode/scripts/bootstrap.test.ts", "plugins/pstack/skills/poteto-mode/scripts/check-plan.test.ts", - "plugins/pstack/skills/poteto-mode/scripts/resolve-codex-transcript.test.ts", "scripts/release.py", "scripts/release_test.py", "scripts/sync-port.sh" + "plugins/pstack/skills/poteto-mode/scripts/resolve-codex-transcript.test.ts", "scripts/release.py", "scripts/release_test.py", "scripts/sync-port.sh", "scripts/front-door.py", "scripts/cloud-setup.sh", "tests/cloud-setup-test.sh" ] } diff --git a/tests/cloud-setup-test.sh b/tests/cloud-setup-test.sh index 8414907f..ce78d733 100755 --- a/tests/cloud-setup-test.sh +++ b/tests/cloud-setup-test.sh @@ -51,7 +51,7 @@ check "every skill is installed" test "$(ls "$dest/skills" | wc -l)" -eq "$(ls " check "every agent is installed" test "$(ls "$dest/agents" | wc -l)" -eq "$(ls "$repo/plugins/pstack/agents" | wc -l)" check "the session hook is installed and executable" test -x "$dest/hooks/session-start" check "the installed kit records its source commit" grep -qx "sha=$sha" "$dest/.cloud-kit" -check "the kit ships passive, as on the Mac" grep -q '^disable-model-invocation: true$' "$dest/skills/bro/SKILL.md" +check "the installed kit keeps the branch's invocation policy" cmp -s "$dest/skills/bro/SKILL.md" "$repo/plugins/pstack/skills/bro/SKILL.md" git -C "$kit" rm -r --quiet plugins/pstack/skills/bro mkdir -p "$kit/plugins/pstack/skills/added" && printf -- '---\nname: added\ndescription: x\n---\n' > "$kit/plugins/pstack/skills/added/SKILL.md" From d877edd6d12b93b8ce348679653e4c3b03b10cea Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:32:08 -0500 Subject: [PATCH 05/10] Record the verifier's routing adaptation in patch 6 Co-Authored-By: Claude Fable 5.1 (cherry picked from commit d4efe199d967c4a1990359c4ed7cdafa3eb58f24) --- FORK.md | 1 + 1 file changed, 1 insertion(+) diff --git a/FORK.md b/FORK.md index 7399a522..aacc1ddc 100644 --- a/FORK.md +++ b/FORK.md @@ -15,6 +15,7 @@ This fork is the pinned source for the pstack plugin on Adam Vellequette's Claud | 4 | `scripts/front-door.py`, `plugins/pstack/.front-door.json`, every `SKILL.md`, `skills/*/agents/openai.yaml` | `front-door.py passive` makes every skill explicit-only (Claude Code: `disable-model-invocation: true`; Codex: `allow_implicit_invocation: false`) and adds a read-by-path note to the router. `front-door.py active` restores the port byte for byte. The release branch shipped passive until the front-door switch on 2026-10-05; it is active since (the commit that made it so says so). | Installed skills must not steer running lanes before the front door switches. The safety review (2026-10-04) found the port lets every skill start on its own. | | 6 | `plugins/pstack/skills/poteto-mode/scripts/orch/` (`orch.ts`, `store.ts`, `orch.test.ts`), `scripts/package.json` | Kept after Cursor pstack 0.15.36 deleted them with the agentic Orchestrate playbook; the test list keeps `orch`. | The harness's `chief-of-staff` skill runs its program against this store CLI (`PSTACK_ORCH`). The playbook text no longer names it. Dropping the files is Adam's call, after the chief-of-staff runtime moves off them. | | 5 | `scripts/cloud-setup.sh`, `tests/cloud-setup-test.sh` | New files. The script installs the kit into a Claude Code cloud session as the personal skills-directory plugin `pstack@skills-dir`. | A cloud session loads no plugin from the Mac or from a repo's settings. See "Cloud sessions" below. | +| 7 | `.claude/skills/verify-open-pstack/` | `REPO` is this fork. `features/formal.ts` holds the recipes for the two formal verification skills, `skill-invocation:poteto-mode` runs a route-only case, a skill's `agents/openai.yaml` selects its Codex invocation surface, and `FORK.md`, `TEAM-INSTALL.md`, the operator scripts and the cloud-setup test are non-runtime paths. With `--account-router` and `--native-model`, `scripts/routing.ts` runs each native session through the harness account router and its `pstack-verify-run` launcher and checks the admission and completion receipts; `harness.ts` and `io.ts` carry the auth-link cleanup and cancellation handling that go with it. Dependency: `~/.agents/harness/scripts/account-router` and `pstack-verify-run`. The two formal cases run Claude with `bypassPermissions` inside their fixture, as the port's setup cases do, because Claude Code 2.1.316 refuses a `Write` under any `.claude/skills/` folder in `dontAsk` mode; a routed Claude run therefore cannot select them, while a routed Codex run can. | The verifier publishes live-gate evidence only to this fork and must exercise the surfaces the fork ships. | Last upstream sync: port release `v1.16.0`, merged 2026-11-01, with Cursor pstack 0.15.30 to 0.15.36 layered on top (the November 1, 2026 update below). Patch 3 (the two router index lines) is retired: upstream's router names both skills. From a940836afdf76b97bf43ea45401acac22b28f595 Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:35:38 -0500 Subject: [PATCH 06/10] Run the formal cases with bypassPermissions inside their fixture Claude Code 2.1.316 refuses a Write under any .claude/skills/ folder in dontAsk mode, so the creation case could not land the generated skill and the live gate failed. The port's setup cases already run this way for the same reason. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit 7bfdd73fe76ce3db317ec76d3026b6e6f6494294) --- .claude/skills/verify-open-pstack/features/formal.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.claude/skills/verify-open-pstack/features/formal.ts b/.claude/skills/verify-open-pstack/features/formal.ts index 36c095c9..8befecfc 100644 --- a/.claude/skills/verify-open-pstack/features/formal.ts +++ b/.claude/skills/verify-open-pstack/features/formal.ts @@ -60,6 +60,7 @@ function observed(record:SessionRecord, verdict:string):boolean { export function maintainFormal():Case { return { id:'stale-model', + claudePermission:'bypassPermissions', async prepare(f) { await git(f,'init','-q','-b','main'); await put(f,'capacity.mjs',ATOMIC);await put(f,'replay.mjs',REPLAY); @@ -98,6 +99,7 @@ export function maintainFormal():Case { export function createFormal():Case { return { id:'create-and-mutate', + claudePermission:'bypassPermissions', async prepare(f) { await git(f,'init','-q','-b','main'); await put(f,'capacity.mjs',ATOMIC);await put(f,'replay.mjs',REPLAY); From e44e8d2962f5531c820b4068caf80ee21c9d5178 Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:39:22 -0500 Subject: [PATCH 07/10] Judge routed eligibility by the selected harness A Claude permission override on a shared recipe refused the routed run for Codex too, which needs no override. The check is now a function with its own test. Co-Authored-By: Claude Fable 5.1 (cherry picked from commit c19fcc6efbd704e99e29938abaca30527c94bfbd) --- .claude/skills/verify-open-pstack/scripts/harness.ts | 9 +++++++-- .../skills/verify-open-pstack/scripts/routing.test.ts | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.claude/skills/verify-open-pstack/scripts/harness.ts b/.claude/skills/verify-open-pstack/scripts/harness.ts index 3eaf07ba..457f3490 100644 --- a/.claude/skills/verify-open-pstack/scripts/harness.ts +++ b/.claude/skills/verify-open-pstack/scripts/harness.ts @@ -1,6 +1,6 @@ import { copyFile, mkdir, readdir, readFile, realpath, stat } from 'node:fs/promises'; import { basename, join } from 'node:path'; -import { CLAUDE_TOOLS, recipe, type Fixture } from '../features/recipes.ts'; +import { CLAUDE_TOOLS, recipe, type Case, type Fixture } from '../features/recipes.ts'; import { requiredFeatures, requiredHarnesses } from './core.ts'; import { command, isolatedEnv, retainedFile, save, session, treeHash, type Command, type Session } from './io.ts'; import { doctor } from './doctor.ts'; @@ -11,6 +11,11 @@ import { publishable } from './verify.ts'; import { REPO, type Driver, type Harness, type Installation, type Observation, type Receipt, type SessionRecord } from './types.ts'; const setupFeature = (feature: string): boolean => feature === 'setup' || feature === 'skill-invocation:setup-pstack'; +/** The routed launcher fixes each harness's isolation, so only a case that needs its own harness's override cannot be routed. */ +export function unroutable(feature: string, harness: Harness, cases: Case[]): boolean { + return feature === 'runner' || setupFeature(feature) || feature.startsWith('agent-preload:') || + cases.some(c => harness === 'codex' ? c.codexSandbox !== undefined : c.claudePermission !== undefined); +} export function launch(harness: Harness, workspace: string, options: { cwd: string; addDirs: string[]; codexSandbox?: 'danger-full-access'; claudePermission?: 'bypassPermissions' }): string[] { const addDirs = options.addDirs.flatMap(dir => ['--add-dir', dir]); return harness === 'claude' @@ -155,7 +160,7 @@ export class MacDriver implements Driver { for (const { installation, features } of plans) { if (!this.routing.models[installation.harness]) throw new Error(`native-model-missing:${installation.harness}`); for (const { feature, cases } of features) { - if (feature === 'runner' || setupFeature(feature) || feature.startsWith('agent-preload:') || cases.some(c => c.codexSandbox || c.claudePermission)) throw new Error(`unsupported-routed-recipe:${feature}`); + if (unroutable(feature, installation.harness, cases)) throw new Error(`unsupported-routed-recipe:${feature}`); } } } diff --git a/.claude/skills/verify-open-pstack/scripts/routing.test.ts b/.claude/skills/verify-open-pstack/scripts/routing.test.ts index d0744baf..ac968563 100644 --- a/.claude/skills/verify-open-pstack/scripts/routing.test.ts +++ b/.claude/skills/verify-open-pstack/scripts/routing.test.ts @@ -4,6 +4,8 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { parse } from './cli.ts'; import { routedSession } from './routing.ts'; +import { unroutable } from './harness.ts'; +import { createFormal, maintainFormal } from '../features/formal.ts'; import type { Session } from './io.ts'; const roots:string[]=[]; afterEach(async()=>{for(const root of roots.splice(0)) await rm(root,{recursive:true,force:true});}); @@ -30,3 +32,11 @@ test('native proof rejects an incomplete admission receipt',async()=>{ if(terminal) expect((await proof).evidence).toHaveLength(3);else await expect(proof).rejects.toThrow('not-successfully-completed'); } }); +test('routed eligibility follows the selected harness',()=>{ + const formal=[createFormal(),maintainFormal()]; + expect(unroutable('skill-invocation:create-formal-verification-skill','claude',formal)).toBe(true); + expect(unroutable('skill-invocation:create-formal-verification-skill','codex',formal)).toBe(false); + expect(unroutable('skill-invocation:maintain-formal-verification-skill','codex',formal)).toBe(false); + expect(unroutable('skill-invocation:poteto-mode','claude',[])).toBe(false); + expect(unroutable('setup','codex',[])).toBe(true); +}); From 84e44014c3cc86b34c9fbb30d12be764912b3c8c Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 18:13:17 -0500 Subject: [PATCH 08/10] Read the sync commit from the skill's own record, labelled or as the git diff base The live gate's sessions record the sync point three ways: a table cell, a labelled line, or the base of the git diff command the skill tells the reader to run. The check now takes the commit from that record and compares the whole token as a prefix of the expected commit, so a stale record fails even when prose names the new head, and a history line naming the old commit does not fail a correct update. A test drives the maintain assertion itself through both outcomes. Co-Authored-By: Claude Fable 5.1 --- .../verify-open-pstack/features/formal.ts | 13 +++++-- .../verify-open-pstack/scripts/formal.test.ts | 36 +++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.claude/skills/verify-open-pstack/features/formal.ts b/.claude/skills/verify-open-pstack/features/formal.ts index 8befecfc..d8cf6bd9 100644 --- a/.claude/skills/verify-open-pstack/features/formal.ts +++ b/.claude/skills/verify-open-pstack/features/formal.ts @@ -57,6 +57,15 @@ function observed(record:SessionRecord, verdict:string):boolean { return record.tools.some(t=>!t.parent && JSON.stringify(t.input).includes('verification/check.mjs') && t.result?.includes(`"verdict":"${verdict}"`)); } +/** The commit the skill's current sync record names. Generated skills record it on a line labelled "sync commit" (a table cell or a colon, words such as "Last confirmed" may precede the label) or, when they keep no labelled record, as the base of the git diff command they tell the reader to run. A labelled record decides even when its value is not a hash. */ +export function syncCommit(skill:string):string|undefined { + const labelled=/^[\s|*-]*(?:[^\n|:]*?\b)?sync commit(?:\s*\([^)\n]*\))?\**\s*[|:]\s*([^\n]*)/im.exec(skill); + if(labelled) return /^[\s*`]*([0-9a-f]{7,40})\b/i.exec(labelled[1]!)?.[1]?.toLowerCase(); + return /\bgit diff\s+([0-9a-f]{7,40})\b/i.exec(skill)?.[1]?.toLowerCase(); +} +/** Whether the skill's sync record names this commit, abbreviated or in full. */ +export function namesCommit(skill:string,head:string):boolean { const token=syncCommit(skill); return token!==undefined && head.startsWith(token); } + export function maintainFormal():Case { return { id:'stale-model', @@ -85,7 +94,7 @@ export function maintainFormal():Case { const replay=record.tools.some(t=>JSON.stringify(t.input).includes('replay.mjs') && t.result?.includes('"used":2')); if(!replay) throw new Error('formal-counterexample-not-replayed'); const skill=await readFile(join(f.dir,'.claude/skills/verify-capacity/SKILL.md'),'utf8'); - if(!skill.includes(baseline.head)) throw new Error('formal-sync-commit-not-updated'); + if(!namesCommit(skill,baseline.head)) throw new Error('formal-sync-commit-not-updated'); const result=await readFile(join(f.dir,'result.md'),'utf8'); if(!/bug|oversubscri/i.test(result) || !/stale|drift/i.test(result)) throw new Error('formal-finding-not-reported'); // The captain independently runs the unmodified checker on the maintained model. @@ -120,7 +129,7 @@ export function createFormal():Case { if(!observed(record,'pass') || !observed(record,'bug')) throw new Error('formal-mutation-not-observed'); if(!record.tools.some(t=>JSON.stringify(t.input).includes('replay.mjs') && t.result?.includes('"used":2'))) throw new Error('formal-mutation-not-replayed'); const path=join(f.dir,'.claude/skills/verify-capacity/SKILL.md'), skill=await readFile(path,'utf8'); - if(!/^---\n[\s\S]*name:\s*verify-capacity[\s\S]*description:/m.test(skill) || !skill.includes(baseline.head) || !skill.includes('capacity.mjs') || !skill.includes('verification/check.mjs') || !/bound|two|2/i.test(skill)) throw new Error('formal-skill-contract-incomplete'); + if(!/^---\n[\s\S]*name:\s*verify-capacity[\s\S]*description:/m.test(skill) || !namesCommit(skill,baseline.head) || !skill.includes('capacity.mjs') || !skill.includes('verification/check.mjs') || !/bound|two|2/i.test(skill)) throw new Error('formal-skill-contract-incomplete'); const output=await f.run(['bun','verification/check.mjs'],{cwd:f.dir}); if(!output.includes('"verdict":"pass"')) throw new Error('formal-final-check-failed'); return {assertions:['skill-loaded','project-skill-created','coverage-and-sync-recorded','mutation-caught','mutation-replayed','code-and-model-restored','bounded-check-passes'],files:[path,join(f.dir,'result.md'),join(f.dir,'verification/model.json')]}; diff --git a/.claude/skills/verify-open-pstack/scripts/formal.test.ts b/.claude/skills/verify-open-pstack/scripts/formal.test.ts index 42526d5b..78a7b80e 100644 --- a/.claude/skills/verify-open-pstack/scripts/formal.test.ts +++ b/.claude/skills/verify-open-pstack/scripts/formal.test.ts @@ -1,9 +1,9 @@ import { afterEach, expect, test } from 'bun:test'; -import { mkdtemp, rm, writeFile } from 'node:fs/promises'; +import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { command } from './io.ts'; -import { createFormal, maintainFormal } from '../features/formal.ts'; +import { createFormal, maintainFormal, namesCommit, syncCommit } from '../features/formal.ts'; import type { Fixture } from '../features/recipes.ts'; import type { SessionRecord } from './types.ts'; const roots:string[]=[]; @@ -30,3 +30,35 @@ test('creation begins with passing code but requires mutation evidence',async()= expect(await command(['bun','verification/check.mjs'],{cwd:f.dir})).toContain('"verdict":"pass"'); await expect(c.assert(record('create-formal-verification-skill'),f)).rejects.toThrow('mutation-not-observed'); }); +test('the sync record is read from its label or the git diff base, and compared whole',()=>{ + const head='efb41f2f3838c0902016a9a97bf7e101d4b36e97', old='761782b83ad658da668937afdf9281ef2e45af56'; + expect(syncCommit('| Sync commit (last confirmed) | `efb41f2` |')).toBe('efb41f2'); + expect(syncCommit(`Last confirmed code/model sync commit: \`${head}\`.`)).toBe(head); + expect(syncCommit(`- **Sync commit**: ${head}`)).toBe(head); + expect(syncCommit(`Compare covered files with \`git diff ${head}..HEAD -- capacity.mjs\`.`)).toBe(head); + expect(syncCommit(`Sync commit: pending\n\nRun git diff ${head}..HEAD`)).toBeUndefined(); + expect(syncCommit(`Update the sync commit after checking ${head}.`)).toBeUndefined(); + expect(syncCommit(`Sync commit candidate: ${head}`)).toBeUndefined(); + expect(syncCommit(`Sync commit has not been updated; counterexample reproduced at: ${head}`)).toBeUndefined(); + expect(namesCommit('| Sync commit | `efb41f20` |',head)).toBe(false); + expect(namesCommit('| Sync commit | `0000000` |',head)).toBe(false); + expect(namesCommit(`Sync commit: ${head.slice(0,7)}\n\nHistory: the stale model previously described ${old}.`,head)).toBe(true); + expect(namesCommit(`Sync commit: ${old}\n\nCounterexample reproduced on HEAD ${head.slice(0,7)}.`,head)).toBe(false); +}); +test('maintenance proves the sync moved by the skill\'s own record, whatever else it mentions',async()=>{ + const f=await fixture(),c=maintainFormal();await c.prepare!(f); + const path=join(f.dir,'.claude/skills/verify-capacity/SKILL.md'); + const stale=/Sync commit: ([0-9a-f]{40})/.exec(await readFile(path,'utf8'))![1]!; + const baseline=JSON.parse(await readFile(`${f.dir}.formal-baseline.json`,'utf8')); + await writeFile(join(f.dir,'verification/model.json'),JSON.stringify({clients:2,limit:1,splitReservation:true})); + await writeFile(join(f.dir,'result.md'),'A real bug: the stale model passed while the split reserve oversubscribes.'); + const tool=(command:string,result:string)=>({name:'Bash',id:command,input:{command},parent:null,result,failed:false}); + const done={...record('maintain-formal-verification-skill'),tools:[tool('bun verification/check.mjs','{"verdict":"pass"}'),tool('bun verification/check.mjs','{"verdict":"bug"}'),tool('bun replay.mjs','{"used":2,"limit":1}')]}; + const skill=(body:string)=>writeFile(path,`---\nname: verify-capacity\ndescription: x\n---\n${body}\n`); + await skill(`Sync commit: ${stale}\n\nCounterexample reproduced on HEAD ${baseline.head.slice(0,7)}.`); + await expect(c.assert(done,f)).rejects.toThrow('sync-commit-not-updated'); + await skill(`Sync commit: pending\n\nRun git diff ${baseline.head}..HEAD -- capacity.mjs`); + await expect(c.assert(done,f)).rejects.toThrow('sync-commit-not-updated'); + await skill(`Sync commit: ${baseline.head.slice(0,7)}\n\nHistory: the stale model previously described ${stale}.`); + await expect(c.assert(done,f)).resolves.toBeDefined(); +}); From e12dbe3341a02cba4c71bdba4853725b409643da Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 18:18:47 -0500 Subject: [PATCH 09/10] Answer the review of the follow-up: guard the sync script, mandate the sync-commit line The sync script no longer overwrites the fork's provenance files, refuses a tag already merged, and leaves a file one side deleted for a person; tests/sync-port-test.sh exercises it on a throwaway history and runs with the static invariants. The two formal fixture prompts ask for one line, "Sync commit: ", and the parser reads only that label, so words before it and prose do not count and records naming different commits count as none. Co-Authored-By: Claude Fable 5.1 --- .../verify-open-pstack/features/formal.ts | 12 +++--- .../verify-open-pstack/features/registry.json | 2 +- .../verify-open-pstack/scripts/formal.test.ts | 12 ++++-- package.json | 2 +- scripts/sync-port.sh | 22 ++++++----- tests/sync-port-test.sh | 37 +++++++++++++++++++ 6 files changed, 66 insertions(+), 21 deletions(-) create mode 100755 tests/sync-port-test.sh diff --git a/.claude/skills/verify-open-pstack/features/formal.ts b/.claude/skills/verify-open-pstack/features/formal.ts index d8cf6bd9..6b82ed20 100644 --- a/.claude/skills/verify-open-pstack/features/formal.ts +++ b/.claude/skills/verify-open-pstack/features/formal.ts @@ -57,11 +57,11 @@ function observed(record:SessionRecord, verdict:string):boolean { return record.tools.some(t=>!t.parent && JSON.stringify(t.input).includes('verification/check.mjs') && t.result?.includes(`"verdict":"${verdict}"`)); } -/** The commit the skill's current sync record names. Generated skills record it on a line labelled "sync commit" (a table cell or a colon, words such as "Last confirmed" may precede the label) or, when they keep no labelled record, as the base of the git diff command they tell the reader to run. A labelled record decides even when its value is not a hash. */ +/** The commit the skill's `Sync commit:` record names. The fixture prompts ask for that line, as a plain line, a list item, a bold label or a table cell; words before the label do not count. Records that name different commits are ambiguous and count as none. */ export function syncCommit(skill:string):string|undefined { - const labelled=/^[\s|*-]*(?:[^\n|:]*?\b)?sync commit(?:\s*\([^)\n]*\))?\**\s*[|:]\s*([^\n]*)/im.exec(skill); - if(labelled) return /^[\s*`]*([0-9a-f]{7,40})\b/i.exec(labelled[1]!)?.[1]?.toLowerCase(); - return /\bgit diff\s+([0-9a-f]{7,40})\b/i.exec(skill)?.[1]?.toLowerCase(); + const values=[...skill.matchAll(/^[\s|*-]*sync commit\**\s*[|:][\s*`]*([0-9a-f]{7,40})\b/gim)].map(m=>m[1]!.toLowerCase()); + const longest=values.reduce((a,b)=>b.length>a.length?b:a,''); + return longest && values.every(v=>longest.startsWith(v)) ? longest : undefined; } /** Whether the skill's sync record names this commit, abbreviated or in full. */ export function namesCommit(skill:string,head:string):boolean { const token=syncCommit(skill); return token!==undefined && head.startsWith(token); } @@ -82,7 +82,7 @@ export function maintainFormal():Case { const head=await commit(f,'Yield during capacity reservation',['capacity.mjs']); await writeFile(`${f.dir}.formal-baseline.json`,JSON.stringify({head,product:sha256(SPLIT),checker:sha256(CHECKER)})); }, - prompt:f=>request(f,'maintain-formal-verification-skill','Maintain .claude/skills/verify-capacity/SKILL.md. A change to reserve landed after its sync commit. The existing checker is an exhaustive bounded-state interpreter; keep verification/check.mjs and its two-client, capacity-one bounds unchanged. Update the model from the current code, run the check before and after, replay any counterexample with bun replay.mjs, and report whether the old pass was stale and whether the current code has a bug.'), + prompt:f=>request(f,'maintain-formal-verification-skill','Maintain .claude/skills/verify-capacity/SKILL.md. A change to reserve landed after its sync commit. The existing checker is an exhaustive bounded-state interpreter; keep verification/check.mjs and its two-client, capacity-one bounds unchanged. Update the model from the current code, run the check before and after, replay any counterexample with bun replay.mjs, record the new sync commit on its own line as "Sync commit: " once the model describes the current code, and report whether the old pass was stale and whether the current code has a bug.'), async assert(record,f) { loaded(record,'maintain-formal-verification-skill'); const baseline=JSON.parse(await readFile(`${f.dir}.formal-baseline.json`,'utf8')); @@ -118,7 +118,7 @@ export function createFormal():Case { const head=await commit(f,'Atomic capacity module and bounded verification tool',['capacity.mjs','replay.mjs','verification/check.mjs','verification/model.json','README.md']); await writeFile(`${f.dir}.formal-baseline.json`,JSON.stringify({head,product:sha256(ATOMIC),checker:sha256(CHECKER)})); }, - prompt:f=>request(f,'create-formal-verification-skill',`Create .claude/skills/verify-capacity/SKILL.md for reserve's capacity invariant. Use the bundled exhaustive bounded model checker (bun verification/check.mjs); keep its interpreter and two-client, capacity-one scope unchanged. Confirm the model matches capacity.mjs. The only authorized product edit is the skill's disposable mutation test: split reserve's check and increment with an await, reflect that split in the model, observe the failure and replay it, then restore both code and model. Record the checked commit, coverage, assumptions, bounds, command and how to distinguish model drift from a bug. Follow the generated skill and report the evidence. The scratch mutation is explicitly permitted by this fixture.`).replace('or change product code.', 'or change product code except for the explicitly permitted scratch mutation.'), + prompt:f=>request(f,'create-formal-verification-skill',`Create .claude/skills/verify-capacity/SKILL.md for reserve's capacity invariant. Use the bundled exhaustive bounded model checker (bun verification/check.mjs); keep its interpreter and two-client, capacity-one scope unchanged. Confirm the model matches capacity.mjs. The only authorized product edit is the skill's disposable mutation test: split reserve's check and increment with an await, reflect that split in the model, observe the failure and replay it, then restore both code and model. Record the checked commit on its own line as "Sync commit: ", then the coverage, assumptions, bounds, command and how to distinguish model drift from a bug. Follow the generated skill and report the evidence. The scratch mutation is explicitly permitted by this fixture.`).replace('or change product code.', 'or change product code except for the explicitly permitted scratch mutation.'), async assert(record,f) { loaded(record,'create-formal-verification-skill'); const baseline=JSON.parse(await readFile(`${f.dir}.formal-baseline.json`,'utf8')); diff --git a/.claude/skills/verify-open-pstack/features/registry.json b/.claude/skills/verify-open-pstack/features/registry.json index 60a14179..d82807cd 100644 --- a/.claude/skills/verify-open-pstack/features/registry.json +++ b/.claude/skills/verify-open-pstack/features/registry.json @@ -83,6 +83,6 @@ ".gitignore", ".mergify.yml", "docs/**", "assets/**", "plugins/pstack/skills/poteto-mode/scripts/bootstrap.test.ts", "plugins/pstack/skills/poteto-mode/scripts/check-plan.test.ts", - "plugins/pstack/skills/poteto-mode/scripts/resolve-codex-transcript.test.ts", "scripts/release.py", "scripts/release_test.py", "scripts/sync-port.sh", "scripts/front-door.py", "scripts/cloud-setup.sh", "tests/cloud-setup-test.sh" + "plugins/pstack/skills/poteto-mode/scripts/resolve-codex-transcript.test.ts", "scripts/release.py", "scripts/release_test.py", "scripts/sync-port.sh", "scripts/front-door.py", "scripts/cloud-setup.sh", "tests/cloud-setup-test.sh", "tests/sync-port-test.sh" ] } diff --git a/.claude/skills/verify-open-pstack/scripts/formal.test.ts b/.claude/skills/verify-open-pstack/scripts/formal.test.ts index 78a7b80e..39db3b50 100644 --- a/.claude/skills/verify-open-pstack/scripts/formal.test.ts +++ b/.claude/skills/verify-open-pstack/scripts/formal.test.ts @@ -30,16 +30,20 @@ test('creation begins with passing code but requires mutation evidence',async()= expect(await command(['bun','verification/check.mjs'],{cwd:f.dir})).toContain('"verdict":"pass"'); await expect(c.assert(record('create-formal-verification-skill'),f)).rejects.toThrow('mutation-not-observed'); }); -test('the sync record is read from its label or the git diff base, and compared whole',()=>{ +test('the sync record is the Sync commit line, compared whole; ambiguity and prose count as none',()=>{ const head='efb41f2f3838c0902016a9a97bf7e101d4b36e97', old='761782b83ad658da668937afdf9281ef2e45af56'; - expect(syncCommit('| Sync commit (last confirmed) | `efb41f2` |')).toBe('efb41f2'); - expect(syncCommit(`Last confirmed code/model sync commit: \`${head}\`.`)).toBe(head); + expect(syncCommit('| Sync commit | `efb41f2` |')).toBe('efb41f2'); + expect(syncCommit(`Sync commit: ${head}`)).toBe(head); expect(syncCommit(`- **Sync commit**: ${head}`)).toBe(head); - expect(syncCommit(`Compare covered files with \`git diff ${head}..HEAD -- capacity.mjs\`.`)).toBe(head); + expect(syncCommit(`Sync commit: ${head.slice(0,7)}\n\n| Sync commit | ${head} |`)).toBe(head); + expect(syncCommit(`Previous sync commit: ${old}\n\nSync commit: ${head}`)).toBe(head); + expect(syncCommit(`Last confirmed code/model sync commit: ${head}`)).toBeUndefined(); + expect(syncCommit(`Compare with git diff ${head}..HEAD`)).toBeUndefined(); expect(syncCommit(`Sync commit: pending\n\nRun git diff ${head}..HEAD`)).toBeUndefined(); expect(syncCommit(`Update the sync commit after checking ${head}.`)).toBeUndefined(); expect(syncCommit(`Sync commit candidate: ${head}`)).toBeUndefined(); expect(syncCommit(`Sync commit has not been updated; counterexample reproduced at: ${head}`)).toBeUndefined(); + expect(syncCommit(`Sync commit: ${old}\n\nSync commit: ${head}`)).toBeUndefined(); expect(namesCommit('| Sync commit | `efb41f20` |',head)).toBe(false); expect(namesCommit('| Sync commit | `0000000` |',head)).toBe(false); expect(namesCommit(`Sync commit: ${head.slice(0,7)}\n\nHistory: the stale model previously described ${old}.`,head)).toBe(true); diff --git a/package.json b/package.json index 4560426a..bd836db6 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,6 @@ "scripts": { "test": "cd plugins/pstack/skills/poteto-mode/scripts && bun install --frozen-lockfile && bun run test", "typecheck": "cd plugins/pstack/skills/poteto-mode/scripts && bun install --frozen-lockfile && bun run typecheck", - "static": "bun -e 'for (const path of process.argv.slice(1)) JSON.parse(await Bun.file(path).text())' .claude-plugin/marketplace.json .agents/plugins/marketplace.json plugins/pstack/.claude-plugin/plugin.json plugins/pstack/.codex-plugin/plugin.json && PSTACK_STATIC_ONLY=1 bash tests/skill-collision-repro.sh" + "static": "bun -e 'for (const path of process.argv.slice(1)) JSON.parse(await Bun.file(path).text())' .claude-plugin/marketplace.json .agents/plugins/marketplace.json plugins/pstack/.claude-plugin/plugin.json plugins/pstack/.codex-plugin/plugin.json && PSTACK_STATIC_ONLY=1 bash tests/skill-collision-repro.sh && bash tests/sync-port-test.sh" } } diff --git a/scripts/sync-port.sh b/scripts/sync-port.sh index c863e724..23dea3b1 100755 --- a/scripts/sync-port.sh +++ b/scripts/sync-port.sh @@ -3,12 +3,14 @@ # # scripts/sync-port.sh e.g. v1.16.0 1.16.0-adam.20261101 # -# Run on a branch cut from adam/release with the `upstream` remote (ericlitman/open-pstack) +# Run on a clean branch cut from adam/release with the `upstream` remote (ericlitman/open-pstack) # fetched. The merge's natural base is the last port release the fork merged, so every file # the fork squash-imported since then conflicts. The script resolves what needs no judgment: # a file whose fork copy equals the previous port release's copy takes the new release's copy, -# and the rest re-merge three-way against that previous release. It stamps the fork version -# on the manifests and UPSTREAM.md, then lists the conflicts left for a person to read. +# and the rest re-merge three-way against that previous release. A file one side deleted, and +# every conflict that survives the three-way merge, stays for a person to read; the fork's +# provenance files (FORK.md, CHANGES.md, NOTICE.md, UPSTREAM.md) merge like any other. It stamps +# the fork version on the manifests and, when it merged cleanly, on UPSTREAM.md's version row. set -eu tag="$1"; version="$2" [ -z "$(git status --porcelain)" ] || { echo "the checkout has local changes; commit or stash them first"; exit 1; } @@ -17,7 +19,9 @@ prev="$(sed -n 's/^| open-pstack version | `\([0-9.]*\)[^`]*` |$/\1/p' UPSTREAM. prev="v$prev" git rev-parse -q --verify "$tag^{commit}" >/dev/null || { echo "unknown tag $tag; fetch upstream --tags"; exit 1; } git rev-parse -q --verify "$prev^{commit}" >/dev/null || { echo "unknown previous release $prev"; exit 1; } +if git merge-base --is-ancestor "$tag" HEAD; then echo "$tag is already merged into this branch"; exit 1; fi ours="$(git rev-parse HEAD)" +inplace() { local file="$1"; shift; sed -E "$@" "$file" > "$file.tmp" && mv "$file.tmp" "$file"; } log="$(mktemp)" if ! git merge --no-commit --no-ff "$tag" > "$log" 2>&1 && [ -z "$(git diff --name-only --diff-filter=U)" ]; then echo "merge of $tag did not start:"; cat "$log"; rm -f "$log"; exit 1 @@ -27,21 +31,21 @@ for f in $(git diff --name-only --diff-filter=U); do o=$(git rev-parse -q --verify "$ours:$f" 2>/dev/null || echo none) p=$(git rev-parse -q --verify "$prev:$f" 2>/dev/null || echo none) t=$(git rev-parse -q --verify "$tag:$f" 2>/dev/null || echo none) + if [ "$o" = none ] || [ "$p" = none ] || [ "$t" = none ]; then continue; fi if [ "$o" = "$p" ] || [ "$o" = "$t" ]; then git checkout --quiet "$tag" -- "$f"; git add -- "$f"; continue; fi if [ "$p" = "$t" ]; then git checkout --quiet "$ours" -- "$f"; git add -- "$f"; continue; fi tmp=$(mktemp -d) - git show "$ours:$f" > "$tmp/ours"; git show "$prev:$f" > "$tmp/prev" 2>/dev/null || : > "$tmp/prev"; git show "$tag:$f" > "$tmp/tag" + git show "$ours:$f" > "$tmp/ours"; git show "$prev:$f" > "$tmp/prev"; git show "$tag:$f" > "$tmp/tag" if git merge-file -p -L fork -L "$prev" -L "$tag" "$tmp/ours" "$tmp/prev" "$tmp/tag" > "$f"; then git add -- "$f"; fi rm -rf "$tmp" done for f in .claude-plugin/marketplace.json plugins/pstack/.claude-plugin/plugin.json plugins/pstack/.codex-plugin/plugin.json; do git show "$tag:$f" > "$f" - sed -i '' -E "s/(\"version\": \")[^\"]+(\")/\1$version\2/" "$f"; git add -- "$f" + inplace "$f" "s/(\"version\": \")[^\"]+(\")/\1$version\2/"; git add -- "$f" done -# The port owns its provenance files; the fork records itself in FORK.md and one CHANGES.md section. -for f in NOTICE.md CHANGES.md; do git show "$tag:$f" > "$f"; git add -- "$f"; done -git show "$tag:UPSTREAM.md" > UPSTREAM.md -sed -i '' -E "s/^(\| open-pstack version \| \`)[^\`]+(\` \|)/\1$version\2/" UPSTREAM.md; git add -- UPSTREAM.md +if ! git diff --name-only --diff-filter=U | grep -qx UPSTREAM.md; then + inplace UPSTREAM.md "s/^(\| open-pstack version \| \`)[^\`]+(\` \|)/\1$version\2/"; git add -- UPSTREAM.md +fi left="$(git diff --name-only --diff-filter=U)" if [ -z "$left" ]; then echo "merged $tag with no conflicts left; read the diff, then commit"; else echo "merged $tag; resolve these by hand, then commit:"; echo "$left"; fi diff --git a/tests/sync-port-test.sh b/tests/sync-port-test.sh new file mode 100755 index 00000000..2a58776f --- /dev/null +++ b/tests/sync-port-test.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Exercise scripts/sync-port.sh on a throwaway history: a fork branch and a port release tag. +set -u +repo="$(cd "$(dirname "$0")/.." && pwd)"; script="$repo/scripts/sync-port.sh" +tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT +fail=0 +check() { local name="$1"; shift; if "$@" >/dev/null 2>&1; then echo "ok: $name"; else echo "FAIL: $name"; fail=1; fi; } +g() { git -C "$tmp/r" -c user.name=fixture -c user.email=fixture@example.invalid -c commit.gpgsign=false "$@"; } +manifests() { for m in .claude-plugin/marketplace.json plugins/pstack/.claude-plugin/plugin.json plugins/pstack/.codex-plugin/plugin.json; do printf '{\n "name": "pstack",\n "version": "%s"\n}\n' "$1" > "$tmp/r/$m"; done; } +mkdir -p "$tmp/r/.claude-plugin" "$tmp/r/plugins/pstack/.claude-plugin" "$tmp/r/plugins/pstack/.codex-plugin" +g init -q -b port +manifests 1.0.0; printf '| open-pstack version | `1.0.0` |\n' > "$tmp/r/UPSTREAM.md"; echo base > "$tmp/r/shared.md"; echo base > "$tmp/r/gone.md"; echo base > "$tmp/r/port-only.md" +g add -A && g commit -qm base && g tag v1.0.0 +g checkout -qb fork +echo fork > "$tmp/r/fork-only.md"; echo "fork change" >> "$tmp/r/shared.md"; echo "fork edit" >> "$tmp/r/gone.md"; printf '| open-pstack version | `1.0.0-fork` |\n' > "$tmp/r/UPSTREAM.md" +g add -A && g commit -qm fork +g checkout -q port +manifests 1.1.0; printf '| open-pstack version | `1.1.0` |\n' > "$tmp/r/UPSTREAM.md"; echo "port change" >> "$tmp/r/shared.md"; echo "port change" >> "$tmp/r/port-only.md"; g rm -q gone.md +g add -A && g commit -qm port && g tag v1.1.0 +g checkout -q fork + +echo x >> "$tmp/r/fork-only.md" +check "a dirty checkout is refused" bash -c "cd '$tmp/r' && ! bash '$script' v1.1.0 1.1.0-fork" +g checkout -q -- fork-only.md +check "an already merged tag is refused" bash -c "cd '$tmp/r' && ! bash '$script' v1.0.0 1.0.0-fork" +check "nothing was staged by a refused run" test -z "$(g diff --cached --name-only)" + +(cd "$tmp/r" && bash "$script" v1.1.0 1.1.0-fork > "$tmp/out" 2>&1) +check "the sync lists the content conflict it left" grep -qx shared.md "$tmp/out" +check "a file one side deleted is left for a person" grep -qx gone.md "$tmp/out" +check "a conflicted provenance file is left for a person" grep -qx UPSTREAM.md "$tmp/out" +check "the port's clean change is taken" grep -q "port change" "$tmp/r/port-only.md" +check "the fork's own file survives" grep -qx fork "$tmp/r/fork-only.md" +check "the manifests carry the fork version" grep -q '"1.1.0-fork"' "$tmp/r/plugins/pstack/.codex-plugin/plugin.json" +check "a conflicted UPSTREAM.md is not stamped" grep -q '^<<<<<<<' "$tmp/r/UPSTREAM.md" +[ "$fail" -eq 0 ] && echo "sync-port: all checks passed" +exit "$fail" From 8775340519d81079072caf592154757e8c689b4f Mon Sep 17 00:00:00 2001 From: Adam Vellequette <249975382+fitziboy3-source@users.noreply.github.com> Date: Sun, 1 Nov 2026 18:22:34 -0500 Subject: [PATCH 10/10] Reject a revision expression as a sync record; give the sync test its own git identity "Sync commit: ^" named a different commit than it declared and passed. The record's value must now be a bare hash, optionally quoted, followed by nothing but punctuation or prose. The sync-port test sets user.name and user.email inside its throwaway repository, so the merge under test does not depend on the runner's git identity. Co-Authored-By: Claude Fable 5.1 --- .claude/skills/verify-open-pstack/features/formal.ts | 11 +++++++---- .../skills/verify-open-pstack/scripts/formal.test.ts | 6 ++++++ tests/sync-port-test.sh | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.claude/skills/verify-open-pstack/features/formal.ts b/.claude/skills/verify-open-pstack/features/formal.ts index 6b82ed20..38c754ae 100644 --- a/.claude/skills/verify-open-pstack/features/formal.ts +++ b/.claude/skills/verify-open-pstack/features/formal.ts @@ -57,11 +57,14 @@ function observed(record:SessionRecord, verdict:string):boolean { return record.tools.some(t=>!t.parent && JSON.stringify(t.input).includes('verification/check.mjs') && t.result?.includes(`"verdict":"${verdict}"`)); } -/** The commit the skill's `Sync commit:` record names. The fixture prompts ask for that line, as a plain line, a list item, a bold label or a table cell; words before the label do not count. Records that name different commits are ambiguous and count as none. */ +/** The commit the skill's `Sync commit:` record names. The fixture prompts ask for that line, as a plain line, a list item, a bold label or a table cell; words before the label do not count, and a value that is not a bare hash (a revision such as `^` or `..HEAD`) counts as none. Records that name different commits are ambiguous and count as none. */ export function syncCommit(skill:string):string|undefined { - const values=[...skill.matchAll(/^[\s|*-]*sync commit\**\s*[|:][\s*`]*([0-9a-f]{7,40})\b/gim)].map(m=>m[1]!.toLowerCase()); - const longest=values.reduce((a,b)=>b.length>a.length?b:a,''); - return longest && values.every(v=>longest.startsWith(v)) ? longest : undefined; + const values=[...skill.matchAll(/^[\s|*-]*sync commit\**\s*[|:]([^\n]*)/gim)] + .map(m=>/^[\s*`]*([0-9a-f]{7,40})(?=[`*]*(?:[\s|,;)]|\.(?!\.)|$))/i.exec(m[1]!)?.[1]?.toLowerCase()); + if(values.some(v=>v===undefined)) return undefined; + const found=values as string[]; + const longest=found.reduce((a,b)=>b.length>a.length?b:a,''); + return longest && found.every(v=>longest.startsWith(v)) ? longest : undefined; } /** Whether the skill's sync record names this commit, abbreviated or in full. */ export function namesCommit(skill:string,head:string):boolean { const token=syncCommit(skill); return token!==undefined && head.startsWith(token); } diff --git a/.claude/skills/verify-open-pstack/scripts/formal.test.ts b/.claude/skills/verify-open-pstack/scripts/formal.test.ts index 39db3b50..3cc1d72e 100644 --- a/.claude/skills/verify-open-pstack/scripts/formal.test.ts +++ b/.claude/skills/verify-open-pstack/scripts/formal.test.ts @@ -44,6 +44,12 @@ test('the sync record is the Sync commit line, compared whole; ambiguity and pro expect(syncCommit(`Sync commit candidate: ${head}`)).toBeUndefined(); expect(syncCommit(`Sync commit has not been updated; counterexample reproduced at: ${head}`)).toBeUndefined(); expect(syncCommit(`Sync commit: ${old}\n\nSync commit: ${head}`)).toBeUndefined(); + expect(syncCommit(`Sync commit: ${head}^`)).toBeUndefined(); + expect(syncCommit(`Sync commit: ${head}~1`)).toBeUndefined(); + expect(syncCommit(`Sync commit: ${head}..HEAD`)).toBeUndefined(); + expect(syncCommit(`Sync commit: ${head}:capacity.mjs`)).toBeUndefined(); + expect(syncCommit(`Sync commit: \`${head.slice(0,7)}\`. At this commit the model was read against reserve.`)).toBe(head.slice(0,7)); + expect(syncCommit(`Sync commit: ${head}, confirmed 2026-11-01`)).toBe(head); expect(namesCommit('| Sync commit | `efb41f20` |',head)).toBe(false); expect(namesCommit('| Sync commit | `0000000` |',head)).toBe(false); expect(namesCommit(`Sync commit: ${head.slice(0,7)}\n\nHistory: the stale model previously described ${old}.`,head)).toBe(true); diff --git a/tests/sync-port-test.sh b/tests/sync-port-test.sh index 2a58776f..8f6bf7ee 100755 --- a/tests/sync-port-test.sh +++ b/tests/sync-port-test.sh @@ -5,10 +5,10 @@ repo="$(cd "$(dirname "$0")/.." && pwd)"; script="$repo/scripts/sync-port.sh" tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT fail=0 check() { local name="$1"; shift; if "$@" >/dev/null 2>&1; then echo "ok: $name"; else echo "FAIL: $name"; fail=1; fi; } -g() { git -C "$tmp/r" -c user.name=fixture -c user.email=fixture@example.invalid -c commit.gpgsign=false "$@"; } +g() { git -C "$tmp/r" "$@"; } manifests() { for m in .claude-plugin/marketplace.json plugins/pstack/.claude-plugin/plugin.json plugins/pstack/.codex-plugin/plugin.json; do printf '{\n "name": "pstack",\n "version": "%s"\n}\n' "$1" > "$tmp/r/$m"; done; } mkdir -p "$tmp/r/.claude-plugin" "$tmp/r/plugins/pstack/.claude-plugin" "$tmp/r/plugins/pstack/.codex-plugin" -g init -q -b port +g init -q -b port && g config user.name fixture && g config user.email fixture@example.invalid && g config commit.gpgsign false manifests 1.0.0; printf '| open-pstack version | `1.0.0` |\n' > "$tmp/r/UPSTREAM.md"; echo base > "$tmp/r/shared.md"; echo base > "$tmp/r/gone.md"; echo base > "$tmp/r/port-only.md" g add -A && g commit -qm base && g tag v1.0.0 g checkout -qb fork