Skip to content

POC: stamp Claude Code's item owner once in itemFields - #2570

Closed
cursor[bot] wants to merge 8 commits into
mainfrom
poc/FIX-1701-stamp-owner-once
Closed

cursor[bot] wants to merge 8 commits into
mainfrom
poc/FIX-1701-stamp-owner-once

Conversation

@cursor

@cursor cursor Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What I subtracted. Claude Code was still deciding ownedBy at every emit site: fourteen ...(ownedBy !== undefined ? { ownedBy } : {}) spreads, plus four extra itemScope(ctx).ownedBy reads for the sub-agent box, its close, the error item, and finalize. itemFields / buildBase now stamp itemScope (task and runtime owner). A caller passes an owner only to replace that: a sub-agent id, or the owner the open stored so the close keeps it. Sub-agent boxes, errors, and their closes take the runtime owner with no extra line. Net −17 lines in packages/claude-code/src/sdk/emit.ts. Codex, Cursor, and core are untouched.

What still passes. pnpm --filter @flow-state-dev/claude-code test — 8 files, 271 tests, including the scope characterization and the owned-container agent check. Same contract: sub-agent owner wins inside a sub-agent, everything else carries the runtime owner, an absent owner is omitted.

This PR does not merge. It is a shape sketch for #2569. Fold the subtraction there, then close this unmerged.

Open in Web View Automation 

claude and others added 8 commits October 1, 2026 11:06
…X-1701 S0)

Pins which of taskId and ownedBy each emitted item version carries, by key
presence and value, across the identity matrix (none, task only, owner only,
task and owner, empty-string task), on every item kind and close path of the
Claude Code, Codex and Cursor emitters. Test-only, green on unmodified source,
including Claude Code's current missing top-level and sub-agent-box owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
…iner (FIX-1701 S1)

Claude Code stamped no ownedBy on its top-level items or its sub-agent
container items, so a run inside a container showed its steps outside it,
breaking the documented Container Ownership contract that Codex and Cursor
keep. Every top-level item and sub-agent box now carries the runtime owner;
items inside a sub-agent keep the sub-agent's owner (subAgentOwner ??
runtimeOwner, decided at the call site). Presence is `!== undefined`.

Flips only the characterization's Claude Code top-level and sub-agent-box
owner rows, and adds the owned-container test that drives claudeCodeAgent
through a real sequencer declaring a container (red on main, green now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
…cope (FIX-1701 S2)

itemScope(ctx) returns { taskId?, ownedBy? } off the runtime identity, each
key present only when the identity defines it (!== undefined). Marked
@internal and exported through @flow-state-dev/core/types beside asRuntime;
not re-exported from the package root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
…701 S3)

Removes the private deriveScope reader and its EmitScope type; every former
use spreads itemScope(ctx). Stamped output unchanged (V0 untouched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
…1701 S4)

Removes the private deriveScope reader and its EmitScope type; every former
use spreads itemScope(ctx). Stamped output unchanged (V0 untouched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
…(FIX-1701 S5)

The shared item stamp reads the task id, and the owner precedence reads the
runtime owner, through itemScope(ctx) instead of casting the identity inline.
Pure refactor against S1's behaviour (V0 and V5 untouched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
…ting (FIX-1701 S6)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZDCzhKV2YFRy4LucoHjCx
The runtime owner belongs on the shared item stamp. A passed owner
replaces it for a sub-agent or a close that kept the open's owner.

Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 1, 2026 11:25am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 1, 2026 11:25am UTC
flow-state-dev-ui Ignored Ignored Oct 1, 2026 11:25am UTC

Request Review

@linear-code

linear-code Bot commented Oct 1, 2026

Copy link
Copy Markdown

FIX-1701

@jhoffner

jhoffner commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Closing unmerged: POC shape sketch for #2569, which has merged. Branch left in place.

@jhoffner jhoffner closed this Oct 5, 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.

3 participants