Skip to content

feat: expose KILROY_PREDECESSOR_NODE/OUTCOME env to handlers (#13)#88

Merged
mattleaverton merged 1 commit into
danshapiro:mainfrom
mattleaverton:fix/13-predecessor-node-env
Apr 27, 2026
Merged

feat: expose KILROY_PREDECESSOR_NODE/OUTCOME env to handlers (#13)#88
mattleaverton merged 1 commit into
danshapiro:mainfrom
mattleaverton:fix/13-predecessor-node-env

Conversation

@mattleaverton
Copy link
Copy Markdown
Collaborator

Summary

From docs/plans/2026-04-24-kilroy-fixes-from-feedback.md item #13.

Bug: Failure-handling tool-command nodes (like fail_report in pr-review) have no clean way to know which predecessor stage failed. The shipped workflow works around this by probing filesystem state (pr-meta.json exists? build-report.json exists? fall through phases in order) — a workaround for the engine not telling the handler what it needs to know.

Fix: Two new env vars exposed to every node:

  • KILROY_PREDECESSOR_NODE — id of the previously completed node
  • KILROY_PREDECESSOR_OUTCOMEsuccess / fail / canceled of that node

Reuses the existing previous_node context key in the run loop, added a parallel previous_outcome using the already-maintained nodeOutcomes map. Both are assembled in BuildStageRuntimeEnv, so they flow through to ToolHandler, CodergenHandler (API), and TmuxAgentHandler (tmux) without per-handler changes.

Semantics on first node

Node KILROY_PREDECESSOR_NODE KILROY_PREDECESSOR_OUTCOME
start node itself "" ""
First real node after start "start" "success"
Any subsequent node id of completed predecessor its outcome

Both keys always present in the subprocess env (possibly empty) so callers don't need to special-case absence vs empty.

Test plan

  • TestToolGraph_PredecessorEnvVars — 3-node graph start → a (exit 1) → b [condition=fail]; node b captures both vars into a file; asserts a + fail.
  • TestToolGraph_PredecessorEnvVarsSuccessPathstart → check → done; check captures vars; asserts start + success.
  • go test ./internal/attractor/engine/... and ./internal/attractor/agents/... pass (2 pre-existing unrelated failures confirmed on base).

Risks / follow-ups

  • Loop/retry: on a second iteration, a node may see its own id as predecessor if the loop body wraps back through it. Inherited from the existing previous_node key.
  • Parallel branches: predecessor is the last serialised completion, same as before. Branch workers in separate subgraph contexts would need their own tracking — out of scope.
  • Also scrubbed from baseNodeEnvStripKeys so a parent run's values don't leak into a child node.

Context

Produced by a dogfood quick-launch run against this repo.

🤖 Generated with Claude Code

@mattleaverton mattleaverton merged commit b55fb0f into danshapiro:main Apr 27, 2026
1 check failed
@mattleaverton mattleaverton deleted the fix/13-predecessor-node-env branch April 27, 2026 17:57
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