teamsmith 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +39 -0
  4. package/skills/teamsmith/SKILL.md +18 -7
  5. package/skills/teamsmith/references/agent-adapters.md +7 -7
  6. package/skills/teamsmith/references/config.md +29 -15
  7. package/skills/teamsmith/references/migration.md +38 -2
  8. package/skills/teamsmith/references/protocol.md +81 -13
  9. package/skills/teamsmith/references/workflows.md +31 -19
  10. package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
  11. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
  12. package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
  13. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  14. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  15. package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
  16. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  17. package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
  18. package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
  19. package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
  20. package/skills/teamsmith/scripts/lib/common.sh +797 -71
  21. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  22. package/skills/teamsmith/scripts/panel/README.md +22 -11
  23. package/skills/teamsmith/scripts/panel/panel.js +217 -215
  24. package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
  25. package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
  26. package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
  27. package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
  28. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  29. package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
  30. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
  31. package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
  32. package/skills/teamsmith/scripts/replies.mjs +893 -0
  33. package/skills/teamsmith/scripts/team +1 -0
  34. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
  35. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  36. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  37. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  38. package/skills/teamsmith/templates/config.sh.tmpl +10 -5
  39. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  40. package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
  41. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  42. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  43. package/skills/teamsmith/tests/config-cli.sh +162 -288
  44. package/skills/teamsmith/tests/death-cause.sh +5 -2
  45. package/skills/teamsmith/tests/install-shape.sh +4 -2
  46. package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
  47. package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
  48. package/skills/teamsmith/tests/key-replies.sh +1075 -0
  49. package/skills/teamsmith/tests/ledger-ban.sh +4 -4
  50. package/skills/teamsmith/tests/ledger-claim.sh +247 -0
  51. package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
  52. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  53. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  54. package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
  55. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  56. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  57. package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
  58. package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
  59. package/skills/teamsmith/tests/panel-b2.sh +1 -1
  60. package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
  61. package/skills/teamsmith/tests/panel-b3.sh +14 -10
  62. package/skills/teamsmith/tests/panel-choices.sh +74 -61
  63. package/skills/teamsmith/tests/panel-cpu.sh +1 -1
  64. package/skills/teamsmith/tests/panel-p21.sh +311 -190
  65. package/skills/teamsmith/tests/perf.sh +1 -1
  66. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  67. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  68. package/skills/teamsmith/tests/routes.sh +43 -22
  69. package/skills/teamsmith/tests/section-budgets.tsv +8 -4
  70. package/skills/teamsmith/tests/section-paths.tsv +26 -16
  71. package/skills/teamsmith/tests/section-select.sh +82 -6
  72. package/skills/teamsmith/tests/smoke.sh +782 -180
  73. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  74. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  75. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  76. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  77. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  78. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  79. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  80. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  81. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  82. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  83. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  84. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  85. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  86. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  87. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  88. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  89. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  90. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  91. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  92. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  93. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  94. package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
  95. package/skills/teamsmith-init/SKILL.md +38 -38
  96. package/skills/teamsmith-init/references/bootstrap.md +6 -4
  97. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -0,0 +1,420 @@
1
+ #!/usr/bin/env bash
2
+ # P228 repair probes. Sourced only by the isolated routing front door.
3
+ routing_observable_snapshot() {
4
+ { find "$STATE" -type f -printf '%p %T@ %s\n' 2>/dev/null | sort
5
+ find "$STATE" -type f -print0 2>/dev/null | sort -z | xargs -0 -r sha256sum
6
+ sha256sum "$CONFIG" "$REPO/docs/team/BOARD.md" "$TMP/argv-jsonl" 2>/dev/null || true
7
+ tmux list-windows -t routing-fixture -F '#{window_id} #{pane_id} #{pane_pid}' 2>/dev/null || true
8
+ git -C "$REPO/.worktrees/dev" status --porcelain
9
+ } | sha256sum | cut -d' ' -f1
10
+ }
11
+ # Preserve each negative template arm, not only the final restored record. All files
12
+ # are synthetic fixture data; capture lives outside observable project state.
13
+ routing_binding_capture() { # entry tag mode before|after
14
+ local entry="$1" tag="$2" mode="$3" phase="$4" f dest
15
+ dest="$TMP/binding-cases/$entry-$tag-$mode/$phase"
16
+ mkdir -p "$dest" || return 1
17
+ for f in "$CONFIG" "$REPO/docs/team/BOARD.md" "$TMP/argv-jsonl" \
18
+ "$STATE/dev.env" "$STATE/pm-launch.env" "$STATE/prompt-dev-T1.md" "$STATE/pm-prompt.md"; do
19
+ if [ -f "$f" ]; then cp -p "$f" "$dest/" || return 1; else printf '%s\n' "$f" >> "$dest/absent.txt" || return 1; fi
20
+ done
21
+ routing_observable_snapshot > "$dest/effect.hash"
22
+ }
23
+ # Option-aware record-only oracle, not a Pi/provider compatibility parser. The
24
+ # probe's supported selectors must each occur once; unrelated data flags consume
25
+ # their literal value, and do not count as identity merely by containing it.
26
+ routing_identity_argv_check() { # jsonl provider model sid|- continuity|-
27
+ python3 - "$@" <<'PY'
28
+ import json,sys
29
+ path,provider,model,sid,continuity=sys.argv[1:]
30
+ args=json.loads(open(path).readlines()[-1]); found={k:[] for k in ('provider','model','sid','continuity')}
31
+ i=0
32
+ while i<len(args):
33
+ a=args[i]; i+=1
34
+ if a in ('--label','-e','--skill'):
35
+ assert i<len(args),args
36
+ i+=1; continue
37
+ if a in ('-c','--continue'):
38
+ found['continuity'].append(a); continue
39
+ for key,opts in {'provider':('--provider',),'model':('--model','-m'),'sid':('--session-id','-s')}.items():
40
+ if a in opts:
41
+ assert i<len(args),args
42
+ found[key].append(args[i]); i+=1; break
43
+ if any(a.startswith(o+'=') for o in opts):
44
+ found[key].append(a.split('=',1)[1]); break
45
+ if any(len(o)==2 and a.startswith(o) for o in opts):
46
+ found[key].append(a[2:]); break
47
+ expected={'provider':[provider],'model':[model],'sid':[] if sid=='-' else [sid],
48
+ 'continuity':[] if continuity=='-' else [continuity]}
49
+ assert found==expected,(found,expected,args)
50
+ PY
51
+ }
52
+ routing_template_probes() {
53
+ # A preceding resume group deliberately removes routine from future policy.
54
+ # This probe makes a new explicit choice: establish its own mapped premise,
55
+ # then restore the prior policy. Never weaken the unmapped-override guard.
56
+ local before_map; before_map="$(team_config_file_value "$CONFIG" TEAM_TASK_MODELS)"
57
+ run config set-task-model routine vendor/routine
58
+ check template-probe-category-ready eq "$RC" 0
59
+ stop_fixture_seat dev
60
+ # Begin with an actual complete assignment and a stopped recording CLI.
61
+ run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/deep/model:high --fresh
62
+ check template-probe-trusted-setup eq "$RC" 0
63
+ team_assignment_load dev; local sid="${TEAM_ASSIGN[sid]:-missing}" bad tag mode snapshot
64
+ stop_fixture_seat dev
65
+ local good="$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id}"
66
+ local -a faults=(
67
+ 'all-hardcoded|--provider other --model wrong:low --session-id other-history'
68
+ 'provider-hardcoded|--provider other --model {model} --session-id {session_id}'
69
+ 'model-hardcoded|--provider {provider} --model wrong:low --session-id {session_id}'
70
+ 'sid-hardcoded|--provider {provider} --model {model} --session-id other-history'
71
+ 'equals-hardcoded|--provider=other --model=wrong --session-id=other-history'
72
+ 'short-hardcoded|-mwrong -sother-history'
73
+ 'quoted-identity|"--model=wrong" --session-id {session_id}'
74
+ 'duplicate-model|--provider {provider} --model {model} --model wrong --session-id {session_id}'
75
+ 'duplicate-provider|--provider {provider} --provider {provider} --model {model} --session-id {session_id}'
76
+ 'script-placeholder|"--provider {provider} --model {model} --session-id {session_id}"'
77
+ 'hidden-script-option|--provider {provider} --model {model} --session-id {session_id} "exec pi --model wrong"'
78
+ 'joined-placeholders|{provider}{model}{session_id}'
79
+ 'positional-all|{provider} {model} {session_id}'
80
+ 'positional-provider|{provider} --model {model} --session-id {session_id}'
81
+ 'positional-model|--provider {provider} {model} --session-id {session_id}'
82
+ 'positional-sid|--provider {provider} --model {model} {session_id}'
83
+ 'data-provider|--label {provider} --model {model} --session-id {session_id}'
84
+ 'data-model|--provider {provider} -e {model} --session-id {session_id}'
85
+ 'data-sid|--provider {provider} --model {model} --skill {session_id}'
86
+ 'list-as-model|--provider {provider} --model {extra_args} {model} --session-id {session_id}'
87
+ 'duplicate-sid|--provider {provider} --model {model} --session-id {session_id} --session-id {session_id}'
88
+ 'continue|--provider {provider} --model {model} --session-id {session_id} --continue'
89
+ 'resume|--provider {provider} --model {model} --session-id {session_id} -r other-history'
90
+ 'bare-session|--provider {provider} --model {model} other-history.jsonl'
91
+ 'missing-model-value|--provider {provider} --model --session-id {session_id}'
92
+ 'missing-sid-selector|--provider {provider} --model {model}'
93
+ 'misbound-placeholder|--provider {model} --model {provider} --session-id {session_id}'
94
+ 'quoted-placeholder|--provider {provider} --model "{model}" --session-id {session_id}'
95
+ 'hidden-shell|--provider {provider} --model {model} --session-id {session_id}; touch TEMPLATE_PWNED'
96
+ )
97
+ for bad in "${faults[@]}"; do
98
+ tag="${bad%%|*}"; run config set TEAM_AGENT_CMD "$TMP/recording-pi ${bad#*|}" --yes
99
+ # The writer may reject the template, which itself is a safe no-launch result.
100
+ if [ "$RC" != 0 ]; then check "template-writer-refusal:$tag" eq "$RC" 4; continue; fi
101
+ for mode in preview launch fresh-preview fresh-launch; do
102
+ # Only continuation requires the opaque template to expose full identity;
103
+ # fresh does not upgrade the frozen seam into a non-Pi compatibility promise.
104
+ case "$tag:$mode" in missing-sid-selector:fresh-*) continue ;; esac
105
+ snapshot="$(routing_observable_snapshot)"
106
+ check "binding-capture:worker:$tag:$mode:before" routing_binding_capture worker "$tag" "$mode" before
107
+ case "$mode" in
108
+ preview) run dispatch dev T1 docs/team/tasks/T1-fixture.md --force --print ;;
109
+ launch) run dispatch dev T1 docs/team/tasks/T1-fixture.md --force ;;
110
+ fresh-preview) run dispatch dev T1 docs/team/tasks/T1-fixture.md --force --fresh --print ;;
111
+ fresh-launch) run dispatch dev T1 docs/team/tasks/T1-fixture.md --force --fresh ;;
112
+ esac
113
+ check "template-refused:$tag:$mode" eq "$RC" 1
114
+ check "template-pure:$tag:$mode" eq "$(routing_observable_snapshot)" "$snapshot"
115
+ check "binding-capture:worker:$tag:$mode:after" routing_binding_capture worker "$tag" "$mode" after
116
+ # Do not let a red old implementation leave an uncommitted worker running.
117
+ stop_fixture_seat dev
118
+ done
119
+ done
120
+ for mode in separate equals short attached extras literal-data; do
121
+ case "$mode" in
122
+ separate) good="$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id}" ;;
123
+ equals) good="$TMP/recording-pi --provider={provider} --model={model} --session-id={session_id}" ;;
124
+ short) good="$TMP/recording-pi --provider {provider} -m {model} -s {session_id}" ;;
125
+ attached) good="$TMP/recording-pi --provider={provider} -m{model} -s{session_id}" ;;
126
+ extras) good="$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id} {extra_args}"
127
+ run config set TEAM_EXTRA_PI_ARGS ' --no-tools --label "two words"' --yes
128
+ check template-harmless-extra-config eq "$RC" 0 ;;
129
+ literal-data) good="$TMP/recording-pi -e 'deep/model:high' --skill literal --provider {provider} --model {model} --session-id {session_id} {extra_args} --label vendor" ;;
130
+ esac
131
+ run config set TEAM_AGENT_CMD "$good" --yes
132
+ check "template-legal-config:$mode" eq "$RC" 0
133
+ snapshot="$(routing_observable_snapshot)"
134
+ run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
135
+ check "template-legal-preview:$mode" eq "$RC" 0
136
+ check "template-legal-preview-pure:$mode" eq "$(routing_observable_snapshot)" "$snapshot"
137
+ check "template-legal-preview-sid:$mode" contains "$OUT" "$sid"
138
+ run dispatch dev T1 docs/team/tasks/T1-fixture.md
139
+ check "template-legal-launch:$mode" eq "$RC" 0
140
+ check "template-legal-argv:$mode" routing_identity_argv_check "$TMP/argv-jsonl" vendor deep/model:high "$sid" -
141
+ if [ "$mode" = extras ]; then
142
+ check template-legal-extra-data python3 -c 'import json,sys; a=json.loads(open(sys.argv[1]).readlines()[-1]); assert "--no-tools" in a and a[a.index("--label")+1]=="two words"' "$TMP/argv-jsonl"
143
+ fi
144
+ stop_fixture_seat dev
145
+ snapshot="$(routing_observable_snapshot)"
146
+ run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh --print
147
+ check "template-bound-fresh-preview:$mode" eq "$RC" 0
148
+ check "template-bound-fresh-preview-pure:$mode" eq "$(routing_observable_snapshot)" "$snapshot"
149
+ run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
150
+ check "template-bound-fresh-launch:$mode" eq "$RC" 0
151
+ local old_sid="$sid"; team_assignment_load dev; sid="${TEAM_ASSIGN[sid]:-missing}"
152
+ check "template-bound-fresh-new-sid:$mode" test "$sid" != "$old_sid"
153
+ check "template-bound-fresh-record-model:$mode" eq "${TEAM_ASSIGN[model]:-missing}" vendor/deep/model:high
154
+ check "template-bound-fresh-record-mode:$mode" eq "${TEAM_ASSIGN[mode]:-missing}" fresh
155
+ check "template-bound-fresh-exact-argv:$mode" routing_identity_argv_check "$TMP/argv-jsonl" vendor deep/model:high "$sid" -
156
+ stop_fixture_seat dev
157
+ done
158
+ run config set TEAM_EXTRA_PI_ARGS '' --yes
159
+ run config set TEAM_AGENT_CMD '' --yes
160
+ run config set TEAM_TASK_MODELS "$before_map" --yes
161
+ check template-probe-policy-restored eq "$RC" 0
162
+ }
163
+ routing_pm_template_probes() {
164
+ local tag bad mode snapshot good
165
+ local -a faults=(
166
+ 'provider|--provider other --model {model}'
167
+ 'model|--provider {provider} --model wrong'
168
+ 'equals|--provider=other --model=wrong'
169
+ 'short|-mwrong'
170
+ 'duplicate|--provider {provider} --model {model} --model {model}'
171
+ 'missing|--provider {provider} --model'
172
+ 'session|--provider {provider} --model {model} --session-id wrong'
173
+ 'session-placeholder|--provider {provider} --model {model} --session-id {session_id}'
174
+ 'continue|--provider {provider} --model {model} -c'
175
+ 'resume-equals|--provider {provider} --model {model} --resume=wrong'
176
+ 'quoted|--provider {provider} "--model=wrong"'
177
+ 'bare-session|--provider {provider} --model {model} history.jsonl'
178
+ 'misbound|--provider {model} --model {provider}'
179
+ 'positional-all|{provider} {model}'
180
+ 'positional-provider|{provider} --model {model}'
181
+ 'positional-model|--provider {provider} {model}'
182
+ 'data-provider|--label {provider} --model {model}'
183
+ 'data-model|--provider {provider} -e {model}'
184
+ 'list-as-model|--provider {provider} --model {extra_args} {model}'
185
+ 'script-placeholder|"--provider {provider} --model {model}"'
186
+ 'hidden-script-option|--provider {provider} --model {model} "exec pi --model wrong"'
187
+ )
188
+ # Keep the private server/session alive while each arm deliberately stops PM.
189
+ # Otherwise stopping its last window destroys the premise of the older rollback
190
+ # control later in this same fixture (not a product publication failure).
191
+ routing_fixture_tmux new-window -d -t routing-fixture -n boundary-anchor 'sleep 600'
192
+ check pm-template-private-anchor eq "$?" 0
193
+ stop_fixture_seat pm
194
+ for bad in "${faults[@]}"; do
195
+ tag="${bad%%|*}"; run config set TEAM_PM_CMD "$TMP/recording-pi ${bad#*|} {resume_args} {prompt}" --yes
196
+ check "pm-template-config:$tag" eq "$RC" 0
197
+ for mode in preview launch; do
198
+ snapshot="$(routing_observable_snapshot)"
199
+ check "binding-capture:pm-fresh:$tag:$mode:before" routing_binding_capture pm-fresh "$tag" "$mode" before
200
+ if [ "$mode" = preview ]; then run up --fresh-pm --print; else run up --fresh-pm; fi
201
+ check "pm-template-refused:$tag:$mode" eq "$RC" 1
202
+ check "pm-template-pure:$tag:$mode" eq "$(routing_observable_snapshot)" "$snapshot"
203
+ check "binding-capture:pm-fresh:$tag:$mode:after" routing_binding_capture pm-fresh "$tag" "$mode" after
204
+ stop_fixture_seat pm
205
+ done
206
+ done
207
+ good="$TMP/recording-pi --provider {provider} --model {model} {resume_args} {prompt}"
208
+ run config set TEAM_PM_CMD "$good" --yes
209
+ run up --fresh-pm --print
210
+ check pm-template-legal-preview eq "$RC" 0
211
+ run up --fresh-pm
212
+ check pm-template-legal-launch eq "$RC" 0
213
+ check pm-template-legal-argv routing_identity_argv_check "$TMP/argv-jsonl" vendor pm:high - -
214
+ stop_fixture_seat pm
215
+ cp -p "$STATE/pm-launch.env" "$TMP/pm-fresh-control-record"
216
+ run config set TEAM_PM_RESUME_ARGS ' --continue' --yes
217
+ check pm-custom-resume-selector-config eq "$RC" 0
218
+ # Explicitly prepared trusted fixture metadata; this is not a claim about Pi
219
+ # history quality. The real launcher must still deliver the selected argv.
220
+ (TEAM_PM_MODEL=vendor/pm:high; TEAM_PM_RESUME_ARGS=--continue; TEAM_PM_FRESH_LAUNCH=0; team_pm_metadata_publish fixture-custom-continuation)
221
+ check pm-custom-known-record-prepared eq "$?" 0
222
+ cp -p "$STATE/pm-launch.env" "$TMP/pm-custom-control-record"
223
+ for tag in provider model positional-all positional-provider positional-model data-provider data-model; do
224
+ case "$tag" in
225
+ provider) bad='--model {model} {resume_args} {prompt}' ;;
226
+ model) bad='--provider {provider} {resume_args} {prompt}' ;;
227
+ positional-all) bad='{provider} {model} {resume_args} {prompt}' ;;
228
+ positional-provider) bad='{provider} --model {model} {resume_args} {prompt}' ;;
229
+ positional-model) bad='--provider {provider} {model} {resume_args} {prompt}' ;;
230
+ data-provider) bad='--label {provider} --model {model} {resume_args} {prompt}' ;;
231
+ data-model) bad='--provider {provider} -e {model} {resume_args} {prompt}' ;;
232
+ esac
233
+ run config set TEAM_PM_CMD "$TMP/recording-pi $bad" --yes
234
+ for mode in preview launch; do
235
+ snapshot="$(routing_observable_snapshot)"
236
+ check "binding-capture:pm-continued:$tag:$mode:before" routing_binding_capture pm-continued "$tag" "$mode" before
237
+ if [ "$mode" = preview ]; then run up --print; else run up; fi
238
+ check "pm-custom-missing-refused:$tag:$mode" eq "$RC" 1
239
+ check "pm-custom-missing-pure:$tag:$mode" eq "$(routing_observable_snapshot)" "$snapshot"
240
+ check "binding-capture:pm-continued:$tag:$mode:after" routing_binding_capture pm-continued "$tag" "$mode" after
241
+ stop_fixture_seat pm
242
+ done
243
+ done
244
+ # Frozen seam explicitly keeps the lost-history branch: if {resume_args} is
245
+ # absent, report that it is not used, rather than pretending to continue.
246
+ run config set TEAM_PM_CMD "$TMP/recording-pi --provider {provider} --model {model} {prompt}" --yes
247
+ run up --print
248
+ check pm-custom-missing-resume-lost-preview eq "$RC" 0
249
+ run up
250
+ check pm-custom-missing-resume-lost-launch eq "$RC" 0
251
+ check pm-custom-missing-resume-honest contains "$OUT" '参数不会带上'
252
+ check pm-custom-missing-resume-no-continue-argv python3 -c 'import json,sys; a=json.loads(open(sys.argv[1]).readlines()[-1]); assert "--continue" not in a and "-c" not in a' "$TMP/argv-jsonl"
253
+ stop_fixture_seat pm
254
+ cp -p "$TMP/pm-custom-control-record" "$STATE/pm-launch.env"
255
+ run config set TEAM_PM_CMD "$good" --yes
256
+ run up --print
257
+ check pm-custom-known-continue-preview eq "$RC" 0
258
+ run up
259
+ check pm-custom-known-continue-launch eq "$RC" 0
260
+ check pm-custom-continue-argv routing_identity_argv_check "$TMP/argv-jsonl" vendor pm:high - --continue
261
+ stop_fixture_seat pm
262
+ # Same continuation with literal data and alternate supported selector forms.
263
+ for tag in separate equals short attached; do
264
+ cp -p "$TMP/pm-custom-control-record" "$STATE/pm-launch.env"
265
+ case "$tag" in
266
+ separate) good='--provider {provider} --model {model}' ;;
267
+ equals) good='--provider={provider} --model={model}' ;;
268
+ short) good='--provider {provider} -m {model}' ;;
269
+ attached) good='--provider={provider} -m{model}' ;;
270
+ esac
271
+ # --label is recording-CLI data with unknown production arity: keep it
272
+ # after every owned group instead of assuming a Pi-wide option table.
273
+ run config set TEAM_PM_CMD "$TMP/recording-pi -e 'pm:high' --skill literal $good {extra_args} {resume_args} {prompt} --label vendor" --yes
274
+ check "pm-bound-config:$tag" eq "$RC" 0
275
+ for mode in preview launch; do
276
+ snapshot="$(routing_observable_snapshot)"
277
+ if [ "$mode" = preview ]; then run up --print; else run up; fi
278
+ check "pm-bound-valid:$tag:$mode" eq "$RC" 0
279
+ if [ "$mode" = preview ]; then
280
+ check "pm-bound-preview-pure:$tag" eq "$(routing_observable_snapshot)" "$snapshot"
281
+ else
282
+ check "pm-bound-exact-argv:$tag" routing_identity_argv_check "$TMP/argv-jsonl" vendor pm:high - --continue
283
+ check "pm-bound-continued-record:$tag" contains "$(team_pm_metadata_load && printf '%s' "$TEAM_PM_METADATA_JSON")" '"mode":"continued"'
284
+ stop_fixture_seat pm
285
+ fi
286
+ done
287
+ snapshot="$(routing_observable_snapshot)"
288
+ run up --fresh-pm --print
289
+ check "pm-bound-fresh-preview:$tag" eq "$RC" 0
290
+ check "pm-bound-fresh-preview-pure:$tag" eq "$(routing_observable_snapshot)" "$snapshot"
291
+ run up --fresh-pm
292
+ check "pm-bound-fresh-launch:$tag" eq "$RC" 0
293
+ check "pm-bound-fresh-exact-argv:$tag" routing_identity_argv_check "$TMP/argv-jsonl" vendor pm:high - -
294
+ check "pm-bound-fresh-record:$tag" contains "$(team_pm_metadata_load && printf '%s' "$TEAM_PM_METADATA_JSON")" '"mode":"fresh"'
295
+ stop_fixture_seat pm
296
+ done
297
+ run config set TEAM_PM_RESUME_ARGS '' --yes
298
+ cp -p "$TMP/pm-fresh-control-record" "$STATE/pm-launch.env"
299
+ run config set TEAM_PM_CMD '' --yes
300
+ run up --print
301
+ check pm-builtin-known-continue-preview eq "$RC" 0
302
+ run up
303
+ check pm-builtin-known-continue-launch eq "$RC" 0
304
+ check pm-builtin-continue-argv python3 -c 'import json,sys; a=json.loads(open(sys.argv[1]).readlines()[-1]); assert a[a.index("--model")+1]=="pm:high" and "-c" in a and any(x.startswith("@") for x in a)' "$TMP/argv-jsonl"
305
+ stop_fixture_seat pm
306
+ for bad in '--continue --session-id other' '--session-id' '--session-id=' '-s' '--resume history.jsonl --continue' '"--model=wrong"' '--provider=wrong' '-mwrong'; do
307
+ (TEAM_PM_FRESH_LAUNCH=1; TEAM_PM_RESUME_ARGS="$bad"; team_pm_identity_guard) > "$TMP/pm-resume-guard-${RANDOM}.log" 2>&1
308
+ check "pm-resume-ownership:$bad" eq "$?" 1
309
+ done
310
+ }
311
+ routing_pm_metadata_matrix() {
312
+ check pm-record-calendar-without-date bash --noprofile --norc -c '
313
+ source "$1"
314
+ date(){ return 91; }
315
+ for t in 2026-10-09T00:00:00Z 2024-02-29T23:59:59Z 2000-02-29T00:00:00Z; do team_launch_time_valid "$t" || exit 1; done
316
+ for t in 2026-02-30T00:00:00Z 1900-02-29T00:00:00Z 2026-13-01T00:00:00Z 2026-01-01T24:00:00Z 0000-01-01T00:00:00Z 2026-10-09Tgarbage; do
317
+ if team_launch_time_valid "$t"; then exit 1; fi
318
+ done
319
+ ' _ "$SKILL/scripts/lib/common.sh"
320
+ local saved="$TMP/pm-metadata-original" tag before rc
321
+ cp "$STATE/pm-launch.env" "$saved"
322
+ for tag in nonce nul time invalid-date model project window version mode missing duplicate blank oversized; do
323
+ python3 - "$saved" "$STATE/pm-launch.env" "$tag" <<'PY'
324
+ import pathlib,sys
325
+ src,dest,tag=sys.argv[1:]; text=pathlib.Path(src).read_text()
326
+ r=dict(line.split('=',1) for line in text.splitlines())
327
+ faults={'nonce':('nonce','bad nonce'),'time':('time','2026-10-09Tgarbage'),
328
+ 'invalid-date':('time','2026-02-30T00:00:00Z'),'model':('model','vendor//bad'),
329
+ 'project':('project',r['project']+'/../repo'),'window':('window','wrong'),
330
+ 'version':('metadata_version','2'),'mode':('mode','guess')}
331
+ if tag in faults: r[faults[tag][0]]=faults[tag][1]
332
+ if tag=='missing': del r['nonce']
333
+ text=''.join(k+'='+v+'\n' for k,v in r.items())
334
+ if tag=='nul': text=text.replace('nonce=', 'nonce=\0',1)
335
+ if tag=='duplicate': text+='nonce=other\n'
336
+ if tag=='blank': text+='\n'
337
+ if tag=='oversized': text+='padding='+'a'*65536+'\n'
338
+ pathlib.Path(dest).write_text(text)
339
+ PY
340
+ before="$(sha "$STATE/pm-launch.env")"; rc=0; team_pm_metadata_load || rc=$?
341
+ check "pm-metadata-rejected:$tag" eq "$rc" 1
342
+ rc=0; team_pm_identity_guard > "$TMP/pm-metadata-$tag.log" 2>&1 || rc=$?
343
+ check "pm-metadata-continue-refused:$tag" eq "$rc" 1
344
+ run config list --json
345
+ check "pm-metadata-machine-unavailable:$tag" python3 -c 'import json,sys; assert json.loads(sys.argv[1])["models"]["pm_launch"]=={}' "$OUT"
346
+ check "pm-metadata-read-only:$tag" eq "$(sha "$STATE/pm-launch.env")" "$before"
347
+ cp "$saved" "$STATE/pm-launch.env"
348
+ check "pm-metadata-restored:$tag" team_pm_metadata_load
349
+ check "pm-metadata-restored-continuation:$tag" team_pm_identity_guard
350
+ done
351
+ }
352
+ routing_reader_matrix() {
353
+ local saved="$TMP/reader-matrix-original" tag rc cols latest output before
354
+ cp "$STATE/dev.env" "$saved"
355
+ # A launch-size snapshot may be unknown or zero-padded; neither invalidates
356
+ # complete identity or changes which committed session the readers select.
357
+ for tag in '' 0005; do
358
+ python3 - "$saved" "$STATE/dev.env" "$tag" <<'PY'
359
+ import pathlib,sys
360
+ text=pathlib.Path(sys.argv[1]).read_text()
361
+ lines=[('sid_bytes='+sys.argv[3]) if x.startswith('sid_bytes=') else x for x in text.splitlines()]
362
+ pathlib.Path(sys.argv[2]).write_text('\n'.join(lines)+'\n')
363
+ PY
364
+ before="$(sha "$STATE/dev.env")"
365
+ check "reader-snapshot-valid:$tag" team_assignment_load dev
366
+ check "reader-snapshot-monitor:$tag" contains "$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)" recorded-A.jsonl
367
+ check "reader-snapshot-pure:$tag" eq "$(sha "$STATE/dev.env")" "$before"
368
+ cp "$saved" "$STATE/dev.env"
369
+ done
370
+ check reader-record-without-GNU-normalizers bash --noprofile --norc -c '
371
+ source "$1"; source "${1%/*}/cmd-config.sh"; TEAM_STATE_DIR="$2"
372
+ date(){ return 91; }; readlink(){ return 91; }
373
+ team_assignment_load dev && team_launch_path_valid / && team_launch_path_valid "$3/missing/leaf"
374
+ ' _ "$SKILL/scripts/lib/common.sh" "$STATE" "$TMP"
375
+ local -a faults=(nonce sid seat window category empty-branch empty-task taskfile-relative worktree-relative taskfile-dot worktree-dot taskfile-link worktree-link started started-date model-colon model-empty model-segment model-space key duplicate blank version bytes origin via mode missing nul)
376
+ ln -s "$REPO/.worktrees/dev" "$TMP/reader-link-wt"
377
+ ln -s "$REPO/docs/team/tasks/T1-fixture.md" "$TMP/reader-link-brief"
378
+ for tag in "${faults[@]}"; do
379
+ python3 - "$saved" "$STATE/dev.env" "$tag" "$TMP" <<'PY'
380
+ import pathlib,sys
381
+ source,dest,tag,tmp=sys.argv[1:]; text=pathlib.Path(source).read_text()
382
+ r=dict(line.split('=',1) for line in text.splitlines()); bad={
383
+ 'nonce':('launch_nonce','malformed nonce'), 'sid':('sid','bad sid'),
384
+ 'seat':('seat','verify'), 'window':('window','verify'), 'category':('category','Bad/category'),
385
+ 'empty-branch':('branch',''), 'empty-task':('task',''),
386
+ 'taskfile-relative':('taskfile','relative.md'), 'worktree-relative':('worktree','relative'),
387
+ 'taskfile-dot':('taskfile',r['taskfile'].replace('/tasks/','/tasks/../tasks/')),
388
+ 'worktree-dot':('worktree',r['worktree']+'/../dev'),
389
+ 'taskfile-link':('taskfile',tmp+'/reader-link-brief'), 'worktree-link':('worktree',tmp+'/reader-link-wt'),
390
+ 'started':('started','2026-10-09Tgarbage'), 'started-date':('started','2026-02-30T00:00:00Z'),
391
+ 'model-colon':('model','bad:provider/model'), 'model-empty':('model','vendor/:high'),
392
+ 'model-segment':('model','vendor/deep//model'), 'model-space':('model','vendor/model bad'),
393
+ 'bytes':('sid_bytes','NaN'), 'origin':('selected_via','guess'), 'via':('launch_via','guess'),
394
+ 'mode':('mode','guess'), 'version':('assignment_version','2')}
395
+ if tag in bad: r[bad[tag][0]]=bad[tag][1]
396
+ if tag=='missing': del r['launch_nonce']
397
+ text=''.join(k+'='+v+'\n' for k,v in r.items())
398
+ if tag=='key': text+='bad-key=unknown\n'
399
+ if tag=='duplicate': text+='sid='+r['sid']+'\n'
400
+ if tag=='blank': text+='\n'
401
+ if tag=='nul': text=text.replace('fixture-nonce','fixture-\0nonce')
402
+ pathlib.Path(dest).write_text(text)
403
+ PY
404
+ before="$(sha "$STATE/dev.env")"; rc=0; team_assignment_load dev || rc=$?
405
+ check "reader-record-rejected:$tag" eq "$rc" 1
406
+ printf '%s rc=%s diagnostic=%s\n' "$tag" "$rc" "$TEAM_ASSIGN_DIAGNOSTIC" >> "$TMP/reader-matrix.log"
407
+ cols="$(team_agent_session_cols dev)"; latest="$(team_agent_session_latest dev || true)"
408
+ output="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
409
+ printf '%s\n' "$output" > "$TMP/reader-monitor-$tag.json"
410
+ check "reader-size-unavailable:$tag" bash -c '! [[ "$1" == *recorded-A* || "$1" == *newer-B* ]]' _ "$cols"
411
+ check "reader-death-unavailable:$tag" eq "$latest" ''
412
+ check "reader-monitor-unavailable:$tag" contains "$output" 'committed SID unavailable'
413
+ run config list --json
414
+ check "reader-machine-unassigned:$tag" python3 -c 'import json,sys; d=json.loads(sys.argv[1]); r=next(r for r in d["models"]["assignments"] if r["agent"]=="dev"); assert not r["assigned"] and not r["sid"] and not r["model"] and r["diagnostic"]' "$OUT"
415
+ check "reader-record-unmodified:$tag" eq "$(sha "$STATE/dev.env")" "$before"
416
+ cp "$saved" "$STATE/dev.env"
417
+ check "reader-restored-record:$tag" team_assignment_load dev
418
+ check "reader-restored-monitor:$tag" contains "$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)" recorded-A.jsonl
419
+ done
420
+ }
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env bash
2
+ # F3: run real shell argv against files that turn an innocent-looking token into
3
+ # an owned selector. Only the routing front door's private repo/HOME/socket is used.
4
+ routing_expansion_probes() { # worker|pm
5
+ local seat="$1" field tag fragment mode before sid='' previous_map
6
+ previous_map="$(team_config_file_value "$CONFIG" TEAM_TASK_MODELS)"
7
+ run config set-task-model routine vendor/routine
8
+ check "$seat-expansion-category-ready" eq "$RC" 0
9
+ if [ "$seat" = worker ]; then
10
+ run config set TEAM_AGENT_CMD '' --yes
11
+ run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/deep/model:high --fresh
12
+ check expansion-assignment-ready eq "$RC" 0
13
+ team_assignment_load dev; sid="${TEAM_ASSIGN[sid]}"; stop_fixture_seat dev
14
+ else
15
+ # PM probes keep a private anchor alive; never use the shared session.
16
+ routing_fixture_tmux new-window -d -t routing-fixture -n expansion-anchor 'sleep 600'
17
+ stop_fixture_seat pm
18
+ fi
19
+ local root="$REPO" custom=""
20
+ [ "$seat" != worker ] || root="$REPO/.worktrees/dev"
21
+ local -a decoys=('--provider=other' '--model=wrong:low' '--session-id=other-history' '--continue' '--resume=other-history' '-mwrong' 'other-history.jsonl')
22
+ for fragment in "${decoys[@]}"; do printf 'identity decoy\n' > "$root/$fragment"; done
23
+ local -a faults=(
24
+ 'provider-glob|--pro*' 'model-glob|--mod*' 'sid-glob|--sess*'
25
+ 'continue-glob|--cont*' 'resume-glob|--resu*' 'short-class|-?[r]ong'
26
+ 'session-file-glob|*.jsonl' 'provider-class|--[p]rovider*'
27
+ 'mixed-quote|"--mod"*' 'brace|{--model=wrong:low,--no-tools}'
28
+ 'tilde|~/routing-note' 'doublequote-escape|"two\\\\words"'
29
+ )
30
+ # Match an actual short selector too (the first pattern deliberately matches
31
+ # nothing but still has unprovable pathname semantics).
32
+ faults+=('short-glob|-m*')
33
+ for field in template extra; do
34
+ for fragment in "${faults[@]}"; do
35
+ tag="${fragment%%|*}"; fragment="${fragment#*|}"
36
+ if [ "$seat" = worker ]; then
37
+ run config set TEAM_EXTRA_PI_ARGS '' --yes
38
+ custom="$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id}"
39
+ if [ "$field" = template ]; then
40
+ run config set TEAM_AGENT_CMD "$custom $fragment" --yes
41
+ else
42
+ run config set TEAM_AGENT_CMD '' --yes
43
+ run config set TEAM_EXTRA_PI_ARGS " $fragment" --yes
44
+ fi
45
+ else
46
+ run config set TEAM_PM_EXTRA_PI_ARGS '' --yes
47
+ custom="$TMP/recording-pi --provider {provider} --model {model} {resume_args} {prompt}"
48
+ if [ "$field" = template ]; then
49
+ run config set TEAM_PM_CMD "$custom $fragment" --yes
50
+ else
51
+ run config set TEAM_PM_CMD '' --yes
52
+ run config set TEAM_PM_EXTRA_PI_ARGS " $fragment" --yes
53
+ fi
54
+ fi
55
+ check "$seat-expansion-config:$field:$tag" eq "$RC" 0
56
+ for mode in preview launch; do
57
+ before="$(routing_observable_snapshot)"
58
+ if [ "$seat" = worker ]; then
59
+ if [ "$mode" = preview ]; then run dispatch dev T1 docs/team/tasks/T1-fixture.md --print; else run dispatch dev T1 docs/team/tasks/T1-fixture.md; fi
60
+ else
61
+ if [ "$mode" = preview ]; then run up --fresh-pm --print; else run up --fresh-pm; fi
62
+ fi
63
+ check "$seat-expansion-refused:$field:$tag:$mode" eq "$RC" 1
64
+ check "$seat-expansion-pure:$field:$tag:$mode" eq "$(routing_observable_snapshot)" "$before"
65
+ if [ "$seat" = worker ]; then stop_fixture_seat dev; else stop_fixture_seat pm; fi
66
+ done
67
+ done
68
+ done
69
+ # Quoted wildcard/brace/tilde text is literal data, not an expansion. Builtin
70
+ # PM must consume the lexer's tokens, not re-split the original quoted text.
71
+ local literal='--label "two words" "--mod*" "{safe,words}" "~/routing-note"'
72
+ literal+=" 'one\\two'"
73
+ for field in template extra; do
74
+ if [ "$seat" = worker ]; then
75
+ run config set TEAM_EXTRA_PI_ARGS '' --yes
76
+ custom="$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id}"
77
+ if [ "$field" = template ]; then run config set TEAM_AGENT_CMD "$custom $literal" --yes
78
+ else run config set TEAM_AGENT_CMD '' --yes; run config set TEAM_EXTRA_PI_ARGS " $literal" --yes; fi
79
+ else
80
+ run config set TEAM_PM_EXTRA_PI_ARGS '' --yes
81
+ custom="$TMP/recording-pi --provider {provider} --model {model} {resume_args} {prompt}"
82
+ if [ "$field" = template ]; then run config set TEAM_PM_CMD "$custom $literal" --yes
83
+ else run config set TEAM_PM_CMD '' --yes; run config set TEAM_PM_EXTRA_PI_ARGS " $literal" --yes; fi
84
+ fi
85
+ check "$seat-expansion-literal-config:$field" eq "$RC" 0
86
+ before="$(routing_observable_snapshot)"
87
+ if [ "$seat" = worker ]; then run dispatch dev T1 docs/team/tasks/T1-fixture.md --print; else run up --fresh-pm --print; fi
88
+ check "$seat-expansion-literal-preview:$field" eq "$RC" 0
89
+ check "$seat-expansion-literal-preview-pure:$field" eq "$(routing_observable_snapshot)" "$before"
90
+ if [ "$seat" = worker ]; then run dispatch dev T1 docs/team/tasks/T1-fixture.md; else run up --fresh-pm; fi
91
+ check "$seat-expansion-literal-launch:$field" eq "$RC" 0
92
+ check "$seat-expansion-literal-argv:$field" python3 - "$TMP/argv-jsonl" "$seat" "$sid" <<'PY'
93
+ import json,sys
94
+ argv=json.loads(open(sys.argv[1]).readlines()[-1])
95
+ assert argv[argv.index('--label')+1]=='two words',argv
96
+ assert all(x in argv for x in ['--mod*','{safe,words}','~/routing-note',r'one\two']),argv
97
+ assert '--model=wrong:low' not in argv and '--provider=other' not in argv,argv
98
+ assert argv.count('--model')==1 and argv.count('--provider')==1,argv
99
+ assert argv[argv.index('--provider')+1]=='vendor',argv
100
+ if sys.argv[2]=='worker':
101
+ assert argv[argv.index('--model')+1]=='deep/model:high' and argv[argv.index('--session-id')+1]==sys.argv[3],argv
102
+ else:
103
+ assert argv[argv.index('--model')+1]=='pm:high' and '-c' not in argv and '--continue' not in argv,argv
104
+ PY
105
+ if [ "$seat" = worker ]; then stop_fixture_seat dev; else stop_fixture_seat pm; fi
106
+ done
107
+ if [ "$seat" = pm ]; then routing_pm_resume_expansion_probes; fi
108
+ for fragment in "${decoys[@]}"; do rm -- "$root/$fragment"; done
109
+ if [ "$seat" = worker ]; then
110
+ run config set TEAM_AGENT_CMD '' --yes; run config set TEAM_EXTRA_PI_ARGS '' --yes
111
+ else
112
+ run config set TEAM_PM_CMD '' --yes; run config set TEAM_PM_EXTRA_PI_ARGS '' --yes
113
+ fi
114
+ run config set TEAM_TASK_MODELS "$previous_map" --yes
115
+ check "$seat-expansion-policy-restored" eq "$RC" 0
116
+ }
117
+ routing_pm_resume_expansion_probes() {
118
+ local field fragment mode before saved="$TMP/pm-expansion-saved-record"
119
+ cp -p "$STATE/pm-launch.env" "$saved"
120
+ for field in builtin custom; do
121
+ if [ "$field" = builtin ]; then run config set TEAM_PM_CMD '' --yes
122
+ else run config set TEAM_PM_CMD "$TMP/recording-pi --provider {provider} --model {model} {resume_args} {prompt}" --yes; fi
123
+ run config set TEAM_PM_EXTRA_PI_ARGS '' --yes
124
+ for fragment in '--mod*' '--pro*' '--sess*' '--cont*' '--resu*' '{--model=wrong:low,--continue}' '--session-id ~'; do
125
+ run config set TEAM_PM_RESUME_ARGS " $fragment" --yes
126
+ check "pm-resume-expansion-config:$field:$fragment" eq "$RC" 0
127
+ # Controlled same-key metadata makes this a real continuation test, not a
128
+ # fresh-pm call that discards resume_args before it can reach the shell.
129
+ (TEAM_PM_FRESH_LAUNCH=0; TEAM_PM_RESUME_ARGS=" $fragment"; team_pm_metadata_publish fixture-resume-expansion)
130
+ check "pm-resume-expansion-record:$field:$fragment" eq "$?" 0
131
+ for mode in preview launch; do
132
+ before="$(routing_observable_snapshot)"
133
+ if [ "$mode" = preview ]; then run up --print; else run up; fi
134
+ check "pm-resume-expansion-refused:$field:$fragment:$mode" eq "$RC" 1
135
+ check "pm-resume-expansion-pure:$field:$fragment:$mode" eq "$(routing_observable_snapshot)" "$before"
136
+ stop_fixture_seat pm
137
+ done
138
+ done
139
+ fragment=" --session-id 'fixture-literal-session'"
140
+ run config set TEAM_PM_RESUME_ARGS "$fragment" --yes
141
+ check "pm-resume-literal-config:$field" eq "$RC" 0
142
+ (TEAM_PM_FRESH_LAUNCH=0; TEAM_PM_RESUME_ARGS="$fragment"; team_pm_metadata_publish fixture-resume-literal)
143
+ check "pm-resume-literal-record:$field" eq "$?" 0
144
+ before="$(routing_observable_snapshot)"
145
+ run up --print
146
+ check "pm-resume-literal-preview:$field" eq "$RC" 0
147
+ check "pm-resume-literal-preview-pure:$field" eq "$(routing_observable_snapshot)" "$before"
148
+ run up
149
+ check "pm-resume-literal-launch:$field" eq "$RC" 0
150
+ check "pm-resume-literal-argv:$field" python3 -c 'import json,sys; a=json.loads(open(sys.argv[1]).readlines()[-1]); assert a.count("--session-id")==1 and a[a.index("--session-id")+1]=="fixture-literal-session",a; assert a[a.index("--model")+1]=="pm:high",a' "$TMP/argv-jsonl"
151
+ stop_fixture_seat pm
152
+ done
153
+ run config set TEAM_PM_RESUME_ARGS '' --yes
154
+ cp -p "$saved" "$STATE/pm-launch.env"
155
+ }