Repository navigation
Commit b968a15
committed
Add mcode-trajectory-studio: read-only session trajectory inspection via the runtime SQLite projection
A Plugin that answers questions about mcode's own sessions: which sessions exist, what
each one was for, how far it got, what the user actually asked for, what failed, and what
a background task captured. Read-only, over `~/.minimax/v2/sqlite/runtime-state.sqlite`
with the per-session `messages.jsonl` as a fallback. 13 MCP tools plus a loopback-only
web panel, zero runtime dependencies, no build step.
This commit is the plugin and everything four review rounds and a mutation sweep changed
in it. The rounds, in order, each closing reproduced defects rather than named ones:
1. Symlink escapes through task and session directories; credential redaction missing the
forms the runtime actually stores (JSON text, escaped JSON, a key and its separator with
a quote between); the panel's Host/Origin/Sec-Fetch-Site set described as authorization
when it is a CSRF fence; `readOnlyHint` wrong on the one tool that starts a listener;
and a Node floor that understated what `node:sqlite` needs.
2. Structured key names (`clientSecret`, `refreshToken`, `xApiKey`) judged by exact match,
so they passed a value-only sweep; `stats.workspaceDir` reaching the panel unredacted
beside the field above it that was folded; record lists bounded per string and not per
response; a JSONL buffer that grew until EOF before the line cap was checked; and a
documented containment boundary narrowed to match what the code enforces.
3. `/api/overview` throwing `ReferenceError` for any session with a non-empty agent
definition — a fixture that stubbed the definition to `null` had hidden it; an event
page trimmed to the byte budget returning the store's own cursor, so records 209–999
of a 1000-record page were unreachable forever; and a byte ceiling implemented as a
character count, which multibyte rows walked straight through.
4. `trajectory_tasks` advancing by rows read rather than delivered, so a byte-trimmed page
answered "no more pages" with hundreds of tasks counted but unreachable; the JSONL
fallback discarding `malformed` exactly when a page stopped on its look-ahead, and
never adopting an all-corrupt artifact at all; a task-index look-ahead clamped back to
its own cap so `capped` could never be true; `tasksOmitted` measured against the read
window and published beside a `tasksTotal` it contradicted; and a list read that
materialised 2,000 unbounded descriptions before egress trimming.
After those, the mutation sweep and the interfaces were audited the way a caller meets
them rather than the way they are written:
- Every record list derives its cursor from records **delivered**, counts omissions
against the **session's own total**, and says which source it read.
- `trajectory_get` grew a `role` filter after measuring the question it opens. A 5,831-record
session holds 11 user messages — 0.2%. Asking "what did the user say" cost one 3 MB call
before and 19 KiB after.
- The redaction sweep is 35× cheaper on a 4 MiB response, after one rule was found
retrying the key separator 64 times per character in text with no separator anywhere.
- `tools/mutation-sweep.mjs` runs all 34 mutation scripts serially and names its failure
categories, because a tally nobody can reproduce is indistinguishable from a clean one.
203 mutants, 0 survivors.
- `tools/browser-check.mjs` drives real Chrome over the DevTools protocol; it is kept out
of the default suite because it needs a browser, and it has caught defects the unit
tests could not see.
The panel carries a per-process 256-bit capability in the URL fragment — never sent to the
server, so never logged and never in a `Referer` — with constant-time comparison on every
`/api/*` route, and `Host`/`Origin`/`Sec-Fetch-Site` as depth. Every outbound payload is
swept once more at the boundary, so a field added later cannot leave unredacted.
CI is scoped to this Plugin: release gates, a stub-free egress contract suite driven
against the real projection, the full suite on ubuntu/macos/windows, and an engine matrix
that asserts the manifest's floor and verified range instead of describing them.1 parent 1ef5e78 commit b968a15
163 files changed
Lines changed: 45288 additions & 0 deletions
File tree
- .github/workflows
- plugins/weekbin/mcode-trajectory-studio
- .claude-plugin
- server
- skills/mcode-trajectory-studio
- test
- tools
- web
- js
- tests/plugins/mcode-trajectory-studio
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments