@memnexus-ai/mx-agent-cli 0.1.273 → 0.1.275

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 (30) hide show
  1. package/dist/__tests__/agents-md-canonicalization.test.js +27 -1
  2. package/dist/__tests__/agents-md-canonicalization.test.js.map +1 -1
  3. package/dist/__tests__/coordination-401-production-wiring.test.d.ts +19 -0
  4. package/dist/__tests__/coordination-401-production-wiring.test.d.ts.map +1 -0
  5. package/dist/__tests__/coordination-401-production-wiring.test.js +97 -0
  6. package/dist/__tests__/coordination-401-production-wiring.test.js.map +1 -0
  7. package/dist/__tests__/coordination-401-recovery.test.d.ts +22 -0
  8. package/dist/__tests__/coordination-401-recovery.test.d.ts.map +1 -0
  9. package/dist/__tests__/coordination-401-recovery.test.js +577 -0
  10. package/dist/__tests__/coordination-401-recovery.test.js.map +1 -0
  11. package/dist/__tests__/coordination-brief-pin.test.js +10 -2
  12. package/dist/__tests__/coordination-brief-pin.test.js.map +1 -1
  13. package/dist/__tests__/coordination-brief.test.js +9 -1
  14. package/dist/__tests__/coordination-brief.test.js.map +1 -1
  15. package/dist/__tests__/coordination-provision.test.js +17 -2
  16. package/dist/__tests__/coordination-provision.test.js.map +1 -1
  17. package/dist/__tests__/coordination-token.test.js +24 -0
  18. package/dist/__tests__/coordination-token.test.js.map +1 -1
  19. package/dist/agent-config/AGENTS.md.template +2 -0
  20. package/dist/agent-config/claude-md/CLAUDE.overlay.memnexus.md +2 -0
  21. package/dist/agent-config/hooks/coordination-brief.sh +61 -9
  22. package/dist/commands/coordination.d.ts +40 -6
  23. package/dist/commands/coordination.d.ts.map +1 -1
  24. package/dist/commands/coordination.js +222 -10
  25. package/dist/commands/coordination.js.map +1 -1
  26. package/dist/lib/coordination-token.d.ts +104 -2
  27. package/dist/lib/coordination-token.d.ts.map +1 -1
  28. package/dist/lib/coordination-token.js +223 -42
  29. package/dist/lib/coordination-token.js.map +1 -1
  30. package/package.json +1 -1
@@ -90,7 +90,33 @@ const SHIM_MAX_BYTES = 600;
90
90
  * deploy path and hashing the written bytes. The value superseded by this one is
91
91
  * `b2c9bc169b11d2685b0f1824f64eecd86c769c1495088ef9526217ea558a7ec4`.
92
92
  */
93
- const CANONICAL_SHA256 = '605c8ff0d0a683a5807f5ae4f590be497ac1ab0b6d73a5e7e7f8b1948fd777af';
93
+ /*
94
+ * Re-derived after #5019: that PR added a reviewed paragraph to the instruction
95
+ * content — the standing fact that production holds no validated customers, so
96
+ * no production number is a proof point about customer behaviour — but it added
97
+ * it by editing the GENERATED `agent-config/AGENTS.md.template` directly instead
98
+ * of a compose source, and it did not re-pin this digest. Both guards then failed
99
+ * on main: claude-md-compose reported DRIFT, and this digest still matched the
100
+ * pre-#5019 template
101
+ * (`605c8ff0d0a683a5807f5ae4f590be497ac1ab0b6d73a5e7e7f8b1948fd777af`, the value
102
+ * superseded here — it is the hash of the template at 34c7feab7, which is the
103
+ * proof that the pin was never updated rather than that content was lost).
104
+ *
105
+ * The paragraph now lives in the SOURCE overlay
106
+ * (`claude-md/CLAUDE.overlay.memnexus.md`), with the product name parameterized
107
+ * as `{{PRODUCT_NAME}}` like the rest of that file, and the template was
108
+ * recomposed with `compose.mjs --write`. It could not go in `CLAUDE.core.md`:
109
+ * the core is project-agnostic and compose.mjs throws on any `{{...}}` token
110
+ * there. The text is byte-identical to what #5019 shipped; only its position
111
+ * moved, from mid-`core:po-communication` to immediately after the dogfooding
112
+ * sentence it elaborates, because the overlay cannot inject into the middle of a
113
+ * core block.
114
+ *
115
+ * Digest below re-derived by running this test's own deploy path — deployClaudeMd
116
+ * into a scratch worktree, hash the written bytes (21,206 bytes) — NOT by copying
117
+ * it out of the CI failure log.
118
+ */
119
+ const CANONICAL_SHA256 = '5b5a4cd853950100eff6ffa3060776e1e06720e23c50a8147b2bc8b571bd0731';
94
120
  let worktree;
95
121
  beforeEach(() => {
96
122
  worktree = mkdtempSync(join(tmpdir(), 'mx-agents-md-'));
@@ -1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C;QACpF,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnF,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACpC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;QACjF,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;QACjF,0EAA0E;QAC1E,6EAA6E;QAC7E,+EAA+E;QAC/E,MAAM,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAChD,MAAM,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * #4970 — the PRODUCTION wiring of the 401-recovery wrapper.
3
+ *
4
+ * WHY THIS FILE EXISTS (security review of #4970). Every case in
5
+ * coordination-401-recovery.test.ts goes through prepareClient({ client }) — the
6
+ * INJECTED branch. The branch that actually ships is the provisioned one, which
7
+ * builds an HttpCoordinationClient and wraps it. The reviewer proved that branch
8
+ * was covered by nothing: replacing its `return withTokenRefresh(...)` with a
9
+ * bare `return new HttpCoordinationClient(cfg)` — i.e. removing 401 recovery from
10
+ * EVERY REAL INVOCATION — left the whole suite green. So the claim "all commands
11
+ * recover and fail loud" held for injected clients only.
12
+ *
13
+ * These tests reach that branch: the token module is mocked so no `az` or
14
+ * filesystem is touched, and HttpCoordinationClient is replaced with a stub whose
15
+ * drain 401s. If the wrapper is removed from the provisioned path, the 401
16
+ * escapes as a plain ServiceHttpError and both cases below fail.
17
+ */
18
+ export {};
19
+ //# sourceMappingURL=coordination-401-production-wiring.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordination-401-production-wiring.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/coordination-401-production-wiring.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * #4970 — the PRODUCTION wiring of the 401-recovery wrapper.
3
+ *
4
+ * WHY THIS FILE EXISTS (security review of #4970). Every case in
5
+ * coordination-401-recovery.test.ts goes through prepareClient({ client }) — the
6
+ * INJECTED branch. The branch that actually ships is the provisioned one, which
7
+ * builds an HttpCoordinationClient and wraps it. The reviewer proved that branch
8
+ * was covered by nothing: replacing its `return withTokenRefresh(...)` with a
9
+ * bare `return new HttpCoordinationClient(cfg)` — i.e. removing 401 recovery from
10
+ * EVERY REAL INVOCATION — left the whole suite green. So the claim "all commands
11
+ * recover and fail loud" held for injected clients only.
12
+ *
13
+ * These tests reach that branch: the token module is mocked so no `az` or
14
+ * filesystem is touched, and HttpCoordinationClient is replaced with a stub whose
15
+ * drain 401s. If the wrapper is removed from the provisioned path, the 401
16
+ * escapes as a plain ServiceHttpError and both cases below fail.
17
+ */
18
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
19
+ // Mock the token module: prepareClient's provisioned branch requires a resolved
20
+ // token, and the refresh hook must be observable without reaching Key Vault.
21
+ vi.mock('../lib/coordination-token.js', () => ({
22
+ resolveCoordinationToken: vi.fn(),
23
+ refreshCoordinationToken: vi.fn(),
24
+ }));
25
+ // Replace ONLY the HTTP client class; keep the real error types and config
26
+ // resolution so the wrapper is exercised against the same shapes it sees live.
27
+ const constructedWith = [];
28
+ let drainImpl = async () => ({ messages: [], remaining: 0, batchId: '' });
29
+ vi.mock('../lib/coordination-client.js', async (importOriginal) => {
30
+ const actual = await importOriginal();
31
+ class StubHttpClient {
32
+ constructor(cfg) {
33
+ constructedWith.push(cfg.token ?? '');
34
+ }
35
+ drain() { return drainImpl(); }
36
+ async enqueue() { return { messageId: 'm', duplicate: false }; }
37
+ async confirmDrain() { }
38
+ async ack() { }
39
+ async history() { return { messages: [], nextBefore: '' }; }
40
+ async respondToMessage() { return { messageId: '', obligationState: 'resolved', stateNote: null, stateChangedAt: '' }; }
41
+ async getObligations() { return { owe: [], owed: [] }; }
42
+ }
43
+ return { ...actual, HttpCoordinationClient: StubHttpClient };
44
+ });
45
+ import { prepareClient, CoordinationAuthError, TOKEN_REJECTED_MARKER } from '../commands/coordination.js';
46
+ import { resolveCoordinationToken, refreshCoordinationToken } from '../lib/coordination-token.js';
47
+ import { ServiceHttpError } from '../lib/coordination-client.js';
48
+ const mockResolve = resolveCoordinationToken;
49
+ const mockRefresh = refreshCoordinationToken;
50
+ const savedEnv = { ...process.env };
51
+ beforeEach(() => {
52
+ constructedWith.length = 0;
53
+ mockResolve.mockReset();
54
+ mockRefresh.mockReset();
55
+ vi.spyOn(process.stderr, 'write').mockImplementation((() => true));
56
+ process.env.MX_COORDINATION_MODE = 'queue';
57
+ process.env.MX_COORD_SERVICE_URL = 'http://coordination.test';
58
+ delete process.env.MX_COORD_SERVICE_TOKEN;
59
+ mockResolve.mockReturnValue({ status: 'resolved', token: 'stale-token', project: 'memnexus', slug: 'platform', source: 'cache' });
60
+ });
61
+ afterEach(() => {
62
+ vi.restoreAllMocks();
63
+ process.env = { ...savedEnv };
64
+ });
65
+ describe('#4970 prepareClient — the PROVISIONED (shipping) client recovers and fails loud', () => {
66
+ it('a surviving 401 on the real client path is a LOUD CoordinationAuthError, and the token was refetched once', async () => {
67
+ drainImpl = async () => { throw new ServiceHttpError(401, 'invalid token'); };
68
+ mockRefresh.mockReturnValue({ status: 'refreshed', token: 'fresh-token', project: 'memnexus', slug: 'platform', source: 'keyvault', cacheInvalidated: true });
69
+ const client = prepareClient();
70
+ expect(client).not.toBeNull();
71
+ const err = await client.drain({}).then(() => null, (e) => e);
72
+ // MUTATION PIN: with the wrapper removed from coordination.ts's provisioned
73
+ // branch this is a bare ServiceHttpError and nothing refetches.
74
+ expect(err).toBeInstanceOf(CoordinationAuthError);
75
+ expect(err.message).toContain(TOKEN_REJECTED_MARKER);
76
+ expect(mockRefresh).toHaveBeenCalledTimes(1);
77
+ expect(mockRefresh).toHaveBeenCalledWith('stale-token');
78
+ // The retry ran against a REBUILT client carrying the fresh token.
79
+ expect(constructedWith).toEqual(['stale-token', 'fresh-token']);
80
+ });
81
+ it('the real client path self-heals: one 401, refetch, retry succeeds', async () => {
82
+ let n = 0;
83
+ drainImpl = async () => {
84
+ n++;
85
+ if (n === 1)
86
+ throw new ServiceHttpError(401, 'invalid token');
87
+ return { messages: [], remaining: 0, batchId: 'b1' };
88
+ };
89
+ mockRefresh.mockReturnValue({ status: 'refreshed', token: 'fresh-token', project: 'memnexus', slug: 'platform', source: 'keyvault' });
90
+ const res = await prepareClient().drain({});
91
+ expect(res).toEqual({ messages: [], remaining: 0, batchId: 'b1' });
92
+ expect(n).toBe(2);
93
+ expect(process.env.MX_COORD_SERVICE_TOKEN).toBe('fresh-token'); // in-memory only
94
+ expect(constructedWith).toEqual(['stale-token', 'fresh-token']);
95
+ });
96
+ });
97
+ //# sourceMappingURL=coordination-401-production-wiring.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordination-401-production-wiring.test.js","sourceRoot":"","sources":["../../src/__tests__/coordination-401-production-wiring.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,gFAAgF;AAChF,6EAA6E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,GAAG,CAAC,CAAC;QACV,SAAS,GAAG,KAAK,IAAI,EAAE;YACrB,CAAC,EAAE,CAAC;YACJ,IAAI,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,gBAAgB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;YAC9D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvD,CAAC,CAAC;QACF,WAAW,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAEtI,MAAM,GAAG,GAAG,MAAM,aAAa,EAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAE7C,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB;QACjF,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * #4970 — a REJECTED coordination token must never read as an empty inbox.
3
+ *
4
+ * Before this, resolveCoordinationToken returned the per-worktree cache
5
+ * unconditionally, nothing deleted that cache on an HTTP error, and runBrief
6
+ * called drain() with no handling at all. Post-rotation every team's session
7
+ * start would present the dead cached token forever with no self-heal, and the
8
+ * session-start hook discarded the failure entirely.
9
+ *
10
+ * THE DIRECTION THAT MATTERS (KI-METHOD-MUTATE-FAIL-OPEN). These tests are
11
+ * written to fail when the code goes back to being QUIET. The mutations they
12
+ * must catch are:
13
+ * - the client wrapper swallowing a 401 and returning an empty DrainResponse;
14
+ * - the second 401 being reported as anything other than a loud, non-zero,
15
+ * TOKEN_REJECTED failure;
16
+ * - refreshCoordinationToken keeping the stale cache file;
17
+ * - the recovery being wired into runBrief only, leaving drain/history silent.
18
+ * A test that only asserts the happy retry path would pass against every one of
19
+ * those, so each case below also asserts the ABSENCE of the reassuring output.
20
+ */
21
+ export {};
22
+ //# sourceMappingURL=coordination-401-recovery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordination-401-recovery.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/coordination-401-recovery.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}