Skip to content

refactor: Phase 3 — split workspace.ts and plugin.ts by responsibility - #91

Merged
vriesd merged 3 commits into
mainfrom
refactor/phase-3-splits
Sep 18, 2026
Merged

vriesd merged 3 commits into
mainfrom
refactor/phase-3-splits

Conversation

@vriesd

@vriesd vriesd commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 3 of the runtime refactor plan (.agents/plans/13-runtime-refactor/README.md). Stacked on #90; retarget once that merges.

Two file splits plus one follow-up from the final review:

  • infrastructure/fs/workspace.ts split into workspace-paths.ts (root validation and .flow layout), managed-fs.ts (managed filesystem primitives), session-lock.ts (cross-process lock), and a 299-line workspace.ts keeping only the session file protocol. Every function body moved verbatim; every importer repointed, including two the plan's file list missed (source-identity.ts and the persistence test's child-process import URL). workspace.ts re-exports nothing except ArchiveCollisionError. The new files form a strict DAG with no backward edges.
  • platform/opencode/plugin.ts split into command-hook.ts, tool-guard.ts, and a wiring-only plugin.ts. Three deliberate changes, all named in the plan: the plugin resolves its workspace through resolveWorkspaceRoot at load (validation moves from the first tool call to plugin load; no valid workspace is affected, and the leadership registry key is unchanged because it already realpathed); one FlowService per plugin instance for the command hook and auto-drive status reads instead of one per call (the whole factory chain is stateless, so this is equivalent); the two session.deleted checks in the event hook merged into one branch. The per-call resolution inside tools.ts is deliberately kept: tools must resolve from their own ToolContext.
  • Follow-up commit: the load-time refusal is now logged through the host before rethrowing, with a test that loads the plugin from the home directory and asserts both the rejection and the log line. docs/development.md names the new modules; the docs byte cap forced a prose trim in the same file.

No prompt text, guidance, Zod schema, tool name, tool response field, Session v5 shape, or error message changes.

Test plan

  • bun run check at ab97a60: 1231 pass, 1 skip, 0 fail
  • bun run smoke:live against a reachable OpenCode host: 22 pass. Note: the smoke used a valid workspace, so it does not exercise the new load-time refusal path; the unit test above does.
  • Task-scoped review of each commit, both diffed block by block against the pre-split files, approved
  • Whole-branch review: ready with fixes; the one Important finding (unlogged load-time throw) is fixed and re-reviewed

Deferred follow-ups (not blocking)

  • The docs byte trim softened three qualifiers in docs/development.md ("must" in Documentation, "immediately" in Release, "intentionally" in Change discipline). Phase 4 edits the same section and restores them.
  • workspace-validation.ts carries its own lstat/open/realpath primitives that overlap managed-fs.ts; consolidating is a natural later step.
  • guardTools keeps positional parameters while createCommandHook takes an options object; justified by what each needs, revisit only if a parameter is added.

🤖 Generated with Claude Code

vriesdcrv and others added 3 commits September 18, 2026 08:44
…aged fs, lock, and session file

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nd wiring

One FlowService per plugin instance, one workspace resolution path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…he split modules

The load-time workspace validation now records why Flow cannot start before
rethrowing, and the developer guide names the new infrastructure and platform
modules.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-18T07:26:21.317372Z ab97a60 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@vriesd
vriesd changed the base branch from refactor/phase-2-application to main September 18, 2026 08:27
@vriesd
vriesd merged commit f6a8c46 into main Sep 18, 2026
7 checks passed
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