Skip to content

PR #69 followups: lifecycle tests, stop-hook env var, doc cleanup#97

Merged
lukstafi merged 4 commits intomainfrom
ludics/task-41f81ece-s6/root
Mar 28, 2026
Merged

PR #69 followups: lifecycle tests, stop-hook env var, doc cleanup#97
lukstafi merged 4 commits intomainfrom
ludics/task-41f81ece-s6/root

Conversation

@lukstafi
Copy link
Copy Markdown
Owner

Summary

  • Lifecycle unit tests: Export refreshAgentStatuses() and add 20 new tests covering updateTurnLifecycle() edge cases, refreshAgentStatuses() integration (null snapshots, stop-hook fast-complete, inconsistency detection), and orchOnStop() env-var fallback
  • Stop-hook env var routing: Update orchOnStop() to fall back to LUDICS_PEER_SYNC_DIR env var when CLI arg is missing/stale; deprecate legacy directory-walk in shell hook with stderr warning
  • Doc cleanup: Rewrite stale isTurnFresh()/phaseDispatchedAt reference to past tense in phase-transitions doc

Test plan

  • All 68 runner tests pass (was 48, +20 new)
  • All 273 tests pass across 18 files
  • bun run typecheck clean
  • Shell hook guard only execs into orch on-stop when peer_sync_dir is validated (no stale env var regression)

🤖 Generated with Claude Code

lukstafi and others added 4 commits March 28, 2026 16:55
Proposal for task-010fa0f1 covering extraction of TASK_ID_RE,
resolveTaskFile helper, reuse of updateFrontmatterField, and
unification of duplicated priorityValue() across dashboard.ts
and flow.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers two features: clickable retrospective links for done tasks, and
a time-based filter (All/30d/7d/24h) using task file mtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…, deprecated fields

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Export refreshAgentStatuses() for direct testing
- Add 20 new tests: updateTurnLifecycle edge cases (5), refreshAgentStatuses
  integration tests (10), orchOnStop env-var fallback tests (5)
- Update orchOnStop() to fall back to LUDICS_PEER_SYNC_DIR env var when CLI
  arg is missing or stale
- Deprecate legacy directory-walk in stop hook shell script with stderr warning
- Rewrite stale isTurnFresh()/phaseDispatchedAt doc reference to past tense

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lukstafi lukstafi force-pushed the ludics/task-41f81ece-s6/root branch from aa8be34 to c3263b3 Compare March 28, 2026 15:55
@lukstafi lukstafi merged commit 62d8b1f into main Mar 28, 2026
@lukstafi
Copy link
Copy Markdown
Owner Author

Coder Refactor Notes — PR #97

1. Consolidate peer-sync resolution into a single function

orchOnStop() now has a 4-step peer-sync dir resolution chain (CLI arg → env var → phase file check → give up), and the shell hook has a parallel 3-step chain (env var → marker file → directory walk). These two resolution chains are coupled but not shared — if one changes, the other can drift.

Suggestion: Extract a resolvePeerSyncDir(cliArg?: string): string | null helper that encapsulates the full resolution logic (CLI arg → env var → marker file walk). Both the TypeScript handler and shell script can call this single source of truth. The shell script would invoke ludics orch resolve-peer-sync "$cwd" and branch on the exit code, eliminating the duplicated discovery logic.

2. Redundant phase file read in orchOnStop()

After the env-var fallback resolves peerSyncDir, the code reads the phase file twice:

  • Line 112: readFileIfExists(join(peerSyncDir, "phase")) — to validate the resolved dir
  • Line 122: readFileIfExists(join(peerSyncDir, "phase")) — to get the phase value for the stop record

These could be collapsed: store the phase value from the validation check and skip the second read.

3. Remove the deprecated directory-walk path entirely

The directory walk (shell script path 3) is now deprecated with a stderr warning. It's still a ~10-line code path that only fires in edge cases. A follow-up task should remove it outright after one release cycle, since the env var and marker file cover all orchestration scenarios. Track this with a TODO or a follow-up task.

4. orchOnStop docstring is now stale

The docstring says "The shell hook passes an empty-string placeholder for the CLI arg when it couldn't resolve the dir, so the env var kicks in." This was true in the v1 implementation but was reverted in round 2 — the shell now only calls orch on-stop when it has a validated peer_sync_dir. The docstring should be updated to reflect that the env-var fallback is for direct CLI invocations only.

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.

1 participant