Research spok lazy load - #17
Conversation
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.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
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
| const staleSkill = `${tempSkill}.stale`; | ||
| let displacedStaleSkill = false; | ||
| try { | ||
| await fs.promises.rename(destSkill, staleSkill); |
There was a problem hiding this comment.
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>
| } | ||
| throw error; | ||
| } finally { | ||
| if (fs.existsSync(projectMarker)) { |
There was a problem hiding this comment.
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>
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 withcapability_unavailablewithout advancing state. Previouslyspok-applypreflighted both harness closures; now it checks only the active harness’sspok-flowentry skill and defers capability checks to the flow engine.ensureVendoredSkillwith statusespresent|materialized|unavailable, using temp-then-rename, handling concurrent runs, and falling back to~/<toolSkillsDir>when the distribution lacks the skill.flow.tsemitscapability_materialized, persistsmaterializedCapabilityPaths, and injects exact flow-generated capability directories into the commit prompt to exclude only those paths.spok-applypreflights only the active harness’sspok-flowmarker and instructsspok init(orspok skills install --tools <tool>).GIT_*hook env to prevent misdirectedgitoperations.Written for commit b8b1325. Summary will update on new commits.