Skip to content

Commit 81f24c3

Browse files
crystianclaude
andcommitted
feat(activity): shell sightings count as executions and fold as reads
User report: activity of type Bash showed in the inspector's Activity section but never on the node card. Earlier passes fixed the inspector and the stats persistence and still missed the card, because the root cause was the contract, not a UI defect. Since the 2026-08-18 field audit, `access: 'shell'` starts were routed by `ActivityStatsService` into the typed recent log with no count mutation, and the card's execution pill hides at `count` 0 while the wire stats carry no sighting field at all, so a node named only by shell commands was structurally invisible on the map. Two user decisions (2026-08-30), one commit: - Shell sightings count like any other resource access. The `sight()` short-circuit is gone; `count()` admits the `shell` access class and keeps tagging both ends of the recent entry `kind: 'shell'`, so the inspector still tells a sighting apart from a read. - Shell sightings are evidence for the observed-relations fold too: `foldAccessFrame` maps `shell` next to `read` into a `reads` relation, so the observed-* finders see a command naming a file as a read and lean on their repetition + points-coverage gates to absorb the heuristic noise. `write` frames stay unfolded, a separate decision. The inspector's count-0 empty gate stays, now for rows checkpointed before this change (spec/db-schema.md notes them). Spec prose updated in provider-activity.md (§Execution stats, `access` enum note, §Session journal Consumption, §Capture level rung 5), index regenerated, ROADMAP gains the decision bullet and annotates the 2026-08-18 history it reverses. Patch changeset for spec and cli with a user-facing note. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 6650c9f commit 81f24c3

12 files changed

Lines changed: 73 additions & 71 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@skill-map/spec": patch
3+
"@skill-map/cli": patch
4+
---
5+
6+
Shell sightings (a `.md` named in a Bash / `run_command` / `bash` command under capture rung 5) now count as evidence: they add to the node's execution stats, so the node card's execution pill agrees with the inspector's Activity section, and the session-journal fold turns them into `reads` relations for the observed-* finders; the recent-log entry stays tagged `kind: "shell"`. Spec: `provider-activity.md` §Execution stats, §Capture level rung 5, §Session journal.
7+
8+
## User-facing
9+
10+
Files mentioned in a shell command (Bash) now count on the node card's execution counter and count as reads for the observed-link finders, matching what the inspector's Activity section already listed.

‎ROADMAP.md‎

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

‎spec/db-schema.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ The BFF's `/api/nodes` route loads the full set of favorited paths once per requ
496496

497497
### `state_activity_stats`
498498

499-
Runtime execution stats per node: the checkpoint of the BFF's in-memory accumulator ([`provider-activity.md`](./provider-activity.md) §Execution stats). One row per node the live activity ever touched, counted executions AND shell sightings alike (a sighting keeps `count` at 0 next to a non-empty recent log). Written debounced by `sm serve` on every mutation, read once at boot to hydrate the accumulator, so counts survive a server restart. Machine-generated (§Storage rule in [`architecture.md`](./architecture.md)); cleared per node by `DELETE /api/activity/node/<pathB64>`, never by a scan.
499+
Runtime execution stats per node: the checkpoint of the BFF's in-memory accumulator ([`provider-activity.md`](./provider-activity.md) §Execution stats). One row per node the live activity ever touched (shell sightings count like any other start since 2026-08-30, see the shell bullet there; a row checkpointed before that may still carry `count` 0 next to a non-empty recent log). Written debounced by `sm serve` on every mutation, read once at boot to hydrate the accumulator, so counts survive a server restart. Machine-generated (§Storage rule in [`architecture.md`](./architecture.md)); cleared per node by `DELETE /api/activity/node/<pathB64>`, never by a scan.
500500

501501
| Column | Type | Constraint |
502502
|---|---|---|

‎spec/index.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
"conformance/fixtures/view-slots-all/.skill-map/plugins/all-slots/analyzers/everything/extension.json": "8f13f91539ced01f332246f90e1957efeedfeb249c647e21a6b4ffda67d312c5",
635635
"conformance/fixtures/view-slots-all/.skill-map/plugins/all-slots/analyzers/everything/index.js": "3aea0f750e4ff3495210ec6306e3bff7130d87c9d970a02feb31a28860fe227d",
636636
"conformance/fixtures/view-slots-all/.skill-map/plugins/all-slots/plugin.json": "c48e8a0574947ade0b4eb189d6bc27a48e24f92f616aacdc177f2d22d472a599",
637-
"db-schema.md": "e83965a154fcefe80821793f27ca0d2659e7e797b1b349120eaa03048895d096",
637+
"db-schema.md": "a6eaabaa68473af31ec6e2162a52218e2dee5794fd120f5368a2aa1a69a024e8",
638638
"input-types.md": "61c9ea9083e1111f4802c38a112bde5c9d948a859f0b398404d731a2d00da7d8",
639639
"interfaces/security-scanner.md": "1e90d23254c4962989a56f64a625b5b7bcc469a2064adcdd07950fd0a6ddbfc9",
640640
"job-events.md": "7e722580e0b9dd0238778436ec4c1e64d355f170767138f2405511d376116741",
@@ -645,7 +645,7 @@
645645
"plugin-kv-api.md": "a9fe61f8c00a689eabb806dadafa55bd275cd0226495a0ffc6d8475ce00b4487",
646646
"plugin-quickstart.md": "1903fa03303d75cd25cc16af3c2876d5eda6e1d9a694e8d3b794a67235e9afb8",
647647
"prompt-preamble.md": "592878ce0dc1c6811fbd24c7bd2c12a69555b28d92071723c321a70efa75e6f5",
648-
"provider-activity.md": "df29eae2aa5b8ebebde512f3a2e53e6de8b722e38abed161f717ae4859b12976",
648+
"provider-activity.md": "fe0e9ea7e34e9aa1b3c063d652fab72337fb9f24ab8de1a7d91a886ce85d87cb",
649649
"schemas/annotations.schema.json": "2020dc285288653eb775bbc80c72a85191bd0411bc11bd752b487a1ad5ec6f98",
650650
"schemas/api/rest-envelope.schema.json": "f2a36211a925df38377c8a7bada8a6fad26ee97ccdb7066bc3d65ecf1c415559",
651651
"schemas/bump-report.schema.json": "dea9390aa706955e2a47f6254310943d96ceb74a2f51539be86f0d389e33fa86",

‎spec/provider-activity.md‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ Broadcast over `/ws` in the common envelope of
571571
`mcp://` server (a tool call), `"read"` when it is a file a unit read,
572572
`"write"` when the unit wrote / edited it (2026-08-17, the capture-level
573573
ladder's third rung), or `"shell"` for a HEURISTIC path sighting parsed
574-
out of a shell command (the ladder's fifth rung; never folded into
575-
observed relations). Absent on a UNIT's own execution (a skill / agent /
574+
out of a shell command (the ladder's fifth rung; folds as `reads` since
575+
2026-08-30). Absent on a UNIT's own execution (a skill / agent /
576576
command start). The resolver derives the resource-vs-unit split from the
577577
signal SHAPE, a PATH signal is a resource access, a NAME signal (`kind` +
578578
`name`) is a unit execution, so a unit reading another unit's file still
@@ -807,7 +807,7 @@ The BFF accumulates per-node execution stats in memory as the hot path and CHECK
807807
fresh owner id and counts again. The dedupe memory is append-only (owners
808808
are not forgotten on `ownerScope` ends, or every pause/resume cycle would
809809
recount).
810-
- `access: "shell"` starts NEVER count: a heuristic path sighting parsed out of a shell command is not an execution (§Capture level rung 5, "a SIGHTING, not evidence"). The sighting still lands in the typed recent log (below), tagged `kind: "shell"`, so the inspector can show who named the file; the node's `count`, `lastStartAt`, `lastOwner` and owner set stay untouched. The frame still rides WITH the node's (unchanged) `stats`, so a client learns the node has a log to show: a `count` of 0 next to a non-empty recent log is a sighted-only node, never an executed one (custody `keepAlive` starts, which log nothing, keep riding bare).
810+
- `access: "shell"` starts COUNT like any other resource access (user decision 2026-08-30, reversing the 2026-08-18 no-count rule): the execution pill on the node card is the only per-node counter the map shows, and a node named by a shell command that never counted stayed invisible there while the inspector listed the sighting, a split the operator read as a defect. The entry still lands in the typed recent log (below) tagged `kind: "shell"`, so the inspector tells a shell sighting apart from a read, and the frame rides WITH the node's updated `stats` like every counted start. The same decision admits the class as evidence in the observed-relations fold, where a sighting folds as `reads` (§Session journal, Consumption): the command named the file, and the analyzer gates absorb the heuristic noise. Custody `keepAlive` starts keep riding bare (they log nothing).
811811
- All other starts (skill invocations, command expansions, markdown reads)
812812
count on every signal.
813813

@@ -1106,7 +1106,7 @@ WHICH nodes executed and who spawned whom, no latency, no tokens, no content.
11061106
frames into **observed relations**, `(source node, target node)` pairs with
11071107
`relation: invokes` (an MCP tool call correlated to its calling unit by
11081108
owner), `relation: spawns` (a spawn frame carrying both resolved paths), or
1109-
`relation: reads` (an `access: 'read'` frame correlated to its reading unit
1109+
`relation: reads` (an `access: 'read'` frame, or since 2026-08-30 an `access: 'shell'` sighting, the command named the file, correlated to its reading unit
11101110
by owner, the same correlation the invokes class uses; the read path never
11111111
becomes the owner's current unit). The unit correlation is TURN-BOUNDED: a
11121112
`turnEnd` frame clears its owner's current-unit claim, so an access in a
@@ -1218,11 +1218,7 @@ per event, cheap enough that the hooks always install their full surface):
12181218
travels: the adapter extracts `.md` path tokens from the command
12191219
(quotes stripped, URL-shaped tokens ignored, deduped, at most 5 per
12201220
command), emits one PATH signal per token with `detail: "Bash"` and
1221-
`access: "shell"`, and drops the rest. A shell frame is a SIGHTING,
1222-
not evidence: it lights the map and lands in recordings, but the
1223-
observed-relations fold ignores the class (a command can name files
1224-
it never touches and touch files it never names) and it never counts
1225-
as an execution.
1221+
`access: "shell"`, and drops the rest. A shell frame is a HEURISTIC sighting (a command can name files it never touches and touch files it never names), admitted as evidence anyway by user decision 2026-08-30: it lights the map, lands in recordings, counts toward the node's execution stats (§Execution stats, the shell bullet) and folds as a `reads` relation (§Session journal, Consumption), leaning on the analyzer gates (repetition + points coverage) to absorb the noise.
12261222

12271223
The active level is a SERVER-side filter at the ingest seam, applied to
12281224
resolved frames BEFORE stats, run history, conversation capture, the

‎src/kernel/session-journal/__tests__/session-journal.spec.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,35 @@ describe('foldObservedActivity relations', () => {
160160
assert.equal(invoke.relation, 'invokes');
161161
});
162162

163-
it('a shell sighting never becomes an observed relation (heuristic, not evidence)', () => {
163+
it('a shell sighting folds as a read of the sighted file (heuristic, admitted 2026-08-30)', () => {
164164
const rec = recording({
165165
frames: [
166166
{
167167
tMs: 1,
168168
type: 'node.activity',
169169
data: { nodePath: SKILL, phase: 'start', owner: 'main:s1' },
170170
},
171-
// Rung-5 frame: renders in replays, but the fold treats it as
172-
// a sighting, not a design-evidence access.
171+
// Rung-5 frame: the command named the file, so the unit that ran
172+
// the command is observed reading it. The sighted path never
173+
// becomes the owner's current unit, like a plain read.
173174
{
174175
tMs: 2,
175176
type: 'node.activity',
176177
data: { nodePath: 'README.md', phase: 'start', owner: 'main:s1', access: 'shell' },
177178
},
179+
{
180+
tMs: 3,
181+
type: 'node.activity',
182+
data: { nodePath: MCP, phase: 'start', owner: 'main:s1', access: 'mcp' },
183+
},
178184
],
179185
});
180-
assert.equal(foldRelations([rec]).size, 0);
186+
const folded = foldRelations([rec]);
187+
assert.equal(folded.size, 2);
188+
const sighted = folded.get(`${SKILL}\x00README.md`)!;
189+
assert.equal(sighted.relation, 'reads');
190+
assert.equal(sighted.count, 1);
191+
assert.equal(folded.get(`${SKILL}\x00${MCP}`)?.relation, 'invokes');
181192
});
182193

183194
it('a turnEnd cuts the unit attribution: later-turn accesses never blame an earlier unit', () => {

‎src/kernel/session-journal/index.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
* uses (2026-08-17, lifting the original reads deferral: the noise
3333
* lives in the ANALYZER gates, repetition + points coverage, not in
3434
* the fold). The read path never becomes the owner's current unit.
35+
* Since 2026-08-30 an `access: 'shell'` sighting folds as `reads` too
36+
* (user decision: the command named the file, heuristic but admitted
37+
* as evidence; the analyzer gates absorb the noise). `write` frames
38+
* stay unfolded until they earn a relation of their own.
3539
*
3640
* The unit correlation is TURN-BOUNDED (user call 2026-08-17): a
3741
* `turnEnd` frame clears its owner's current-unit claim, so an access in
@@ -312,8 +316,10 @@ function foldUnitStart(
312316

313317
/**
314318
* One resource-access frame: the owner's current unit (when known)
315-
* touched the accessed path. `mcp` folds as `invokes`, `read` as
316-
* `reads`; any future access class is ignored until it earns a fold.
319+
* touched the accessed path. `mcp` folds as `invokes`, `read` and
320+
* `shell` as `reads` (a shell sighting is a heuristic read, admitted
321+
* 2026-08-30); `write` and any future class are ignored until they
322+
* earn a fold.
317323
*/
318324
function foldAccessFrame(
319325
relations: Map<string, IFoldEntry>,
@@ -323,7 +329,8 @@ function foldAccessFrame(
323329
access: unknown,
324330
tMs: number,
325331
): void {
326-
const relation = access === 'mcp' ? 'invokes' : access === 'read' ? 'reads' : null;
332+
const relation =
333+
access === 'mcp' ? 'invokes' : access === 'read' || access === 'shell' ? 'reads' : null;
327334
if (relation === null) return;
328335
const caller = state.lastUnitByOwner.get(owner);
329336
if (caller !== undefined && caller !== accessedPath) {

‎src/server/__tests__/activity-stats-store.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ describe('activity-stats-store', () => {
5454
after.nodeDetail(NODE).recent.map((e) => e.detail),
5555
['Bash', 'Skill'],
5656
);
57-
// The sighted-only node survives too: count 0, log intact.
58-
assert.equal(after.nodeDetail('docs/notes.md').stats.count, 0);
57+
// The sighted node survives too: its counted sighting and the typed log.
58+
assert.equal(after.nodeDetail('docs/notes.md').stats.count, 1);
5959
assert.equal(after.nodeDetail('docs/notes.md').recent[0]?.kind, 'shell');
6060
assert.equal(after.pairSnapshot()[pairKeyOf(NODE, CHILD)]?.count, 1);
6161
assert.equal(after.sinceMs, before.sinceMs);

‎src/server/__tests__/activity-stats.spec.ts‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('ActivityStatsService.record', () => {
116116
assert.equal(stats.nodeDetail('mcp://notion').recent[0]?.caller, undefined);
117117
});
118118

119-
it('a shell SIGHTING never counts as an execution (spec §Capture level rung 5)', () => {
119+
it('a shell sighting counts as an execution and stays typed in the log (spec §Execution stats, 2026-08-30)', () => {
120120
const stats = new ActivityStatsService();
121121
const skill = '.claude/skills/demo/SKILL.md';
122122
const file = 'docs/notes.md';
@@ -128,16 +128,14 @@ describe('ActivityStatsService.record', () => {
128128
detail: 'Bash',
129129
access: 'shell',
130130
});
131-
// The frame rides WITH the node's unchanged stats (count stays 0),
132-
// so a client learns the node has a log to show...
133-
assert.equal(enriched?.count, 0);
134-
assert.equal(enriched?.lastStartAt, 0);
135-
// ...and no execution stat mutates: count, lastStartAt, owners all zero.
131+
// The frame rides WITH the node's updated stats, like every counted start.
132+
assert.equal(enriched?.count, 1);
133+
assert.ok((enriched?.lastStartAt ?? 0) > 0);
136134
const detail = stats.nodeDetail(file);
137-
assert.equal(detail.stats.count, 0);
138-
assert.equal(detail.stats.lastStartAt, 0);
139-
assert.equal(detail.stats.distinctOwners, 0);
140-
// The typed recent log still carries the sighting on BOTH ends.
135+
assert.equal(detail.stats.count, 1);
136+
assert.equal(detail.stats.lastOwner, 'main:s1');
137+
assert.equal(detail.stats.distinctOwners, 1);
138+
// The typed recent log carries the sighting on BOTH ends, still tagged shell.
141139
assert.equal(detail.recent[0]?.kind, 'shell');
142140
assert.equal(detail.recent[0]?.detail, 'Bash');
143141
assert.equal(detail.recent[0]?.caller, skill);

‎src/server/activity-stats.ts‎

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
* - `keepAlive` starts NEVER count and never touch the owner sets:
1717
* custody is not an execution.
1818
* - `sticky` starts count ONCE per `(nodePath, owner)` pair.
19-
* - `access: 'shell'` starts NEVER count: a heuristic path sighting
20-
* parsed out of a shell command is not an execution (spec §Capture
21-
* level rung 5, "a SIGHTING, not evidence"). The sighting still
22-
* lands in the typed recent log (both ends, `kind: 'shell'`) so
23-
* the inspector can show who named the file, and the frame rides
24-
* WITH the node's unchanged (count 0) stats so a client learns the
25-
* node has a log to show.
19+
* - `access: 'shell'` starts COUNT like any other resource access
20+
* (user decision 2026-08-30, reversing the 2026-08-18 no-count
21+
* rule: the card's execution pill is the map's only per-node
22+
* counter, and a sighted-only node was invisible there). The entry
23+
* stays tagged `kind: 'shell'` in the typed recent log (both ends)
24+
* so the inspector tells a sighting apart from a read; the
25+
* session-journal fold admits it as a `reads` relation too.
2626
* - Everything else (skill invocations, command expansions, markdown
27-
* reads) counts on every signal.
27+
* reads and writes) counts on every signal.
2828
*
2929
* Every bound below saturates or evicts oldest entries; hitting a cap
3030
* never errors and never blocks ingestion.
@@ -327,9 +327,6 @@ export class ActivityStatsService {
327327
record(data: INodeActivityEventData): INodeActivityStats | null {
328328
if (data.nodePath === undefined || data.phase !== 'start') return null;
329329
if (data.keepAlive === true) return null;
330-
if (data.access === 'shell') {
331-
return this.sight(data.nodePath, data.owner, data.detail, data.access);
332-
}
333330
if (data.sticky === true && data.owner !== undefined) {
334331
if (!this.claimStickyOnce(data.nodePath, data.owner)) return null;
335332
}
@@ -473,34 +470,16 @@ export class ActivityStatsService {
473470
}
474471

475472
/**
476-
* A shell SIGHTING: lands in the typed recent log on both ends (the
477-
* sighted node's entry plus the caller's mirrored one) but mutates
478-
* NO execution stat, `count` / `lastStartAt` / `lastOwner` / owner
479-
* set stay untouched (spec §Execution stats). Returns the node's
480-
* UNCHANGED stats so the WS frame carries them and a client learns
481-
* the node has a log to show (a count of 0 next to a non-empty
482-
* recent log reads as sighted-only); custody `keepAlive` starts keep
483-
* riding bare, they log nothing.
473+
* Count one start: every node-attributed start that survived the
474+
* gates above, a unit's own execution or a resource access (mcp /
475+
* read / write / shell alike, spec §Execution stats). The typed
476+
* recent entry lands on both ends of a resource access.
484477
*/
485-
private sight(
486-
nodePath: string,
487-
owner: string | undefined,
488-
detail: string | undefined,
489-
access: 'shell',
490-
): INodeActivityStats {
491-
const at = Date.now();
492-
const caller = this.correlateCaller(nodePath, owner, access);
493-
const state = this.stateFor(nodePath);
494-
this.pushRecent(state, buildRecentEntry({ at, owner, detail, caller, kind: access }));
495-
this.trackAccess(nodePath, owner, detail, access, caller, at);
496-
return projectStats(state);
497-
}
498-
499478
private count(
500479
nodePath: string,
501480
owner: string | undefined,
502481
detail: string | undefined,
503-
access: 'mcp' | 'read' | 'write' | undefined,
482+
access: 'mcp' | 'read' | 'write' | 'shell' | undefined,
504483
): INodeActivityStats {
505484
const state = this.stateFor(nodePath);
506485
state.count += 1;

0 commit comments

Comments
 (0)