Skip to content

Research spok lazy load - #17

Open
0xjgv wants to merge 4 commits into
mainfrom
research-spok-lazy-load
Open

Research spok lazy load#17
0xjgv wants to merge 4 commits into
mainfrom
research-spok-lazy-load

Conversation

@0xjgv

@0xjgv 0xjgv commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Summary by cubic

Resolves step capabilities lazily in spok flow next, ensuring only the active step’s skill for its runner and materializing it into the project when missing; unavailable skills block with capability_unavailable without advancing state. Previously spok-apply preflighted both harness closures; now it checks only the active harness’s spok-flow entry skill and defers capability checks to the flow engine.

  • Adds ensureVendoredSkill with statuses present | materialized | unavailable, using temp-then-rename, handling concurrent runs, and falling back to ~/<toolSkillsDir> when the distribution lacks the skill.
  • flow.ts emits capability_materialized, persists materializedCapabilityPaths, and injects exact flow-generated capability directories into the commit prompt to exclude only those paths.
  • Capability resolution is skipped outside a Spok project; hybrid runs materialize Codex skills into the Codex skills dir.
  • spok-apply preflights only the active harness’s spok-flow marker and instructs spok init (or spok skills install --tools <tool>).
  • Harness child processes no longer inherit GIT_* hook env to prevent misdirected git operations.

Written for commit b8b1325. Summary will update on new commits.

Review in cubic

Flow Test and others added 3 commits August 22, 2026 15:43
Git exports GIT_DIR/GIT_INDEX_FILE into hook processes; from a linked
worktree that redirected every nested git the tests spawn into this repo,
so its pre-commit hook ran inside temp repos and failed with
'Module not found harness.ts'.
Ensure only the active step's skill for that step's runner before
dispatch, materializing it from the Spok distribution into the
worktree-local skills dir when missing (copy-if-missing, temp-then-rename).
Unavailable capabilities block with code capability_unavailable and leave
workflow state untouched; a materialization emits capability_materialized
to flow-events.jsonl.

Drop the hybrid dual-harness skill preflight from the spok-apply template:
only the active harness's spok-flow entry marker is checked, everything
else is owned by the flow engine.
The failed pre-commit run in a24ba1e executed the tests under git's
hook-exported GIT_DIR; their fixture-repo 'git add' calls staged README.md
('# Test') and a.txt into this repo's index, and the next commit swept
them in. aae94db stops the leak; this restores the real README and
removes a.txt.

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9710b069b0

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/workflow/flow.ts
Comment thread src/core/skill-vendor.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/core/templates/workflows/apply.ts
Comment thread src/core/skill-vendor.ts Outdated
Comment thread harness.ts
Comment thread src/core/skill-vendor.ts Outdated

@greptile-apps greptile-apps Bot 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/core/skill-vendor.ts">

<violation number="1" location="src/core/skill-vendor.ts:100">
P2: On Windows, when an existing destination is held open, this rename can fail with `EPERM`; the catch leaves `destSkill` in place, so the second rename also fails and lazy resolution reports `unavailable`. Handle `EPERM`/`EXDEV` with the copy/remove fallback used by `archive.ts`, or retry the replacement before returning unavailable.</violation>

<violation number="2" location="src/core/skill-vendor.ts:116">
P3: In the failed-retry path of `publishCopiedSkill`, the `finally` only removes `staleSkill` when `projectMarker` exists. When the final `rename(tempSkill, destSkill)` throws with no marker present, the restore `rename(staleSkill, destSkill)` has its error swallowed, so a displaced project skill directory can be left at `<temp>.stale` on disk with no cleanup and `destSkill` left missing. Key the `finally` cleanup off `displacedStaleSkill` instead of `projectMarker` so the displaced dir is always reclaimed.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/core/skill-vendor.ts
const staleSkill = `${tempSkill}.stale`;
let displacedStaleSkill = false;
try {
await fs.promises.rename(destSkill, staleSkill);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: On Windows, when an existing destination is held open, this rename can fail with EPERM; the catch leaves destSkill in place, so the second rename also fails and lazy resolution reports unavailable. Handle EPERM/EXDEV with the copy/remove fallback used by archive.ts, or retry the replacement before returning unavailable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/core/skill-vendor.ts, line 100:

<comment>On Windows, when an existing destination is held open, this rename can fail with `EPERM`; the catch leaves `destSkill` in place, so the second rename also fails and lazy resolution reports `unavailable`. Handle `EPERM`/`EXDEV` with the copy/remove fallback used by `archive.ts`, or retry the replacement before returning unavailable.</comment>

<file context>
@@ -69,6 +70,55 @@ function skillMarkerPath(root: string, toolSkillsDir: string, skillName: string)
+  const staleSkill = `${tempSkill}.stale`;
+  let displacedStaleSkill = false;
+  try {
+    await fs.promises.rename(destSkill, staleSkill);
+    displacedStaleSkill = true;
+  } catch {
</file context>

Comment thread src/core/skill-vendor.ts
}
throw error;
} finally {
if (fs.existsSync(projectMarker)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: In the failed-retry path of publishCopiedSkill, the finally only removes staleSkill when projectMarker exists. When the final rename(tempSkill, destSkill) throws with no marker present, the restore rename(staleSkill, destSkill) has its error swallowed, so a displaced project skill directory can be left at <temp>.stale on disk with no cleanup and destSkill left missing. Key the finally cleanup off displacedStaleSkill instead of projectMarker so the displaced dir is always reclaimed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/core/skill-vendor.ts, line 116:

<comment>In the failed-retry path of `publishCopiedSkill`, the `finally` only removes `staleSkill` when `projectMarker` exists. When the final `rename(tempSkill, destSkill)` throws with no marker present, the restore `rename(staleSkill, destSkill)` has its error swallowed, so a displaced project skill directory can be left at `<temp>.stale` on disk with no cleanup and `destSkill` left missing. Key the `finally` cleanup off `displacedStaleSkill` instead of `projectMarker` so the displaced dir is always reclaimed.</comment>

<file context>
@@ -69,6 +70,55 @@ function skillMarkerPath(root: string, toolSkillsDir: string, skillName: string)
+    }
+    throw error;
+  } finally {
+    if (fs.existsSync(projectMarker)) {
+      await fs.promises.rm(staleSkill, { recursive: true, force: true }).catch(() => {});
+    }
</file context>

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