Skip to content

Add runtime identity artifacts for task worktrees#34

Closed
Fuiste wants to merge 4 commits into
mainfrom
codex/research-night-shift-friction
Closed

Add runtime identity artifacts for task worktrees#34
Fuiste wants to merge 4 commits into
mainfrom
codex/research-night-shift-friction

Conversation

@Fuiste

@Fuiste Fuiste commented Apr 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a persisted per-task runtime identity with deterministic worktree IDs, Compose project names, port bases, and optional named port aliases
  • generate runtime artifacts under each run and inject NIGHT_SHIFT_* variables into setup, maintenance, provider execution, and verification flows
  • surface runtime identity details in prompts, status, reports, docs, and QA guidance without adding new CLI flags
  • update the demo and test harness to cover runtime identity generation, persistence, and reporting behavior

Testing

  • gleam test

@Fuiste Fuiste left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I found two blocking issues in the runtime identity implementation.

  • src/night_shift/runtime_identity.gleam:47-57 derives port_base from sha256_mod(..., 1000), so there are only 1000 possible bases. Because runtime contexts are retained per task, not just used transiently, different tasks in the same run can collide on the same port block. The collision risk is already material well below 1000 tasks (roughly 17% by 20 tasks), so this does not provide the deterministic isolation the feature is aiming for.
  • src/night_shift/runtime_identity.gleam:160-164 writes night-shift.env as raw KEY=VALUE lines using absolute paths from the runtime context. If either the repo path or state path contains spaces, the resulting file is not safely sourceable by shell scripts, even though the docs pitch it as a shell/Compose-friendly artifact. The env file needs escaping/quoting rules (or a narrower documented parser contract) before we can rely on it.

Fuiste commented Apr 13, 2026

Copy link
Copy Markdown
Owner Author

Addressed the review in 4fa6de9.

  • runtime port allocation now probes deterministically across the current run and skips port blocks already persisted by retained worktrees, so tasks in the same run no longer collide on the 20-port block
  • night-shift.env now writes shell-safe quoted assignments, and the docs/tests now describe and cover that contract
  • reran gleam test after the fixes

Fuiste commented Apr 14, 2026

Copy link
Copy Markdown
Owner Author

QA completed on the combined stack branch and the work has been superseded by #35.

What I validated:

  • combined-branch end-to-end QA in the scratch repo
  • intentional interruption followed by doctor, resume --explain, and resume
  • successful verification, provenance/runtime artifacts, and delivery on the resumed run

Closing this PR in favor of the QAed combined branch.

@Fuiste Fuiste closed this Apr 14, 2026
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