Skip to content

Detect entity activity and human-gated sessions - #76

Merged
kentwelcome merged 3 commits into
mainfrom
spacedock-ensign/detect-entity-activity-state
Jul 27, 2026
Merged

kentwelcome merged 3 commits into
mainfrom
spacedock-ensign/detect-entity-activity-state

Conversation

@kentwelcome

Copy link
Copy Markdown
Contributor

Give Spacetop a reliable three-state activity signal so users can see whether workers, first officers, or humans currently own each task.

What changed

  • Derive typed idle, running, and human-gate activity from structured agent logs.
  • Attribute running work to workers or first officers using exact session evidence.
  • Cache privacy-safe session projections with incremental file cursors.
  • Render Runtime, Session, Status, and Updated with handler-aware labels.

Evidence

  • 20/20 focused session-activity tests passed.
  • 562/562 app/core unit tests passed; integration/doc tests and make lint passed.

Review guidance

Focus on live Codex object-literal exec parsing and equal-length cache rewrites.


069

Copilot AI review requested due to automatic review settings July 27, 2026 15:17
kentwelcome added a commit that referenced this pull request Jul 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EntityActivity domain model (idle, running · worker/FO, human-gate) and updates indexing/UI rendering to consume it.
  • Reworks spacetop-core session 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;
}
@kentwelcome
kentwelcome merged commit 3fa954b into main Jul 27, 2026
2 checks passed
@kentwelcome
kentwelcome deleted the spacedock-ensign/detect-entity-activity-state branch July 27, 2026 15:25
kentwelcome added a commit that referenced this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants