Detect entity activity and human-gated sessions - #76
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the prior “confidence/liveness”-based session attribution with a strict, fail-closed entity activity model derived from structured Codex + Claude Code session artifacts, then surfaces that activity in the TUI (list markers + preview metadata) and documents the new contract.
Changes:
- Introduces a typed
EntityActivitydomain model (idle,running · worker/FO,human-gate) and updates indexing/UI rendering to consume it. - Reworks
spacetop-coresession scanning to stream/project JSON/JSONL records with per-file byte cursors + checkpoints, and reduces structured events into current activity. - Adds fixtures + tests for Codex/Claude structured schemas (including Codex code-mode exec parsing and cache cursor reuse) and updates specs/README/AGENTS to match the new behavior.
Reviewed changes
Copilot reviewed 35 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/fixtures/session-activity/codex-worker-unlinked/rollout.jsonl | New Codex fixture: child-shaped worker without parent thread linkage (fail-closed). |
| tests/fixtures/session-activity/codex-worker-open/rollout.jsonl | New Codex fixture: worker open state with canonical spawn + assignment + start. |
| tests/fixtures/session-activity/codex-worker-complete/rollout.jsonl | New Codex fixture: worker completion closes activity. |
| tests/fixtures/session-activity/codex-fo-gate/rollout.jsonl | New Codex fixture: FO-scoped gate via request_user_input. |
| tests/fixtures/session-activity/codex-fo-exec/rollout.jsonl | New Codex fixture: FO exec scope via code-mode nested tools.exec_command. |
| tests/fixtures/session-activity/codex-fo-exec-text-only/rollout.jsonl | New Codex fixture: non-executable text(path) mention should fail closed. |
| tests/fixtures/session-activity/codex-fo-exec-nested/rollout.jsonl | New Codex fixture: nested JSON wrapper around exec module input. |
| tests/fixtures/session-activity/claude-worker-open/parent.jsonl | New Claude fixture: parent session dispatching a subagent. |
| tests/fixtures/session-activity/claude-worker-open/claude-fo-redacted/subagents/worker.meta.json | New Claude fixture: teammate meta correlation for a worker. |
| tests/fixtures/session-activity/claude-worker-open/claude-fo-redacted/subagents/worker.jsonl | New Claude fixture: sidechain acceptance record. |
| tests/fixtures/session-activity/claude-worker-idle/parent.jsonl | New Claude fixture: idle notification closes worker. |
| tests/fixtures/session-activity/claude-worker-idle/claude-fo-redacted/subagents/worker.meta.json | New Claude fixture: meta includes explicit parent session + tool-use correlation. |
| tests/fixtures/session-activity/claude-worker-idle/claude-fo-redacted/subagents/worker.jsonl | New Claude fixture: sidechain acceptance record (idle case). |
| tests/fixtures/session-activity/claude-two-parent-same-name/parent-b/subagents/worker.meta.json | New Claude fixture: duplicate worker names across parent sessions (B). |
| tests/fixtures/session-activity/claude-two-parent-same-name/parent-b/subagents/worker.jsonl | New Claude fixture: sidechain worker content for parent B. |
| tests/fixtures/session-activity/claude-two-parent-same-name/parent-b.jsonl | New Claude fixture: second parent session dispatch + idle notification. |
| tests/fixtures/session-activity/claude-two-parent-same-name/parent-a/subagents/worker.meta.json | New Claude fixture: duplicate worker names across parent sessions (A). |
| tests/fixtures/session-activity/claude-two-parent-same-name/parent-a/subagents/worker.jsonl | New Claude fixture: sidechain worker content for parent A. |
| tests/fixtures/session-activity/claude-two-parent-same-name/parent-a.jsonl | New Claude fixture: parent A dispatch. |
| tests/fixtures/session-activity/claude-fo-gate/session.jsonl | New Claude fixture: FO gate via AskUserQuestion. |
| tests/fixtures/session-activity/claude-fo-complete/session.jsonl | New Claude fixture: FO end-turn closes scoped activity. |
| README.md | Updates user-facing description to the 3-state activity contract and fail-closed evidence rules. |
| docs/superpowers/specs/2026-07-27-spacetop-entity-activity-design.md | Adds implemented design spec for entity activity detection + privacy/caching contract. |
| docs/superpowers/specs/2026-06-11-spacetop-agent-session-detection-design.md | Marks prior proposal spec as superseded. |
| crates/spacetop/src/ui/tests/task_list.rs | Updates task list tests for new markers/status text (running handler + human-gate diamond). |
| crates/spacetop/src/ui/tests/preview.rs | Updates preview tests to assert Runtime/Session/Status/Updated output and no transcript leakage. |
| crates/spacetop/src/ui/tests.rs | Refactors test helpers from AgentSessionState to EntityActivity attribution. |
| crates/spacetop/src/ui/preview.rs | Renders new activity metadata lines (Runtime/Session/Status/Updated) via EntityActivity. |
| crates/spacetop/src/ui/list.rs | Updates list rendering to use EntityActivity for markers and optional status labels. |
| crates/spacetop/src/app/tests.rs | Updates app tests to the new EntityActivityAttribution report shape and preserved snapshot behavior on scan failure. |
| crates/spacetop/src/app/overview.rs | Preserves last successful activity snapshot on scan errors; clears activities only on workflow reload. |
| crates/spacetop-core/src/session_activity.rs | Major rewrite: structured JSON/JSONL projection + incremental cursor/checkpoint scanning + event reduction into EntityActivity. |
| crates/spacetop-core/src/index.rs | Replaces session attribution storage with entity_activities and updates query helpers. |
| crates/spacetop-core/src/domain/mod.rs | Introduces AgentRuntime, ActivityHandler, and EntityActivity (+ attribution/report changes). |
| crates/spacetop-core/Cargo.toml | Adds serde_json dependency to support structured record parsing/projection. |
| Cargo.lock | Locks serde_json dependency. |
| AGENTS.md | Updates repo contract to describe the new structured activity detection and cursor-based JSONL scanning rules. |
Comment on lines
+313
to
+319
| parsed_by_runtime | ||
| .entry(runtime) | ||
| .or_default() | ||
| .push(ParsedFile { | ||
| path: entry.path().to_path_buf(), | ||
| records: snapshot.records.clone(), | ||
| }); |
Comment on lines
+476
to
+480
| let terminated = line.last() == Some(&b'\n'); | ||
| if line.iter().all(u8::is_ascii_whitespace) { | ||
| cursor += read as u64; | ||
| continue; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Give Spacetop a reliable three-state activity signal so users can see whether workers, first officers, or humans currently own each task.
What changed
Evidence
make lintpassed.Review guidance
Focus on live Codex object-literal exec parsing and equal-length cache rewrites.
069