run-pilot.sh bash
178 lines 7.8 KB
Raw
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 10 hours ago
1 #!/usr/bin/env bash
2 #
3 # Muse commit pilot (Phase 7A, Step 7A-14) — reproducible driver.
4 #
5 # Proves the canonical → projection → Muse commit loop end-to-end on our own repo-guidance
6 # Flow `flow_overseer_handover`, extending the 7A-12 anti-drift demo with Muse as the durable
7 # write surface:
8 # 1. Generate marker-first projections from canonical v0.1.0 into the pilot workspace.
9 # 2. Muse-commit the baseline artifacts on feat/flow-projection-pilot.
10 # 3. Bump canonical to v0.2.0, regenerate, capture clean diff (only canonical change).
11 # 4. Muse-commit the updated artifacts; record before/after SHAs + muse diff.
12 # 5. Anti-drift gates: delete+regenerate byte-identical; hand-edit caught; staleness caught.
13 #
14 # Scope fence (7A-14): pilot + evidence only. Does NOT touch flows/starter/, the live data store,
15 # real AGENTS.md, .cursor/rules/, FLOW_LIVE_READ_AUTHORIZED, flow run, or MuseHub enrichment.
16 set -uo pipefail
17
18 REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
19 cd "$REPO_ROOT"
20
21 KNOWTATION_MUSE="muse -C $REPO_ROOT"
22 EV="docs/evidence/7A-14"
23 ART="$EV/artifacts"
24 WS="$EV/pilot-workspace"
25 V1="docs/evidence/7A-12/demo-starters/v1"
26 V2="docs/evidence/7A-12/demo-starters/v2"
27 STORE_ROOT="$(mktemp -d)"
28 export KNOWTATION_DATA_DIR="$STORE_ROOT/data"
29
30 FLOW="flow_overseer_handover"
31 RUNBOOK_OUT="$WS/overseer.AGENTS.md"
32 CURSOR_OUT="$WS/overseer.cursor.mdc"
33
34 TRANSCRIPT="$ART/transcript.txt"
35 SHA_BEFORE="$ART/muse-sha-before.txt"
36 SHA_AFTER="$ART/muse-sha-after.txt"
37 MUSE_DIFF="$ART/muse-commit.v1-to-v2.diff"
38
39 mkdir -p "$KNOWTATION_DATA_DIR" "$ART" "$WS"
40 : > "$TRANSCRIPT"
41
42 log() { printf '%s\n' "$*" | tee -a "$TRANSCRIPT"; }
43 run() {
44 local label="$1"; shift
45 log ""
46 log "### $label"
47 log "\$ $*"
48 "$@" >>"$TRANSCRIPT" 2>&1
49 local rc=$?
50 log "[exit=$rc]"
51 return 0
52 }
53
54 log "=== Muse commit pilot (7A-14) ==="
55 log "repo: $REPO_ROOT"
56 log "store: $KNOWTATION_DATA_DIR"
57 log "pilot workspace: $WS"
58
59 # --- Dependency gate: branch + Muse HEAD (7A-10b/7A-11b/7A-12 baseline) --------------------
60 run "0a. muse status (dependency gate)" $KNOWTATION_MUSE status
61 BRANCH=$($KNOWTATION_MUSE status 2>/dev/null | awk '/^On branch/{print $3}')
62 if [[ "$BRANCH" != "feat/flow-projection-pilot" ]]; then
63 log "FATAL: expected branch feat/flow-projection-pilot, got: ${BRANCH:-unknown}"
64 exit 1
65 fi
66
67 # --- Stage A: seed canonical v0.1.0, generate baseline projections ------------------------
68 node -e "import('./lib/flow/flow-store.mjs').then(m=>{const r=m.seedStarterFlows(process.env.KNOWTATION_DATA_DIR,'default',{starterDir:'$V1'});console.log('seed v1',JSON.stringify(r));})" | tee -a "$TRANSCRIPT"
69
70 run "1a. generate cli_runbook @ v0.1.0 → pilot workspace" \
71 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --out "$RUNBOOK_OUT"
72 run "1b. generate cursor_rule @ v0.1.0 → pilot workspace" \
73 node cli/index.mjs flow project "$FLOW" --harness cursor_rule --out "$CURSOR_OUT"
74 run "1c. --check baseline cli_runbook (expect drift=false, exit 0)" \
75 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --out "$RUNBOOK_OUT" --check
76
77 # --- Stage B: Muse commit v0.1.0 baseline -------------------------------------------------
78 $KNOWTATION_MUSE log -1 | tee "$SHA_BEFORE" | tee -a "$TRANSCRIPT"
79 SHA_BEFORE_VAL=$($KNOWTATION_MUSE log -1 | sed -n 's/^commit \(sha256:[^ ]*\).*/\1/p')
80 log "sha before pilot commits: $SHA_BEFORE_VAL"
81
82 run "2a. muse code add pilot workspace + evidence driver" \
83 $KNOWTATION_MUSE code add "$WS" "$EV/run-pilot.sh"
84 run "2b. muse commit v0.1.0 pilot baseline" \
85 $KNOWTATION_MUSE commit -m "$(cat <<'EOF'
86 feat(flow): 7A-14 Muse commit pilot baseline @ v0.1.0
87
88 Generate repo-guidance projections (cli_runbook + cursor_rule) from canonical
89 flow_overseer_handover v0.1.0 into docs/evidence/7A-14/pilot-workspace/ and
90 Muse-commit them as the durable write surface. Pilot only — real AGENTS.md and
91 .cursor/rules untouched; throwaway store; posture unchanged.
92
93 EOF
94 )"
95
96 COMMIT_V1=$($KNOWTATION_MUSE log -1 | sed -n 's/^commit \(sha256:[^ ]*\).*/\1/p')
97 log "commit v0.1.0 sha: $COMMIT_V1"
98
99 # --- Stage C: canonical v0.2.0, regenerate, capture anti-drift diff -----------------------
100 node -e "import('./lib/flow/flow-store.mjs').then(m=>{const r=m.seedStarterFlows(process.env.KNOWTATION_DATA_DIR,'default',{starterDir:'$V2'});console.log('seed v2',JSON.stringify(r));})" | tee -a "$TRANSCRIPT"
101
102 cp "$RUNBOOK_OUT" "$ART/overseer.AGENTS.v0.1.0.md"
103 cp "$CURSOR_OUT" "$ART/overseer.v0.1.0.mdc"
104
105 run "3a. regenerate cli_runbook @ v0.2.0" \
106 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --out "$RUNBOOK_OUT"
107 run "3b. regenerate cursor_rule @ v0.2.0" \
108 node cli/index.mjs flow project "$FLOW" --harness cursor_rule --out "$CURSOR_OUT"
109
110 cp "$RUNBOOK_OUT" "$ART/overseer.AGENTS.v0.2.0.md"
111 cp "$CURSOR_OUT" "$ART/overseer.v0.2.0.mdc"
112
113 log ""
114 log "### 3c. anti-drift diff v0.1.0 → v0.2.0 (cli_runbook)"
115 diff -u "$ART/overseer.AGENTS.v0.1.0.md" "$ART/overseer.AGENTS.v0.2.0.md" | tee "$ART/overseer.runbook.v1-to-v2.diff" | tee -a "$TRANSCRIPT"
116 log "[diff captured: $ART/overseer.runbook.v1-to-v2.diff]"
117
118 log ""
119 log "### 3d. anti-drift diff v0.1.0 → v0.2.0 (cursor_rule)"
120 diff -u "$ART/overseer.v0.1.0.mdc" "$ART/overseer.v0.2.0.mdc" | tee "$ART/overseer.cursor.v1-to-v2.diff" | tee -a "$TRANSCRIPT"
121 log "[diff captured: $ART/overseer.cursor.v1-to-v2.diff]"
122
123 # --- Stage D: Muse commit v0.2.0 + record muse diff between commits -------------------------
124 run "4a. muse code add updated pilot workspace" $KNOWTATION_MUSE code add "$WS"
125 run "4b. muse commit v0.2.0 pilot update" \
126 $KNOWTATION_MUSE commit -m "$(cat <<'EOF'
127 feat(flow): 7A-14 Muse commit pilot update @ v0.2.0
128
129 Regenerate pilot-workspace projections after canonical flow_overseer_handover
130 0.1.0→0.2.0 bump. Diff carries only the canonical summary change + marker version
131 (anti-drift proven in docs/evidence/7A-14/artifacts/). Pilot only.
132
133 EOF
134 )"
135
136 COMMIT_V2=$($KNOWTATION_MUSE log -1 | sed -n 's/^commit \(sha256:[^ ]*\).*/\1/p')
137 log "commit v0.2.0 sha: $COMMIT_V2"
138 $KNOWTATION_MUSE log -1 | tee "$SHA_AFTER" | tee -a "$TRANSCRIPT"
139
140 log ""
141 log "### 4c. muse diff v0.1.0 commit → v0.2.0 commit (pilot workspace only)"
142 if [[ -n "$COMMIT_V1" && -n "$COMMIT_V2" ]]; then
143 $KNOWTATION_MUSE diff "$COMMIT_V1" "$COMMIT_V2" --path "$WS" 2>/dev/null | tee "$MUSE_DIFF" | tee -a "$TRANSCRIPT" || \
144 log "[muse diff unavailable — artifact diffs in $ART/ are authoritative]"
145 else
146 log "[skip muse diff — commit shas not captured]"
147 fi
148
149 # --- Stage E: anti-drift acceptance (extends 7A-12 §10) -----------------------------------
150 cp "$RUNBOOK_OUT" "$ART/.overseer.AGENTS.v0.2.0.keep"
151 rm -f "$RUNBOOK_OUT"
152 run "5a. regenerate deleted cli_runbook @ v0.2.0" \
153 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --out "$RUNBOOK_OUT"
154 log ""
155 log "### 5b. byte-identical after delete+regenerate"
156 if diff "$ART/.overseer.AGENTS.v0.2.0.keep" "$RUNBOOK_OUT" >>"$TRANSCRIPT" 2>&1; then
157 log "IDENTICAL: regenerated artifact == pre-delete artifact (lossless)"
158 else
159 log "MISMATCH: regeneration was not byte-identical"
160 fi
161 rm -f "$ART/.overseer.AGENTS.v0.2.0.keep"
162
163 cp "$RUNBOOK_OUT" "$ART/overseer.AGENTS.handedited.md"
164 printf '\n<!-- hand-scribbled note that is NOT in canonical -->\n' >> "$ART/overseer.AGENTS.handedited.md"
165 run "5c. --check hand-edited cli_runbook (expect drift=true, exit 1)" \
166 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --out "$ART/overseer.AGENTS.handedited.md" --check
167
168 run "5d. --check pinned v0.1.0 vs latest v0.2.0 (expect stale=true, exit 1)" \
169 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --version 0.1.0 --out "$ART/overseer.AGENTS.v0.1.0.md" --check
170
171 run "5e. cursor_rule fidelity (--json)" \
172 node cli/index.mjs flow project "$FLOW" --harness cursor_rule --json
173 run "5f. cli_runbook fidelity (--json)" \
174 node cli/index.mjs flow project "$FLOW" --harness cli_runbook --json
175
176 log ""
177 log "=== pilot complete — workspace + artifacts + muse SHAs under $EV ==="
178 rm -rf "$STORE_ROOT"
File History 1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 10 hours ago