Repository navigation
feat(harness): agentic coding core (Phase 1) - #102
Merged
Merged
Conversation
Approved design for Claude-Code-style harness support: workspace file tool suite behind a path jail, permission modes + allow/deny/ask rules layered on the existing HITL gate, checkpoints/rewind, model-driven plan tool, env context assembly, ACP-shaped SSE events, and a tracked P2-P4 parity roadmap (hooks, subagents, compaction/memory, sandbox/ACP). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
22 TDD tasks implementing Harness P1 from the approved spec: harness package, Windows-safe path jail, file tool suite (read/edit/write/glob/grep), permission modes + allow/deny/ask rules (+ .claude/settings.json import + registry merge), per-turn checkpoints/restore, task_plan tool, env-context builder, workspace registry + routes, run_turn integration, and desktop UI (workspace bar, tool timeline, diff/plan cards, rewind). Documents the Windows-local test baseline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Match the plan's jail code to the shipped fix (resolve(strict=False), no lstrip, `from None`) + the new regression test, after code review found two POSIX escapes in the first draft. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Match the plan's glob() to the shipped fix (try/except on Path.glob + resolve-then-relative_to jail per hit) + 3 escape tests, after spec review found ../ pattern traversal and an absolute-pattern crash. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…low-up Consolidated note of the glob/grep/edit/read fixes from two-stage review (commits 2e27af8, fc134cb) and the deferred walk-then-filter scalability fast-follow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…eaker requirement Note the acceptEdits git push/reset auto-approval fix (a557ac8) and add a REQUIRED safety note to Task 14: a gate `allow` for bash must still hit the catastrophic-command circuit breaker (bash args are not jailed). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…layout Record the reliability fixes (5409c8e) and fix the checkpoint path so the store root is turn-agnostic (checkpoints/<turn_id>/manifest.json), removing the double-nesting both implementers flagged for Task 14/17. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…sk 14b breaker Env context appends to extra_sections (not a system var); tools/gate/events anchored to verified agent.py locations; events via _completion_events + drain loop; ws context dict threaded to _run_one_tool. Split the catastrophic-bash circuit breaker into Task 14b (no existing breaker to reuse). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
run_turn gains workspace_root/workspace_rules: when set, the five file tools + task_plan are registered, an env-context section is appended to the system prompt, and a merged permission ruleset (workspace_rules + .claude/settings.json) is built into a per-turn `ws` context threaded through _run_one_tool (dispatch + per-edit checkpoint snapshot) and the tool-call loop's gate. The harness rule gate runs BEFORE the existing HITL gate, guarded by `if workspace_root:` so non-workspace turns are byte-for-byte unchanged: deny -> tool_error + blocked_outcome (skip_breaker) + continue; allow -> calls.append + continue (skips the HITL prompt); ask -> falls through to the existing permissions.requires_approval check untouched. _completion_events gains tool_call/file_diff/plan_update for the six harness tool names; a checkpoint event fires after a successful edit_file/write_file. Checkpoints live under config.REPO_ROOT/checkpoints (gitignored, same pattern as projects/ and knowledge/). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s HITL skip) + checkpoint id
Code review (empirically verified) found the Task 14 gate insertion had
no tool-name filter: `if workspace_root:` applied rules.gate() to EVERY
tool call, not just the 5 file tools + task_plan. rules.gate's mode
defaults are calibrated for that set only:
- CRITICAL: in "bypass" mode, gate() returns "allow" unconditionally for
ANY tool name, so a workspace turn in bypass mode skipped the existing
HITL prompt for sensitive built-ins (code_execution, authenticate,
memory mutations). Reproduced concretely: code_execution ran for real
via the docker engine with zero approval. Task 15 exposes "bypass"
publicly, so this had to land first.
- Also: "plan" mode hard-denied safe non-file tools like web_search
instead of falling through to the existing (already-correct) fails-
closed HITL handling for unrecognized modes.
Fix: scope the gate to `_wfs.FILE_TOOL_NAMES | {"task_plan", "bash"}` —
the set rules.py's mode/rule engine actually governs. Every other tool
name now falls straight through to the existing HITL gate, unchanged.
Also fixes the checkpoint event emitting the raw `turn_id` instead of
`ws["ckpt_turn"]` (turn_id or "adhoc") — they can diverge when turn_id
is falsy, which would point the Task 17 restore route at a checkpoint
id that was never written.
Two new regression tests in test_agent_workspace.py exercise both bugs
end-to-end through run_turn (code_exec=True / web_search=True are
required on the run_turn() calls — without them the H6 "tool not
enabled" check intercepts the call before it ever reaches the gate
under test, which was verified empirically while writing these).
Plan doc: recorded the Task 14b/Task 15 ordering dependency this fix
creates (Task 15 must not land before this + the bash circuit breaker).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ontract, bypass semantics) /harness/workspaces prefix (tenancy owns /workspaces); case-insensitive canonical permission modes with un-aliased legacy literals; deliberate safety-positive bypass semantics (built-ins still prompt) to be recorded in the spec at Task 22. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…force protected paths (route review)
…ly restore, detach banner) Match the desktop plan to the shipped route fixes (8aaa79c): restoreCheckpoint uses /harness/workspaces, RewindMenu offers file restore only (conversation deferred), and render the workspace_detached banner. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds the five harness SSE events (tool_call, file_diff, plan_update, checkpoint, workspace_detached) as members of the existing AgentEvent discriminated union (events.ts), and WorkspaceBar: folder name + permission-mode selector + detach, for the composer.
ToolTimeline (condensed harness tool-call list), FileDiffCard (unified diff with add/del/context line styling), and PlanCard (task_plan's current plan, latest plan_update wins) -- the three harness activity renderers, independently unit-tested.
Wire WorkspaceBar into the composer, render tool timeline / file diffs / plan card / rewind from a message''s accumulated harness events, add the workspace_detached banner, and the restoreCheckpoint client method (/harness/workspaces prefix, file restore only). Full desktop gate green (typecheck + 365 tests + build). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ewind workspace (review)
Four transcript reducers rebuilt assistant messages as narrow {role,blocks}
literals, silently dropping toolCalls/fileDiffs/planItems/checkpointTurnId (the
RewindMenu/diffs vanished after an artifact/approval/question on the same
message) — now spread ...m. Each assistant message records its workspaceId so
rewind restores the folder the message was produced under, not a stale closure.
Plus ToolTimeline/PlanCard sr-only status for a11y and a stale Composer comment.
Desktop gate green (typecheck + 379 tests + build).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…uilt deltas README gains a "Harness (code workspaces)" section; the spec marks P1 shipped and records the review-hardened as-built deltas (safety-scoped bypass, catastrophic-bash breaker, enforced protected paths, /harness routes, workspace-bound checkpoints, file-only rewind) and the deliberate deferrals (workspace-cwd bash, FIFO pruning). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 22, 2026
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.
Harness v1 — agentic coding core (Phase 1)
Attach a chat to a local folder and the agent becomes a Claude-Code-style coding agent scoped to that folder, layered on the existing multi-provider
run_turnloop (no rewrite, no new provider dependency). This is Phase 1 of the design indocs/superpowers/specs/2026-07-20-harness-design.md; the roadmap (P2–P4: hooks, subagents, memory hierarchy, sandbox/ACP) is tracked there.What's in it
Backend — new
backend/ocd_core/harness/package + additive wiring intorun_turn:workspace_fs.resolve_in_workspace) — symlink/junction-safe, defeats..-traversal, sibling-prefix roots (C:\wsvsC:\ws2), and absolute-path escapes on both Windows and POSIX.read_file(numbered, offset/limit),edit_file(unique-old_stringguard + read-before-edit + unified diff),write_file(read-before-overwrite),glob,grep(jailed, bounded).rules.py) — modesdefault/acceptEdits/plan/strict/bypass(+ legacyauto/askaliases) andallow/deny/askrules (bash(git *), precedence deny > ask > allow > mode). Reads a workspace's.claude/settings.jsonpermissions. Mode-independent catastrophic-bash breaker (rm -rf /, fork bombs,mkfs, disk-device writes)./harness/workspacesroutes (CRUD, rules, checkpoint list/restore).Desktop —
AgentEventunion extensions +WorkspaceBar,ToolTimeline,FileDiffCard,PlanCard,RewindMenu, therestoreCheckpointclient, and chat wiring (each message stamped with its workspace so rewind targets the right folder;workspace_detachedbanner).Safety posture (integration with existing gates)
task_plan+bash); pre-existing sensitive built-ins (code_execution,authenticate, memory mutations) keep their existing HITL prompt.bypassauto-runs the coding tools (minus the breaker) but a sensitive built-in still prompts — only legacyautoturns the gate fully off. (A deliberate, safety-positive deviation from the spec's "bypass = auto", recorded in spec §14.).env,*.pem,id_*) stay write-gated even inacceptEdits.workspace_iddegrades to a normal folderless chat and emits aworkspace_detachedevent +workspace_attach_failedaudit — the model never silently over-claims folder access.workspace_root/ws).Honest scope note
bashstill runs in the existing read-only sandbox (SANDBOX_ROOT), not the attached folder — running commands/tests in the workspace is a deliberate fast-follow (needs a jailed workspace cwd + a broader gated allowlist, adjacent to the P4 container runner). The file tools cover the core edit/search loop. Other deferrals (in spec §14): checkpoint FIFO pruning,glob/grepwalk-then-filter perf on large.git/node_modules.Testing
ruffclean (CI-pinned 0.15.22).Process
Built subagent-driven with two-stage (spec + code-quality) review per task. Reviews caught and fixed, before merge: three jail escapes, a silent
grep countbug, anacceptEditsauto-git push, a Criticalbypass-mode HITL skip for sensitive built-ins, a Critical cross-workspace checkpoint overwrite, an unenforced protected-paths gap, and a desktop transcript regression that dropped the rewind UI. Plan + as-built notes:docs/superpowers/plans/2026-07-20-harness-phase1.md.🤖 Generated with Claude Code