@memnexus-ai/mx-agent-cli 0.1.276 → 0.1.277

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.
@@ -107,6 +107,25 @@ mx-agent-system/docs/testing-conventions.md.
107
107
  If existing tests fail *before* your changes, that's a pre-existing issue. Note it but
108
108
  don't fix it in this scope.
109
109
 
110
+ **Verify you are testing current bytes.** Both failure modes below produced a complete,
111
+ confident, wrong picture with no error anywhere — checking the identity of what you read is
112
+ the only defense.
113
+
114
+ - After any force-push, amend, or rebase: `git fetch origin <branch>` and diff the ref
115
+ locally. Never work from `gh pr view` / `gh pr diff` alone — the API has served a
116
+ pre-force-push head, zero comments, and no force-push event on a PR that had all three
117
+ (#5086).
118
+ - A comment count or timeline thinner than you expect is a staleness signal, not a quiet PR.
119
+ - Name the head SHA you actually tested in the QA report: "PASS at 2dd3845d1", not "PASS on
120
+ #5046". A SHA-scoped verdict stays honest after the next force-push; a PR-scoped one does
121
+ not.
122
+ - When checks were re-run to pick up a fix on main: a `pull_request` run executes
123
+ `refs/pull/N/merge`, not main, and reopening a PR does not reliably refresh that ref.
124
+ Poll `gh api repos/OWNER/REPO/pulls/N --jq .merge_commit_sha` until it changes, then
125
+ reopen again. "It ran after the fix landed" is not evidence it ran the fix (#5116).
126
+ - Judge a run's validity from its job log — `HEAD is now at <sha> Merge <head> into <base>`,
127
+ with `<base>` at current main — not the check rollup, which looks identical either way.
128
+
110
129
  ### 3. Review Generated Tests
111
130
 
112
131
  If the Implementation Engineer wrote tests, review them critically:
@@ -79,6 +79,25 @@ Before diving into code, understand what you're protecting:
79
79
 
80
80
  ### 2. Review Changed Files
81
81
 
82
+ **First, verify you are reading current bytes.** Both failure modes below produced a
83
+ complete, confident, wrong picture with no error anywhere — checking the identity of what
84
+ you read is the only defense.
85
+
86
+ - After any force-push, amend, or rebase: `git fetch origin <branch>` and diff the ref
87
+ locally. Never review from `gh pr view` / `gh pr diff` alone — the API has served a
88
+ pre-force-push head, zero comments, and no force-push event on a PR that had all three
89
+ (#5086).
90
+ - A comment count or timeline thinner than you expect is a staleness signal, not a quiet PR.
91
+ - Name the head SHA you actually read in the verdict: "PASS at 2dd3845d1", not "PASS on
92
+ #5046". A SHA-scoped verdict stays honest after the next force-push; a PR-scoped one does
93
+ not.
94
+ - When checks were re-run to pick up a fix on main: a `pull_request` run executes
95
+ `refs/pull/N/merge`, not main, and reopening a PR does not reliably refresh that ref.
96
+ Poll `gh api repos/OWNER/REPO/pulls/N --jq .merge_commit_sha` until it changes, then
97
+ reopen again. "It ran after the fix landed" is not evidence it ran the fix (#5116).
98
+ - Judge a run's validity from its job log — `HEAD is now at <sha> Merge <head> into <base>`,
99
+ with `<base>` at current main — not the check rollup, which looks identical either way.
100
+
82
101
  For each changed file, apply the appropriate security lens:
83
102
 
84
103
  **API endpoints and routes:**
@@ -28,13 +28,43 @@
28
28
  # key state with it; this hook now uses it too. The discipline is unchanged — same
29
29
  # threshold, same required save — it is the attribution that is fixed.
30
30
  #
31
- # When no session id is available (harness supplied none, or jq is unavailable) the
32
- # counter falls back to the legacy worktree-wide key. That over-counts rather than
33
- # under-counts, which keeps the reminder firing instead of silently disabling it.
34
- # #4863 added a branch whose effect is SILENCE (the once-per-session advisory), so
35
- # that promise is no longer automatic: the quiet period is honoured only when a real
36
- # per-session key exists. Without a session id the message repeats rather than
37
- # suppressing — see the suppression check in section 3.
31
+ # When the payload is readable and the harness supplied NO session id, this hook now
32
+ # EXITS SILENTLY: it does not count, does not observe capability, and does not remind.
33
+ # When the payload is unreadable (broken jq) the legacy worktree-wide key is still
34
+ # used, per #4863 — see NO SESSION ID → NO REMINDER below for why the two differ.
35
+ #
36
+ # NO SESSION ID → NO REMINDER (#5013). This reverses what this comment used to say.
37
+ # The old text read: "the counter falls back to the legacy worktree-wide key. That
38
+ # over-counts rather than under-counts, which keeps the reminder firing instead of
39
+ # silently disabling it." That preference was wrong, and it was wrong in a way that
40
+ # only shows up at the concurrency this fleet actually runs at.
41
+ #
42
+ # The worktree-wide fallback key is SHARED BY EVERY AGENT IN THE WORKTREE. Under one
43
+ # leader plus three or more concurrent subagents, each making dozens of tool calls,
44
+ # that one file accumulates all of their calls. Any agent reading it — including a
45
+ # subagent on its FIRST tool call — is told "50 tool calls since last memory save"
46
+ # about work it did not do. That is not over-counting. It is a FALSE PREMISE: the
47
+ # sentence the agent is handed is not true of the agent it is handed to. #4802 fixed
48
+ # exactly this defect for the primary key and left it standing in the fallback.
49
+ #
50
+ # Why silence is the cheaper failure. A missed reminder costs one un-prompted
51
+ # checkpoint, and the agent's own roleguide already tells it when to checkpoint. A
52
+ # false reminder costs compliance with EVERY hook prompt on the fleet: an agent that
53
+ # correctly reasons "this demand's premise is false, I decline it" — which is the
54
+ # #4734 discipline working as designed — has just rehearsed the reasoning that lets
55
+ # it decline a TRUE demand. A control that cries wolf does not degrade only itself.
56
+ # It also makes a genuine hook message indistinguishable from an injected one
57
+ # (#4863/#5006), because "the claim in the message does not match reality" is the
58
+ # main test an agent has for spotting injected content.
59
+ #
60
+ # This is the one degradation in this file that points at silence rather than at
61
+ # over-reporting, and it is deliberately narrow: it applies ONLY when the payload
62
+ # parsed and the session id was absent from it. Every other degradation here picks
63
+ # between two TRUE messages, so over-reporting is the safe direction for them; this
64
+ # one picks between silence and a FALSE message, where it is not. The gate is a
65
+ # discipline aid, not a safety control — nothing is left unprotected while it is
66
+ # quiet — so it is allowed to fail off. No other gate in this file may adopt this
67
+ # pattern by analogy, and the broken-jq path deliberately does not (see the guard).
38
68
  #
39
69
  # CAPABILITY OBSERVATION (#4863). This hook is registered with an empty matcher, so
40
70
  # it fires in EVERY session — including subagents provisioned with Read/Grep/Glob and
@@ -195,6 +225,29 @@ fi
195
225
  SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null) || SESSION_ID=""
196
226
  SESSION_ID="${SESSION_ID//[^a-zA-Z0-9_-]/}"
197
227
 
228
+ # NO SESSION ID → NO REMINDER (#5013). Everything below this line — the counter, the
229
+ # capability marker, the advisory, the demand — is a statement about ONE session. With
230
+ # no session id there is no key that isolates one session, only the worktree-wide key
231
+ # shared by every agent in the worktree, and a count taken from a shared key is not a
232
+ # fact about the agent being handed it. Exit before any of that state is created or
233
+ # read, so no shared counter file can exist to be misattributed later. Silent and
234
+ # exit 0: this path is not an error, and a message here would be the false premise
235
+ # this guard exists to prevent. Rationale in full in the header.
236
+ #
237
+ # SCOPED TO THE READABLE-PAYLOAD CASE ON PURPOSE. The condition is "jq worked and the
238
+ # harness supplied no session id", not "no session id for any reason". A payload this
239
+ # hook cannot parse (PAYLOAD_OPAQUE) keeps its existing behaviour — worktree-wide key,
240
+ # demand fires — because #4863's security review specifically established that a
241
+ # broken or missing jq must not silently disable this gate, and reproduced the
242
+ # inertness it causes. That property is worth more than closing a false-premise path
243
+ # that only opens when jq itself is broken: a broken jq is a rare, machine-wide fault,
244
+ # while a harness that omits session_id is a routine condition on the hot path. This
245
+ # does leave one false-premise path alive under broken jq. It is documented, not
246
+ # overlooked; closing it needs #4863 reopened, not a quiet reversal here.
247
+ if [[ "$PAYLOAD_OPAQUE" -eq 0 && -z "$SESSION_ID" ]]; then
248
+ exit 0
249
+ fi
250
+
198
251
  WORKTREE_NAME="${CLAUDE_WORKTREE_NAME:-default}"
199
252
  # Sanitize: alphanumeric, hyphens, underscores only — prevent path traversal
200
253
  WORKTREE_NAME="${WORKTREE_NAME//[^a-zA-Z0-9_-]/}"
@@ -317,15 +370,15 @@ if [[ "$CURRENT" -ge "$THRESHOLD" ]]; then
317
370
  # This is not the hook being disabled — the demand returns the moment the
318
371
  # session uses Bash or a MemNexus MCP tool.
319
372
  #
320
- # The `-n "$SESSION_ID"` is the load-bearing part (#4863 security review). The
373
+ # The `-n "$SESSION_ID"` was the load-bearing part (#4863 security review): the
321
374
  # quiet period is a claim about ONE session ("this session has already been
322
- # advised"), so it may only be honoured when the state it reads is actually
323
- # keyed to a session. Without a session id every session in the worktree shares
324
- # one .advised file, and a single read-only subagent's advisory would silence
325
- # the checkpoint gate for capable sessions beside it — the #4802 cross-session
326
- # attribution bug, reintroduced in the one branch whose effect is silence.
327
- # No session id → never suppress; the message repeats instead. Over-reminding
328
- # is the failure this file has always chosen.
375
+ # advised"), so it may only be honoured when the state it reads is actually keyed
376
+ # to a session. As of #5013 it is UNREACHABLE-FALSE — a sessionless call now exits
377
+ # at the top of the file and never gets here, so SESSION_ID is always non-empty at
378
+ # this point. Retained as a defence-in-depth assertion, not as live logic: it costs
379
+ # one builtin test on a path that runs once per 50 calls, and it keeps this branch
380
+ # correct on its own terms if the top-of-file guard is ever moved or relaxed. Do
381
+ # not read it as evidence that a sessionless call can reach this branch.
329
382
  if [[ "$CAPABLE" -eq 0 && -n "$SESSION_ID" && -f "$ADVISED_FILE" ]]; then
330
383
  exit 0
331
384
  fi
@@ -440,6 +493,13 @@ if [[ "$CURRENT" -ge "$THRESHOLD" ]]; then
440
493
  fi
441
494
 
442
495
  SAVE_COMMAND=" mx memories create --conversation-id \"<conv_id>\" --content \"[what you've done]. Next: [next step].\" --topics \"<component>,in-progress\" --code-context '${CODE_CONTEXT}'"
496
+ # #5006. `<conv_id>` on its own reads as "any conversation id", and an agent whose
497
+ # brief named no conversation fills it with "NEW" — which is the documented default
498
+ # for starting a topic. Each such save opens a fresh conversation, so one iteration's
499
+ # record ends up split across several, and nothing reports that it happened. The
500
+ # placeholder cannot carry this itself without ceasing to be copy-pasteable, so the
501
+ # guidance is a line beside it, matching how CODE_CONTEXT_NOTE is handled above.
502
+ CONV_ID_NOTE=" <conv_id>: use the conversation id from your task brief. If you have none, ask the session that dispatched you rather than passing \"NEW\" — a new conversation per checkpoint fragments one iteration's record across several."
443
503
 
444
504
  # ── 3b. Provenance block (#4734/#4863) ────────────────────────────────────
445
505
  # An interruption that demands work is indistinguishable, by shape, from the
@@ -481,6 +541,7 @@ if [[ "$CURRENT" -ge "$THRESHOLD" ]]; then
481
541
  echo " - If you CAN save one, this is the command:"
482
542
  echo "$SAVE_COMMAND"
483
543
  echo " (or the create_memory MCP tool, with the same codeContext)."
544
+ echo "$CONV_ID_NOTE"
484
545
  if [[ -n "$CODE_CONTEXT_NOTE" ]]; then
485
546
  echo "$CODE_CONTEXT_NOTE"
486
547
  fi
@@ -504,6 +565,7 @@ if [[ "$CURRENT" -ge "$THRESHOLD" ]]; then
504
565
  # code is the same defect class in the other direction.
505
566
  echo "1. Save a checkpoint now (required before continuing):"
506
567
  echo "$SAVE_COMMAND"
568
+ echo "$CONV_ID_NOTE"
507
569
  # `if`, not `[[ ... ]] && echo`. Policy, not a claim about this line: never
508
570
  # leave a failing test within reach of an ERR trap. Whether a given position
509
571
  # is exempt depends on where the list sits and how it is nested — too fragile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memnexus-ai/mx-agent-cli",
3
- "version": "0.1.276",
3
+ "version": "0.1.277",
4
4
  "description": "CLI for creating and managing AI agent teams",
5
5
  "type": "module",
6
6
  "bin": {