@memnexus-ai/mx-agent-cli 0.1.231 → 0.1.233

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 (57) hide show
  1. package/dist/__tests__/behavioral-extraction.test.js +93 -0
  2. package/dist/__tests__/behavioral-extraction.test.js.map +1 -1
  3. package/dist/__tests__/behavioral-injection.test.d.ts +13 -0
  4. package/dist/__tests__/behavioral-injection.test.d.ts.map +1 -0
  5. package/dist/__tests__/behavioral-injection.test.js +384 -0
  6. package/dist/__tests__/behavioral-injection.test.js.map +1 -0
  7. package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts +18 -0
  8. package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts.map +1 -0
  9. package/dist/__tests__/bootstrap-behavioral-contract.test.js +101 -0
  10. package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +1 -0
  11. package/dist/__tests__/provision-behavioral-contract.test.d.ts +13 -0
  12. package/dist/__tests__/provision-behavioral-contract.test.d.ts.map +1 -0
  13. package/dist/__tests__/provision-behavioral-contract.test.js +454 -0
  14. package/dist/__tests__/provision-behavioral-contract.test.js.map +1 -0
  15. package/dist/__tests__/provision-copy-containment.test.d.ts +19 -0
  16. package/dist/__tests__/provision-copy-containment.test.d.ts.map +1 -0
  17. package/dist/__tests__/provision-copy-containment.test.js +187 -0
  18. package/dist/__tests__/provision-copy-containment.test.js.map +1 -0
  19. package/dist/__tests__/provision-teambuilder-flow.test.d.ts +22 -0
  20. package/dist/__tests__/provision-teambuilder-flow.test.d.ts.map +1 -0
  21. package/dist/__tests__/provision-teambuilder-flow.test.js +165 -0
  22. package/dist/__tests__/provision-teambuilder-flow.test.js.map +1 -0
  23. package/dist/__tests__/provision-write-integrity.test.d.ts +18 -0
  24. package/dist/__tests__/provision-write-integrity.test.d.ts.map +1 -0
  25. package/dist/__tests__/provision-write-integrity.test.js +141 -0
  26. package/dist/__tests__/provision-write-integrity.test.js.map +1 -0
  27. package/dist/__tests__/startup-report.test.js +3 -3
  28. package/dist/__tests__/startup-report.test.js.map +1 -1
  29. package/dist/agent-config/shared/eval-tiered-rigor.md +4 -2
  30. package/dist/commands/bootstrap.d.ts +2 -0
  31. package/dist/commands/bootstrap.d.ts.map +1 -1
  32. package/dist/commands/bootstrap.js +15 -1
  33. package/dist/commands/bootstrap.js.map +1 -1
  34. package/dist/commands/create.d.ts +188 -0
  35. package/dist/commands/create.d.ts.map +1 -1
  36. package/dist/commands/create.js +606 -23
  37. package/dist/commands/create.js.map +1 -1
  38. package/dist/commands/new.d.ts +2 -0
  39. package/dist/commands/new.d.ts.map +1 -1
  40. package/dist/commands/new.js +6 -1
  41. package/dist/commands/new.js.map +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +13 -2
  44. package/dist/index.js.map +1 -1
  45. package/dist/lib/behavioral-injection.d.ts +144 -0
  46. package/dist/lib/behavioral-injection.d.ts.map +1 -0
  47. package/dist/lib/behavioral-injection.js +438 -0
  48. package/dist/lib/behavioral-injection.js.map +1 -0
  49. package/dist/lib/claude.d.ts +49 -7
  50. package/dist/lib/claude.d.ts.map +1 -1
  51. package/dist/lib/claude.js +62 -82
  52. package/dist/lib/claude.js.map +1 -1
  53. package/dist/lib/templates.d.ts +1 -1
  54. package/dist/lib/templates.d.ts.map +1 -1
  55. package/dist/lib/templates.js +2 -0
  56. package/dist/lib/templates.js.map +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,438 @@
1
+ /**
2
+ * behavioral-injection.ts — behavioral-block detection primitive (#4541).
3
+ *
4
+ * PROBLEM. Every team's `CLAUDE.local.md` — the file re-injected into the model
5
+ * context on EVERY conversation turn — is generated from the roleguide content
6
+ * between `<!-- behavioral-start -->` and `<!-- behavioral-end -->`. When a
7
+ * roleguide has no markers the generator wrote one stderr line and shipped an
8
+ * isolation-only file: the team ran with no every-turn behavioral reinforcement
9
+ * (no prior-art gate, no decision authority, no delegation limits). Eval ran that
10
+ * way from 2026-06-28 for four weeks before anyone noticed.
11
+ *
12
+ * Root cause was NOT a botched sweep. PR #3539 tagged every roleguide that
13
+ * existed at the time; eval's roleguide landed 12 days later. Nothing re-triggers
14
+ * marker-tagging when a team is provisioned AFTER a completion sweep, and
15
+ * provisioning had no step for it.
16
+ *
17
+ * This module is the pure, never-throwing detection primitive — the same shape as
18
+ * `hook-completeness.ts` (#4428). Two consumers sit on top of it:
19
+ * 1. `runCreate` (commands/create.ts) — the PRIMARY control. Provisioning
20
+ * REFUSES to complete when the target roleguide has no non-empty block. This
21
+ * is the moment a human is looking, and it is what prevents recurrence.
22
+ * 2. `writeClaudeLocal` (lib/claude.ts) — the LOUD, FAIL-OPEN warning. A team
23
+ * whose block went missing after provisioning still starts (availability
24
+ * beats correctness here; per #4123 the fail-CLOSED tier is reserved for
25
+ * hooks / settings.json / agent-config conflicts, and this is not that), but
26
+ * the degradation is named by team and surfaced where an operator reads it.
27
+ *
28
+ * These two are the ONLY enforcement. There is no automated repo-wide check: a
29
+ * pre-push gate wiring `dev-tools/scripts/validate-roleguide-behavioral-markers.sh`
30
+ * into ci-validate-hook.sh was DESCOPED after three security review rounds in
31
+ * which the gate's fixes kept producing new findings. That script still exists and
32
+ * duplicates the marker rules below in bash, but it must be run by hand — so a
33
+ * roleguide whose block is removed AFTER provisioning is caught only by consumer
34
+ * (2), at session start, per team. Follow-ups: a GitHub Actions job (pipeline's
35
+ * file territory) and Red Team's shared `behavioral-base.md` refactor, which would
36
+ * make coverage a build guarantee and remove the need for a presence check.
37
+ * If you change the marker rules here, change them in that script too.
38
+ */
39
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readFileSync, realpathSync, } from 'fs';
40
+ import { basename, dirname, join, sep } from 'path';
41
+ export const BEHAVIORAL_START_MARKER = '<!-- behavioral-start -->';
42
+ export const BEHAVIORAL_END_MARKER = '<!-- behavioral-end -->';
43
+ /**
44
+ * True when `candidate` is `root` itself or lies beneath it.
45
+ *
46
+ * The root is normalised before the separator is appended: for root `/` the naive
47
+ * `root + sep` builds `//`, so `isInside(anything, '/')` was ALWAYS false. That
48
+ * failed closed (a `/` root simply authorised nothing) but it is still a latent
49
+ * trap for any future caller that passes a filesystem root, and a containment
50
+ * helper that silently answers "no" to everything is exactly the kind of control
51
+ * that reports safety it does not provide.
52
+ */
53
+ function isInside(candidate, root) {
54
+ if (candidate === root)
55
+ return true;
56
+ const prefix = root.endsWith(sep) ? root : root + sep;
57
+ return candidate.startsWith(prefix);
58
+ }
59
+ /**
60
+ * Resolve `absPath` (already built from a realpath'd root) and classify it.
61
+ * Never throws.
62
+ */
63
+ function safeResolve(absPath, realRoot) {
64
+ let real;
65
+ try {
66
+ real = realpathSync(absPath);
67
+ }
68
+ catch {
69
+ // realpathSync throws for a missing file AND for a DANGLING symlink. Only
70
+ // the latter has a link to report, so check before calling it missing —
71
+ // otherwise a dangling link is diagnosed as an absent roleguide and the
72
+ // operator is sent to fix the wrong thing.
73
+ if (isSymlink(absPath))
74
+ return { kind: 'symlink', real: absPath };
75
+ return { kind: 'missing' };
76
+ }
77
+ // Symlink-ness is checked BEFORE containment so the diagnosis names the
78
+ // actionable fact. A link pointing outside the repo is both a symlink and an
79
+ // escape; "this is a symlink, replace it with a regular file" is the fix in
80
+ // either case, and an in-repo link is rejected too (PO directive 2026-07-20).
81
+ if (real !== absPath)
82
+ return { kind: 'symlink', real };
83
+ if (!isInside(real, realRoot))
84
+ return { kind: 'escapes', real };
85
+ return { kind: 'ok', real };
86
+ }
87
+ /** True when the final component of `absPath` is itself a symbolic link. */
88
+ function isSymlink(absPath) {
89
+ try {
90
+ return lstatSync(absPath).isSymbolicLink();
91
+ }
92
+ catch {
93
+ return false;
94
+ }
95
+ }
96
+ /**
97
+ * Extract the behavioral block from ALREADY-READ bytes. Pure — no filesystem
98
+ * access, so it never re-resolves a path.
99
+ *
100
+ * Split out so a caller holding the bytes that were read from a validated
101
+ * descriptor can derive the block from EXACTLY those bytes rather than reading
102
+ * the path a second time (#4541 review round 5). Two reads of the same path can
103
+ * return different content, which would let the roleguide copied into a worktree
104
+ * and the block injected into that team's per-turn context disagree.
105
+ */
106
+ export function extractMarkerBlock(text, label) {
107
+ const startIdx = text.indexOf(BEHAVIORAL_START_MARKER);
108
+ const endIdx = text.indexOf(BEHAVIORAL_END_MARKER);
109
+ if (startIdx === -1 || endIdx === -1) {
110
+ const missing = startIdx === -1 && endIdx === -1
111
+ ? `${BEHAVIORAL_START_MARKER} and ${BEHAVIORAL_END_MARKER}`
112
+ : startIdx === -1
113
+ ? BEHAVIORAL_START_MARKER
114
+ : BEHAVIORAL_END_MARKER;
115
+ return {
116
+ ok: false, content: null, raw: text, problem: 'markers-missing',
117
+ detail: `${label} is missing ${missing}`,
118
+ };
119
+ }
120
+ if (endIdx <= startIdx) {
121
+ return {
122
+ ok: false, content: null, raw: text, problem: 'markers-inverted',
123
+ detail: `${label} has ${BEHAVIORAL_END_MARKER} before ${BEHAVIORAL_START_MARKER}`,
124
+ };
125
+ }
126
+ const content = text.slice(startIdx + BEHAVIORAL_START_MARKER.length, endIdx).trim();
127
+ if (!content) {
128
+ return {
129
+ ok: false, content: null, raw: text, problem: 'content-empty',
130
+ detail: `${label} has an EMPTY behavioral block (markers present, no content between them)`,
131
+ };
132
+ }
133
+ return { ok: true, content, raw: text, problem: null, detail: null };
134
+ }
135
+ /**
136
+ * Check ONE roleguide file for a non-empty behavioral block. Never throws.
137
+ *
138
+ * CONTAINMENT. The file must resolve inside one of `allowedRoots`. Resolution is
139
+ * physical: the PARENT directory is realpath'd (which collapses every
140
+ * intermediate symlink) and the result must sit under an allowed root, so a
141
+ * symlinked directory cannot smuggle the read outside it.
142
+ *
143
+ * ATOMICITY. The open, the type check, and the read all use ONE file descriptor
144
+ * obtained with `O_NOFOLLOW`:
145
+ * * `O_NOFOLLOW` makes the kernel refuse (ELOOP) if the FINAL component is a
146
+ * symbolic link, so link-ness is decided by the same syscall that acquires
147
+ * the handle — not by an earlier `lstat` whose answer could be stale.
148
+ * * `fstat` and the read then operate on that descriptor, so the bytes checked
149
+ * are provably the bytes read.
150
+ * A `statSync`-then-`readFileSync` pair reintroduces the v2.69 TOCTOU defect:
151
+ * between the two calls the path can be replaced with a link to any file the
152
+ * process can read, and the content lands in every-turn model context.
153
+ *
154
+ * RESIDUAL, stated precisely and CONDITIONALLY: Node has no `openat`, so the
155
+ * parent directory is resolved by path rather than held as a descriptor. A parent
156
+ * component swapped between the `realpath` and the `open` is not detected, and
157
+ * that window is not closable in pure Node.
158
+ *
159
+ * Whether it matters depends entirely on the ROOT, so callers own this argument:
160
+ * * For a root only privileged writers can modify — the project root, a team's
161
+ * own git worktree — winning the race requires write access inside that root,
162
+ * which already implies the ability to edit the roleguide directly. The race
163
+ * buys the attacker nothing.
164
+ * * For a WORLD-WRITABLE root the argument collapses: anyone can create and swap
165
+ * directories in `/tmp`, so the race is winnable without any pre-existing
166
+ * privilege. An earlier revision of `create.ts` used `process.cwd()` as an
167
+ * allowed root, which made exactly this case reachable; roots are now derived
168
+ * from project configuration (project root, or a git worktree under the
169
+ * project's worktree directory) rather than chosen by the caller.
170
+ * Do not pass a world-writable directory as an allowed root.
171
+ */
172
+ export function checkRoleguideMarkers(roleguideAbsPath, opts) {
173
+ const label = opts.label ?? roleguideAbsPath;
174
+ if (!opts.allowedRoots || opts.allowedRoots.length === 0) {
175
+ // Fail CLOSED. A caller that forgot its trust boundary must not get an
176
+ // unbounded read.
177
+ return {
178
+ ok: false, content: null, raw: null, problem: 'roleguide-path-escapes-root',
179
+ detail: `refusing to read ${label}: no allowed root was supplied`,
180
+ };
181
+ }
182
+ // Resolve every allowed root physically; drop any that does not exist.
183
+ const roots = [];
184
+ for (const r of opts.allowedRoots) {
185
+ try {
186
+ roots.push(realpathSync(r));
187
+ }
188
+ catch {
189
+ // A non-existent root simply contributes no permission.
190
+ }
191
+ }
192
+ if (roots.length === 0) {
193
+ return {
194
+ ok: false, content: null, raw: null, problem: 'roleguide-path-escapes-root',
195
+ detail: `refusing to read ${label}: none of the allowed roots exist`,
196
+ };
197
+ }
198
+ // Resolve the PARENT physically — this collapses intermediate symlinks.
199
+ const parent = dirname(roleguideAbsPath);
200
+ const base = basename(roleguideAbsPath);
201
+ let realParent;
202
+ try {
203
+ realParent = realpathSync(parent);
204
+ }
205
+ catch {
206
+ return {
207
+ ok: false, content: null, raw: null, problem: 'roleguide-missing',
208
+ detail: `roleguide not found at ${label} (directory does not exist)`,
209
+ };
210
+ }
211
+ if (!roots.some((root) => isInside(realParent, root))) {
212
+ return {
213
+ ok: false, content: null, raw: null, problem: 'roleguide-path-escapes-root',
214
+ detail: `${label} resolves to ${join(realParent, base)}, outside the allowed ` +
215
+ `location(s): ${roots.join(', ')}`,
216
+ };
217
+ }
218
+ // Single descriptor: O_NOFOLLOW decides link-ness, fstat decides regular-file-ness,
219
+ // and the read comes off the same handle.
220
+ const resolvedPath = join(realParent, base);
221
+ let fd;
222
+ try {
223
+ fd = openSync(resolvedPath, constants.O_RDONLY | constants.O_NOFOLLOW);
224
+ }
225
+ catch (err) {
226
+ const code = err?.code;
227
+ if (code === 'ELOOP') {
228
+ return {
229
+ ok: false, content: null, raw: null, problem: 'roleguide-symlink',
230
+ detail: `${label} is a symbolic link — roleguides must be regular files ` +
231
+ `(symlinked content never appears in a diff and is invisible to review)`,
232
+ };
233
+ }
234
+ if (code === 'ENOENT') {
235
+ return {
236
+ ok: false, content: null, raw: null, problem: 'roleguide-missing',
237
+ detail: `roleguide not found at ${label}`,
238
+ };
239
+ }
240
+ return {
241
+ ok: false, content: null, raw: null, problem: 'roleguide-unreadable',
242
+ detail: `could not open roleguide ${label} (${code ?? 'unknown error'})`,
243
+ };
244
+ }
245
+ let text;
246
+ try {
247
+ const st = fstatSync(fd);
248
+ if (!st.isFile()) {
249
+ return {
250
+ ok: false, content: null, raw: null, problem: 'roleguide-not-regular-file',
251
+ detail: `${label} is not a regular file`,
252
+ };
253
+ }
254
+ // HARD LINKS defeat every check above. A hard link inside an allowed root to
255
+ // a file outside it passes all of them: the parent realpaths inside the root,
256
+ // O_NOFOLLOW does not fire (a hard link is not a symbolic link), and fstat
257
+ // reports a regular file. The content still comes from outside the tree and
258
+ // still reaches per-turn model context, and a write through the OTHER link
259
+ // changes it with no visible change here — which is precisely the reasoning
260
+ // this module gives for banning symlinks. nlink is read from the SAME
261
+ // descriptor the bytes come from, so it cannot be raced.
262
+ if (st.nlink > 1) {
263
+ return {
264
+ ok: false, content: null, raw: null, problem: 'roleguide-hard-link',
265
+ detail: `${label} has ${st.nlink} hard links — roleguides must be single-linked ` +
266
+ `regular files (a hard link can alias content outside the repository, and edits ` +
267
+ `through the other link never appear in a diff)`,
268
+ };
269
+ }
270
+ text = readFileSync(fd, 'utf-8');
271
+ }
272
+ catch {
273
+ return {
274
+ ok: false, content: null, raw: null, problem: 'roleguide-unreadable',
275
+ detail: `could not read roleguide ${label}`,
276
+ };
277
+ }
278
+ finally {
279
+ try {
280
+ closeSync(fd);
281
+ }
282
+ catch {
283
+ // best effort
284
+ }
285
+ }
286
+ return extractMarkerBlock(text, label);
287
+ }
288
+ /**
289
+ * Resolve a team slug to its roleguide and check the behavioral block.
290
+ * Never throws. Path-containment checks match the pre-existing extractor:
291
+ * the slug may not escape the teams directory and the roleguide path may not
292
+ * escape the project root.
293
+ */
294
+ export function checkBehavioralInjection(projectRoot, teamSlug, teamsDir = 'mx-agent-system/teams') {
295
+ const base = (extra) => ({
296
+ ok: false, content: null, raw: null, problem: null, detail: null,
297
+ teamSlug, displayName: teamSlug, roleguideRelPath: null,
298
+ ...extra,
299
+ });
300
+ // 0. Resolve the project root ONCE. Every path below is built from the
301
+ // realpath'd root so that `realpathSync(p) !== p` means "a component of p
302
+ // was a symlink" and nothing else.
303
+ let realRoot;
304
+ try {
305
+ realRoot = realpathSync(projectRoot);
306
+ }
307
+ catch {
308
+ return base({
309
+ problem: 'team-file-missing',
310
+ detail: `project root ${projectRoot} does not exist`,
311
+ });
312
+ }
313
+ // 1. Team catalog file — lexical containment, then symlink/escape resolution.
314
+ const teamsBase = join(realRoot, teamsDir);
315
+ const teamFilePath = join(teamsBase, `${teamSlug}.md`);
316
+ if (!isInside(teamFilePath, teamsBase) || teamFilePath === teamsBase) {
317
+ return base({
318
+ problem: 'invalid-team-slug',
319
+ detail: `invalid team slug "${teamSlug}" — path escapes the teams directory`,
320
+ });
321
+ }
322
+ const teamResolved = safeResolve(teamFilePath, realRoot);
323
+ if (teamResolved.kind === 'missing') {
324
+ return base({
325
+ problem: 'team-file-missing',
326
+ detail: `no team catalog file at ${teamsDir}/${teamSlug}.md`,
327
+ });
328
+ }
329
+ if (teamResolved.kind === 'symlink') {
330
+ return base({
331
+ problem: 'team-file-symlink',
332
+ detail: `${teamsDir}/${teamSlug}.md resolves through a symbolic link ` +
333
+ `(${teamResolved.real}) — team catalog files must be regular files`,
334
+ });
335
+ }
336
+ if (teamResolved.kind === 'escapes') {
337
+ return base({
338
+ problem: 'team-file-escapes-root',
339
+ detail: `${teamsDir}/${teamSlug}.md resolves outside the project root ` +
340
+ `(${teamResolved.real})`,
341
+ });
342
+ }
343
+ let teamFileContent;
344
+ try {
345
+ teamFileContent = readFileSync(teamFilePath, 'utf-8');
346
+ }
347
+ catch {
348
+ return base({
349
+ problem: 'team-file-unreadable',
350
+ detail: `could not read team catalog file ${teamsDir}/${teamSlug}.md`,
351
+ });
352
+ }
353
+ // 2. Display name
354
+ const displayNameLine = teamFileContent.split('\n').find((l) => l.startsWith('Display name:'));
355
+ const displayName = displayNameLine
356
+ ? displayNameLine.replace('Display name:', '').trim() || teamSlug
357
+ : teamSlug;
358
+ // 3. Roleguide path — FIRST backticked token on the `Roleguide:` line.
359
+ const roleguideLineRaw = teamFileContent.split('\n').find((l) => l.startsWith('Roleguide:'));
360
+ if (!roleguideLineRaw) {
361
+ return base({
362
+ displayName,
363
+ problem: 'roleguide-line-missing',
364
+ detail: `no 'Roleguide:' line in ${teamsDir}/${teamSlug}.md`,
365
+ });
366
+ }
367
+ const roleguideMatch = roleguideLineRaw.match(/`([^`]+)`/);
368
+ if (!roleguideMatch) {
369
+ return base({
370
+ displayName,
371
+ problem: 'roleguide-path-unparseable',
372
+ detail: `could not parse a backticked roleguide path from ${teamsDir}/${teamSlug}.md`,
373
+ });
374
+ }
375
+ const roleguideRelPath = roleguideMatch[1];
376
+ // 4. Roleguide — lexical containment first (rejects `../` and absolute paths
377
+ // before any filesystem call), then symlink/escape resolution.
378
+ const roleguideAbsPath = join(realRoot, roleguideRelPath);
379
+ if (!isInside(roleguideAbsPath, realRoot) || roleguideAbsPath === realRoot) {
380
+ return base({
381
+ displayName, roleguideRelPath,
382
+ problem: 'roleguide-path-escapes-root',
383
+ detail: `roleguide path "${roleguideRelPath}" escapes the project root`,
384
+ });
385
+ }
386
+ const rgResolved = safeResolve(roleguideAbsPath, realRoot);
387
+ if (rgResolved.kind === 'symlink') {
388
+ return base({
389
+ displayName, roleguideRelPath,
390
+ problem: 'roleguide-symlink',
391
+ detail: `${roleguideRelPath} resolves through a symbolic link (${rgResolved.real}) — ` +
392
+ `roleguides must be regular files (symlinked content never appears in a diff ` +
393
+ `and is invisible to review)`,
394
+ });
395
+ }
396
+ if (rgResolved.kind === 'escapes') {
397
+ return base({
398
+ displayName, roleguideRelPath,
399
+ problem: 'roleguide-path-escapes-root',
400
+ detail: `${roleguideRelPath} resolves outside the project root (${rgResolved.real})`,
401
+ });
402
+ }
403
+ const marker = checkRoleguideMarkers(roleguideAbsPath, {
404
+ allowedRoots: [realRoot],
405
+ label: roleguideRelPath,
406
+ });
407
+ return { ...marker, teamSlug, displayName, roleguideRelPath };
408
+ }
409
+ /**
410
+ * One-line, actionable remediation text for a failed check. Shape mirrors
411
+ * `describeHookProblems` in claude.ts: state what is wrong, then the exact fix.
412
+ */
413
+ export function describeBehavioralProblem(r) {
414
+ if (r.ok)
415
+ return '';
416
+ const what = r.detail ?? 'behavioral block unavailable';
417
+ switch (r.problem) {
418
+ case 'markers-missing':
419
+ case 'markers-inverted':
420
+ case 'content-empty':
421
+ return `${what}. Fix: wrap the roleguide's behavioral sections (decision authority, ` +
422
+ `prior-art gate, delegation limits, stop conditions) in ` +
423
+ `${BEHAVIORAL_START_MARKER} / ${BEHAVIORAL_END_MARKER}.`;
424
+ case 'roleguide-symlink':
425
+ case 'team-file-symlink':
426
+ case 'roleguide-not-regular-file':
427
+ case 'roleguide-hard-link':
428
+ case 'roleguide-path-escapes-root':
429
+ case 'team-file-escapes-root':
430
+ return `${what}. Fix: replace the link with a regular file committed inside the ` +
431
+ `repository. Symlinks are banned in agent config (PO directive 2026-07-20) because ` +
432
+ `their content never appears in a diff.`;
433
+ default:
434
+ return `${what}. Fix: make the roleguide reachable from the team catalog entry, ` +
435
+ `then confirm it carries a non-empty ${BEHAVIORAL_START_MARKER} block.`;
436
+ }
437
+ }
438
+ //# sourceMappingURL=behavioral-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavioral-injection.js","sourceRoot":"","sources":["../../src/lib/behavioral-injection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EACL,SAAS,EAAE,SAAS,EAAc,SAAS,EAAE,SAAS,EACtD,QAAQ,EAAE,YAAY,EAAE,YAAY,GACrC,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAoD/D;;;;;;;;;GASG;AACH,SAAS,QAAQ,CAAC,SAAiB,EAAE,IAAY;IAC/C,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;IACtD,OAAO,SA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wC,CAAC;QAC7C;YACE,OAAO,GAAG,IAAI,mEAAmE;gBAC/E,uCAAuC,uBAAuB,SAAS,CAAC;IAC9E,CAAC;AACH,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Mirrors the patterns in dev-tools/worktree-cli/src/operations.ts.
4
4
  */
5
5
  export declare function logSuccess(msg: string): void;
6
- export declare function logWarning(msg: string): void;
6
+ export declare function logWarning(msg: string, code?: string): void;
7
7
  export declare function logDim(msg: string): void;
8
8
  /**
9
9
  * Deploy the instruction files into the worktree from the templates.
@@ -29,13 +29,16 @@ export declare function deployClaudeMd(projectRoot: string, worktreePath: string
29
29
  /**
30
30
  * Extract behavioral content from a team's roleguide.
31
31
  *
32
- * Reads the team catalog entry to find the roleguide path, then reads the
33
- * roleguide and extracts content between `<!-- behavioral-start -->` and
34
- * `<!-- behavioral-end -->` markers.
32
+ * Thin back-compat wrapper over `checkBehavioralInjection` (lib/behavioral-injection.ts),
33
+ * which owns the parsing, path-containment, and marker rules. Returns null on any
34
+ * failure so a missing block can never break worktree creation.
35
35
  *
36
- * All failures are silent (logged to stderr with [mx-agent] prefix) and
37
- * return null — missing markers, missing team files, or read errors should
38
- * never break worktree creation.
36
+ * REPORTING MOVED (#4541). This function used to write the failure to stderr and
37
+ * continue. That warning WAS captured in the startup log, and eval still ran with
38
+ * no behavioral block for four weeks unnoticed. Detection is now silent here —
39
+ * the caller (`writeClaudeLocal`) emits ONE loud, team-named warning through the
40
+ * same `logWarning` channel as the #4428 hook self-heal, so the degradation lands
41
+ * in the operator's terminal and in the structured startup report with a code.
39
42
  */
40
43
  export declare function extractBehavioralContent(projectRoot: string, teamSlug: string, teamsDir?: string): {
41
44
  content: string;
@@ -61,6 +64,45 @@ export declare function writeClaudeLocal(opts: {
61
64
  slot: number;
62
65
  projectSlug?: string;
63
66
  teamSlug?: string;
67
+ /**
68
+ * Use THIS roleguide for the behavioral block instead of resolving one via the
69
+ * team catalog (#4541 security review, MUST FIX 3a / finding B).
70
+ *
71
+ * Provisioning must generate the session from the SAME file it validated. Two
72
+ * things go wrong without this:
73
+ * 1. WRONG FILE. `mx-agent provision` resolves --roleguide from the caller's
74
+ * cwd first (the team-builder's own worktree, where a new roleguide lives
75
+ * before it reaches the base branch); the catalog lookup resolves from
76
+ * projectRoot only. When those differ — the documented team-builder
77
+ * workflow, and `new project` where projectRoot is outputDir — the
78
+ * contract would validate file A while the session was generated from
79
+ * file B. A control that reports PASS while the invariant is violated is
80
+ * worse than no control.
81
+ * 2. FALSE WARNING. During provisioning the catalog entry does not exist yet
82
+ * (it is written two steps later), so a catalog lookup returns
83
+ * team-file-missing and prints "Behavioral block MISSING" on every
84
+ * successful provision — a 100% false-positive rate on the primary path,
85
+ * training operators to ignore the one string this whole change exists to
86
+ * make un-ignorable.
87
+ */
88
+ behavioralOverride?: {
89
+ roleguideAbsPath: string;
90
+ roleguideRelPath: string;
91
+ displayName: string;
92
+ /** Directories the roleguide must resolve inside — see checkRoleguideMarkers. */
93
+ allowedRoots: string[];
94
+ /**
95
+ * The exact bytes the caller already read from its validated descriptor.
96
+ *
97
+ * When supplied, the behavioral block is extracted from THESE bytes and the
98
+ * path is not read again (#4541 review round 5). Provisioning copies the
99
+ * roleguide into the new worktree from the same bytes, so the file in the
100
+ * worktree and the block injected into that team's per-turn context are
101
+ * guaranteed to be the same content — two reads of one path can disagree.
102
+ * When absent, the path is read (with full containment) as before.
103
+ */
104
+ raw?: string | null;
105
+ };
64
106
  }): void;
65
107
  export declare function syncClaudeConfig(worktreePath: string, opts?: {
66
108
  baseBranch?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAA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