@memnexus-ai/mx-agent-cli 0.1.296-next.3 → 0.1.296-next.4

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 (44) hide show
  1. package/dist/__tests__/coordination-401-production-wiring.test.js +67 -1
  2. package/dist/__tests__/coordination-401-production-wiring.test.js.map +1 -1
  3. package/dist/__tests__/coordination-brief.test.js +58 -1
  4. package/dist/__tests__/coordination-brief.test.js.map +1 -1
  5. package/dist/__tests__/coordination-client.test.js +113 -1
  6. package/dist/__tests__/coordination-client.test.js.map +1 -1
  7. package/dist/__tests__/coordination-command.test.js +288 -2
  8. package/dist/__tests__/coordination-command.test.js.map +1 -1
  9. package/dist/__tests__/provision-completion-rows.test.js +329 -64
  10. package/dist/__tests__/provision-completion-rows.test.js.map +1 -1
  11. package/dist/__tests__/provision-resume.test.js +146 -0
  12. package/dist/__tests__/provision-resume.test.js.map +1 -1
  13. package/dist/__tests__/provision-row12-stub-server.test.d.ts +21 -0
  14. package/dist/__tests__/provision-row12-stub-server.test.d.ts.map +1 -0
  15. package/dist/__tests__/provision-row12-stub-server.test.js +262 -0
  16. package/dist/__tests__/provision-row12-stub-server.test.js.map +1 -0
  17. package/dist/__tests__/team-token-probe.test.d.ts +16 -0
  18. package/dist/__tests__/team-token-probe.test.d.ts.map +1 -0
  19. package/dist/__tests__/team-token-probe.test.js +295 -0
  20. package/dist/__tests__/team-token-probe.test.js.map +1 -0
  21. package/dist/commands/coordination.d.ts.map +1 -1
  22. package/dist/commands/coordination.js +48 -5
  23. package/dist/commands/coordination.js.map +1 -1
  24. package/dist/commands/create.d.ts +28 -10
  25. package/dist/commands/create.d.ts.map +1 -1
  26. package/dist/commands/create.js +123 -33
  27. package/dist/commands/create.js.map +1 -1
  28. package/dist/lib/coordination-client.d.ts +11 -0
  29. package/dist/lib/coordination-client.d.ts.map +1 -1
  30. package/dist/lib/coordination-client.js +79 -18
  31. package/dist/lib/coordination-client.js.map +1 -1
  32. package/dist/lib/coordination-token.d.ts +20 -0
  33. package/dist/lib/coordination-token.d.ts.map +1 -1
  34. package/dist/lib/coordination-token.js +1 -1
  35. package/dist/lib/coordination-token.js.map +1 -1
  36. package/dist/lib/team-token-probe.d.ts +120 -0
  37. package/dist/lib/team-token-probe.d.ts.map +1 -0
  38. package/dist/lib/team-token-probe.js +202 -0
  39. package/dist/lib/team-token-probe.js.map +1 -0
  40. package/dist/lib/templates.d.ts +1 -1
  41. package/dist/lib/templates.d.ts.map +1 -1
  42. package/dist/lib/templates.js +1 -1
  43. package/dist/standards/known-issues-standard.md +380 -0
  44. package/package.json +1 -1
@@ -18,6 +18,9 @@ import { vaultTokenPresent, VAULT_NAME } from '../lib/vault.js';
18
18
  // Row 10's other half (#288). For a credential-endpoint project the row asks
19
19
  // whether a credential is OBTAINABLE, not whether a Key Vault secret exists.
20
20
  import { usesCredentialEndpoint, provisionCredentialForWorktree, credentialCacheState, credentialCachePath, writeCredentialCache, } from '../lib/coordination-token.js';
21
+ // Row 12's probe (#15, v41): one GET /obligations as the new team. Its own module
22
+ // so the completion-row tests stub it by module, as they do rows 9 and 10.
23
+ import { probeTeamToken } from '../lib/team-token-probe.js';
21
24
  /**
22
25
  * Row 10's remedy for a 403 in a project the coordination service creates on
23
26
  * login (#507). The compiled-project remedy ("an operator creates a grant", or
@@ -2048,6 +2051,17 @@ function checkSeedShape(name, leaderState, requireProduct) {
2048
2051
  }
2049
2052
  /** Row 3 for the extras: they hang off row 3 and are told apart by the letter. */
2050
2053
  const EXTRA_ANCHOR_ROW_N = 3;
2054
+ /** Row 12's label: exactly what the probe proves, and nothing it does not (#15). */
2055
+ const ROW_12_LABEL = 'the new team\'s token authenticates to the coordination service (GET /obligations 200)';
2056
+ /**
2057
+ * Row 12's detail for a Key Vault project, which `provision` does not probe
2058
+ * (plan item 5). It names the step, so under the product owner's ruling on #15
2059
+ * (comment 6135468021) the row is a named human step there, not a repair.
2060
+ */
2061
+ const ROW_12_KEY_VAULT_STEP = 'not probed: this project\'s tokens come from Key Vault; run `mx-agent coordination brief` in the new '
2062
+ + 'worktree after its first `start`';
2063
+ const ROW_12_RECHECK_DETAIL = 'not run: --recheck does not contact the coordination service';
2064
+ const ROW_12_STOPPED_DETAIL = 'not run: provision stopped before the probe';
2051
2065
  /**
2052
2066
  * Whether the committed project config names a different coordination URL than
2053
2067
  * the level that actually won.
@@ -2725,21 +2739,62 @@ function checkCompletionRows(i) {
2725
2739
  detail: 'permanently manual: only the new team may write inside its own worktree',
2726
2740
  required: false,
2727
2741
  });
2728
- // Row 12 stays not asserted: the claim its label makes needs the service, the
2729
- // roster and a token (#15), and none of those is checked here. What this
2730
- // version can say is whether a coordination URL resolves at all, which is the
2731
- // part that was silently missing (#32). printCompletionRows writes the line.
2742
+ // Row 12: the new team's token authenticates to the coordination service
2743
+ // (#15; v41 plan on #15, comment 6135520093, amendment 1, comment 6135584856).
2744
+ //
2745
+ // REQUIRED on the credential-endpoint path. The product owner ruled on
2746
+ // 2026-10-13 (comment 6135468021 on #15) that a row 12 which names no step and
2747
+ // still lets "Team Created!" print is a repair. So any probe outcome other than
2748
+ // asserted refuses the banner, the convention rows 3 to 5, 9, 10 and 15 follow.
2749
+ //
2750
+ // The probe itself runs in `runCreate` (it is an HTTP request) and reaches
2751
+ // here as `i.row12`. The URL source (#32) stays on the row and in the detail.
2732
2752
  const urlSource = i.coordinationUrlSource ?? null;
2733
- rows.push({
2753
+ const urlNote = urlSource === null
2754
+ ? 'no coordination-service-url in env, config, or mx-agent.config.json; '
2755
+ + 'set coordinationServiceUrl in mx-agent.config.json'
2756
+ : `coordination URL from ${urlSource}`
2757
+ + (i.coordinationUrlMismatch === true
2758
+ ? '; note: mx-agent.config.json declares a different URL; the '
2759
+ + `${urlSource === 'env' ? 'MX_COORD_SERVICE_URL environment variable' : 'operator config'}`
2760
+ + ' takes precedence'
2761
+ : '');
2762
+ const row12Base = {
2734
2763
  n: 12,
2735
- label: 'mx-agent coordination brief answers without "not registered"',
2736
- asserted: false,
2737
- urlAsserted: urlSource !== null,
2764
+ label: ROW_12_LABEL,
2738
2765
  urlSource: urlSource ?? undefined,
2739
2766
  urlMismatch: i.coordinationUrlMismatch === true,
2740
- detail: '',
2741
- required: false,
2742
- });
2767
+ };
2768
+ if (!usesCredentialEndpoint(i.projectSlug)) {
2769
+ rows.push({ ...row12Base, asserted: false, detail: `${ROW_12_KEY_VAULT_STEP}; ${urlNote}`, required: false });
2770
+ }
2771
+ else {
2772
+ const mode = i.row12 ?? { mode: 'probe', outcome: undefined };
2773
+ if (mode.mode === 'recheck') {
2774
+ rows.push({ ...row12Base, asserted: false, detail: `${ROW_12_RECHECK_DETAIL}; ${urlNote}`, required: false });
2775
+ }
2776
+ else if (mode.mode === 'not-run') {
2777
+ // Not required: the step that stopped provision is the failure, and
2778
+ // listing row 12 beside it would count one fault twice.
2779
+ rows.push({ ...row12Base, asserted: false, detail: `${ROW_12_STOPPED_DETAIL}; ${urlNote}`, required: false });
2780
+ }
2781
+ else {
2782
+ const o = mode.outcome;
2783
+ rows.push(o === undefined
2784
+ ? { ...row12Base, asserted: false, couldNotRun: true, required: true,
2785
+ detail: `the probe did not run, so whether the token authenticates is not established; ${urlNote}` }
2786
+ : o.kind === 'asserted'
2787
+ ? { ...row12Base, asserted: true, required: true, detail: `${o.detail}; ${urlNote}` }
2788
+ : o.kind === 'failed'
2789
+ ? { ...row12Base, asserted: false, required: true, detail: `${o.detail}; ${urlNote}` }
2790
+ : o.kind === 'could-not-run'
2791
+ ? { ...row12Base, asserted: false, couldNotRun: true, required: true, detail: `${o.detail}; ${urlNote}` }
2792
+ // `not-run`: row 10 did not hold, and row 10 is required, so the run
2793
+ // already fails on it. Not required here, so one fault is not
2794
+ // counted twice (plan item 2).
2795
+ : { ...row12Base, asserted: false, required: false, detail: `${o.detail}; ${urlNote}` });
2796
+ }
2797
+ }
2743
2798
  // Row 13: no placeholder survives into a provisioned team (#83 B3).
2744
2799
  //
2745
2800
  // REQUIRED, and it is the row that makes generation safe. Provisioning writes
@@ -2986,12 +3041,9 @@ function printCompletionRows(rows) {
2986
3041
  console.log(chalk.bold(` ${row.sectionHeading}:`));
2987
3042
  // Padded to one width so the verdict column stays a column: `asserted (shape)`
2988
3043
  // is the longest of the three, and rows 3 to 5 are the only ones that print it.
2989
- // A not-asserted row whose `urlAsserted` is true had one of its parts checked
2990
- // (#32), and the verdict column says so: `partly asserted` is its own state,
2991
- // between the green rows and the ones this version does not look at. The row
2992
- // still counts as not asserted, because the claim its label makes needs the
2993
- // roster and a token too.
2994
- const partlyAsserted = !row.asserted && (row.urlAsserted === true || row.partlyAsserted === true);
3044
+ // A not-asserted row with `partlyAsserted` had one of its parts checked (row
3045
+ // 9, #77), and the verdict column says so. It still counts as not asserted.
3046
+ const partlyAsserted = !row.asserted && row.partlyAsserted === true;
2995
3047
  // Could-not-run is its own word, before `partly asserted`: a row that could
2996
3048
  // not look has not had a part hold, so the two are not the same state and the
2997
3049
  // yellow they share does not make them one (#290 Should Fix 4).
@@ -3009,19 +3061,7 @@ function printCompletionRows(rows) {
3009
3061
  : row.required
3010
3062
  ? chalk.red('not asserted ')
3011
3063
  : chalk.yellow('not asserted ');
3012
- // The detail names which part held and which did not, so a resolved URL does
3013
- // not read as nothing and a missing one names the field that fixes it.
3014
- const detail = !row.asserted && row.urlAsserted !== undefined
3015
- ? (row.urlAsserted
3016
- ? `coordination URL from ${row.urlSource}; roster and token not checked (#15)`
3017
- + (row.urlMismatch
3018
- ? '; note: mx-agent.config.json declares a different URL; the '
3019
- + `${row.urlSource === 'env' ? 'MX_COORD_SERVICE_URL environment variable' : 'operator config'}`
3020
- + ' takes precedence'
3021
- : '')
3022
- : 'no coordination-service-url in env, config, or mx-agent.config.json; '
3023
- + 'set coordinationServiceUrl in mx-agent.config.json; roster and token not checked (#15)')
3024
- : row.detail;
3064
+ const detail = row.detail;
3025
3065
  // Printed for asserted rows too: when a row is green on the probe rather than
3026
3066
  // on the id read, the reader is told which evidence held.
3027
3067
  const why = detail ? chalk.dim(` — ${detail}`) : '';
@@ -4323,6 +4363,9 @@ async function runRecheck(i) {
4323
4363
  build: probeBuiltCli(worktreePath),
4324
4364
  credential,
4325
4365
  credentialCheckedByCacheOnly: usesCredentialEndpoint(cfg.projectSlug),
4366
+ // `--recheck` writes nothing and never asks the service (amendment Must Fix
4367
+ // 2), so row 12 is not probed here and is not required.
4368
+ row12: { mode: 'recheck' },
4326
4369
  });
4327
4370
  printCompletionRows(rows);
4328
4371
  const failedRows = rows.filter((r) => r.required && !r.asserted);
@@ -4410,6 +4453,8 @@ async function runProvisionSteps(ctx) {
4410
4453
  let build;
4411
4454
  let credential;
4412
4455
  let coordinationUrlAtProvision = null;
4456
+ /** Row 12's probe outcome, set at step 8b on the credential-endpoint path only. */
4457
+ let row12Probe;
4413
4458
  const memPrefix = cfg.projectSlug ? `${cfg.projectSlug}-` : '';
4414
4459
  const memoryNames = [
4415
4460
  `${memPrefix}${slug}-leader-state`,
@@ -4423,8 +4468,12 @@ async function runProvisionSteps(ctx) {
4423
4468
  * below. Two builders would let a failing run print a row table the successful
4424
4469
  * path could not produce, which is the class of defect the completion check
4425
4470
  * exists to catch.
4471
+ *
4472
+ * Row 12's mode is the one input each caller states explicitly (bar-raiser
4473
+ * Step 4 condition R2): step 8b passes the probe's outcome, the failure
4474
+ * handler passes `not-run`.
4426
4475
  */
4427
- const completionRows = () => checkCompletionRows({
4476
+ const completionRows = (row12) => checkCompletionRows({
4428
4477
  slug,
4429
4478
  projectSlug: cfg.projectSlug,
4430
4479
  baseBranch: cfg.baseBranch,
@@ -4469,6 +4518,7 @@ async function runProvisionSteps(ctx) {
4469
4518
  // Row 10, for a credential-endpoint project. Undefined for every other
4470
4519
  // project, and ignored there.
4471
4520
  credential,
4521
+ row12,
4472
4522
  });
4473
4523
  try {
4474
4524
  // ── 1. Slot allocation ─────────────────────────────────────────────
@@ -5229,8 +5279,46 @@ async function runProvisionSteps(ctx) {
5229
5279
  writeCache: cacheWriteFault(fault),
5230
5280
  });
5231
5281
  }
5282
+ // Row 12's probe (#15, v41): one GET /obligations as the new team.
5283
+ //
5284
+ // THE SAME URL row 10's mint used, `coordinationUrlAtProvision`, resolved
5285
+ // from `projectRoot` at step 0. Never a fresh `resolveClientConfig()` with no
5286
+ // root, which derives one from the current directory (the defect recorded at
5287
+ // the `serviceUrl` argument above). The probe validates it again with the
5288
+ // team-token rules before the token is read.
5289
+ //
5290
+ // Runs whether or not row 10 held: `probeTeamToken` answers `not-run` with no
5291
+ // request when the credential is not a usable 0600 cache, so the row says
5292
+ // why rather than being silent.
5293
+ //
5294
+ // A cached token answered 401 gets ONE re-mint through the same mint this
5295
+ // step uses, with `forceMint`: the callee writes the cache only after the
5296
+ // service has issued a token, so a refused or failed re-mint leaves the old
5297
+ // file as it was (bar-raiser Step 4 condition R1). An issued re-mint whose
5298
+ // cache write fails has removed the old file; row 10 then reports that
5299
+ // write failure, because `probe.credential` is the re-mint's outcome
5300
+ // (security review N-1). `refreshCoordinationToken` is not
5301
+ // used: it needs the `.mx-coordination-team` marker, which the new team
5302
+ // writes later (row 11).
5303
+ const probe = await probeTeamToken({
5304
+ credential,
5305
+ url: coordinationUrlAtProvision?.url,
5306
+ urlSource: coordinationUrlAtProvision?.source,
5307
+ remint: () => provisionCredentialForWorktree({
5308
+ project: cfg.projectSlug,
5309
+ team: slug,
5310
+ worktreePath,
5311
+ serviceUrl: coordinationUrlAtProvision?.url,
5312
+ writeCache: cacheWriteFault(fault),
5313
+ forceMint: true,
5314
+ }),
5315
+ });
5316
+ // Row 10 reports the cache the team's first session will read, which after a
5317
+ // re-mint is the new one.
5318
+ credential = probe.credential;
5319
+ row12Probe = probe.outcome;
5232
5320
  }
5233
- const rows = completionRows();
5321
+ const rows = completionRows({ mode: 'probe', outcome: row12Probe });
5234
5322
  printCompletionRows(rows);
5235
5323
  // Advisory, not a row: nothing fails on it and nothing is gated by it. It names
5236
5324
  // what row 13's closed set cannot see, so a renamed or invented placeholder is
@@ -5362,7 +5450,9 @@ async function runProvisionSteps(ctx) {
5362
5450
  const step = err instanceof ProvisioningStepError
5363
5451
  ? err.step
5364
5452
  : 'a step after the worktree was created';
5365
- const rows = completionRows();
5453
+ // Row 12 is not probed here: provision stopped before the probe, and the
5454
+ // step that stopped it is the failure this message names (condition R2).
5455
+ const rows = completionRows({ mode: 'not-run' });
5366
5456
  printCompletionRows(rows);
5367
5457
  throw new CompletionCheckError(stepFailureMessage({
5368
5458
  step,