2.9 KiB
2.9 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec |
|---|---|---|---|---|---|---|
| 01-runtime-state-ownership | Enforce runtime-state ownership | completed | 1 | plan.md | ../../specs/executors/requirements/port-collision-safety.md |
Task 01: Enforce Runtime-State Ownership
Add a cross-platform ownership lock before any backend shared-state initialization.
Acceptance
- A second backend that uses the same canonical Kandev home exits with code 1 before persistent backend initialization.
- Separate homes that reference one external SQLite database cannot open that database at the same time.
- The operating system releases ownership after normal process exit or forced process exit. No lock-file removal is necessary.
Verification
Run these commands from the repository root:
cd apps/backend && go test -tags fts5 ./internal/backendapp/ownershiplock ./internal/backendapp
make -C apps/backend test-windows
git diff --check
The first regression test must fail before the production change because no backend-home lock exists.
Files Likely Touched
apps/backend/internal/backendapp/main.goapps/backend/internal/backendapp/main_test.goapps/backend/internal/backendapp/ownershiplock/lock.goapps/backend/internal/backendapp/ownershiplock/lock_unix.goapps/backend/internal/backendapp/ownershiplock/lock_windows.goapps/backend/internal/backendapp/ownershiplock/lock_test.goapps/backend/internal/backendapp/ownershiplock/targets.goapps/backend/internal/backendapp/ownershiplock/targets_test.goapps/backend/Makefile.github/workflows/backend-tests.yml
Dependencies
None.
Parallelism
parallel-safe with Task 02. This task owns internal/backendapp, the new lock package, and Windows
test-package configuration. Task 02 owns orchestrator and status-summary files.
Inputs
- Spec section Exclusive runtime-state ownership.
- ADR
2026-08-09-exclusive-runtime-state-ownership. - Plan section Runtime-state ownership locks.
- Existing supervisor stop-before-start behavior in
internal/launcher/supervisor.goandapps/cli/src/supervisor/child.ts.
Risks
- Do not erase a lock file during release. Another process can then lock a different file identity.
- Register subprocess cleanup before assertions so a failed test cannot retain ownership.
- Acquire every required target as one operation. Release earlier targets if a later target fails.
Output Contract
Report the behavior, changed files, exact test results, blockers, and risks. Update this task and
plan.md in the same conversation.
Results
- Added cross-platform ownership locks for the canonical Kandev home and external SQLite paths.
- Acquired ownership before backend logging and shared-state initialization; conflicts return exit code 1.
- Added subprocess, target-selection, startup-order, and Windows-sensitive package coverage.
- Verification:
go test -tags fts5 ./internal/backendapp/ownershiplock ./internal/backendapppassed (304 tests).