Skip to content

Report every NAT run's lifecycle from its start - #485

Closed
bar-capsule wants to merge 1 commit into
refimpl/adapters-09-nat-event-loopfrom
refimpl/adapters-10-nat-run-lifecycle
Closed

bar-capsule wants to merge 1 commit into
refimpl/adapters-09-nat-event-loopfrom
refimpl/adapters-10-nat-run-lifecycle

Conversation

@bar-capsule

@bar-capsule bar-capsule commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #484. Next: #486. The full stack is listed in #22.

What changed

  • NAT creates a new step stream for each run and pushes WORKFLOW_START before any call, so subscribing on the first call missed every run's start, and a later run's lifecycle entirely. build_acs_middleware now registers an acs_lifecycle telemetry exporter through the builder NAT passes it; NAT starts it for every run, subscribed before WORKFLOW_START.
  • A middleware built without NAT's builder subscribes on each run's first call, once per run's stream while that run lasts, so overlapping runs each report once, from their first call on.
  • The README's "backstop" claim is corrected: the lifecycle observer reports workflow start and end only, never tool calls, so an unwired function reaches the Guardian in no form. Wire every function and lint in CI.

Findings this answers. Raised while reviewing this stack, from NAT's Runner: the first run missed its start events, and a second run missed all lifecycle events.

Which issue does this implement

Part of #134

Base branch

Stacked on #484, not on integration. It lands through #22; see the stack in #22.

Type of change

  • Reference implementation or adapter

I tested this

At this slice's top (b595f2cd), with claude removed from PATH and ACS_LIVE_CLAUDE and ACS_SPEC_DIR unset: 456 passed and 3 expected skips with the NAT extra, 392 passed and 3 expected skips without it. The skips are the two opt-in live Claude Code tests and the manual Cursor procedure. CI passes on this PR, including the installed-wheel check on Python 3.11 and 3.12.

Checklist

  • Commits are signed off with git commit -s (required by the DCO)
  • Prose follows STYLE.md
  • No secrets, tokens, or internal URLs in the diff

Security

Every NAT run reports its lifecycle from its start.

An acs_lifecycle exporter subscribes to each run's step stream before
WORKFLOW_START, so every run reports its sessionStart and userMessage.

Signed-off-by: Bar Kaduri <bar@capsule.security>

@drk-ram drk-ram left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit b595f2cd08afe128ae3321597c9c4c7b95429c3d against its stated stacked base.

No additional blocking finding in this slice relative to #484.

acs/integrations/nat/adapter.py:923-967 registers the exporter while building the middleware, so NAT subscribes before the first workflow event rather than waiting for the first protected call. The fallback keys subscriptions by each run's stream, and the tests cover consecutive runs, overlapping fallback streams, disabled operation, and an orphan exporter configuration. Correcting the README's tool-call backstop claim is important: lifecycle observation is not coverage for unwired functions.

The focused command below passed on Windows/Python 3.11. The broader NAT selection had 52 passed, 3 failed, and 9 setup errors: the two inherited emission-fixture races raised on #484, plus the POSIX pipe-based Guardian launcher. This approval does not clear the lower slice's requested changes.

Local validation (from adapters, Python 3.11):

python -m pytest tests/integrations/nat/test_runner_lifecycle.py -q --tb=short

Result: 5 passed, 3 subtests passed in 7.62s

@rocklambros

Copy link
Copy Markdown
Collaborator

Closing this slice because PR #22 (the reference adapters for Claude Code, Cursor and NAT) merged into integration as 2630ec2, and that merge carries every slice in this stack. The top of the stack had the same files as PR #22's final commit, so nothing in this slice was left behind. Thanks, Bar, for cutting the adapters into pieces this size, because it made the review possible.

@rocklambros rocklambros closed this Nov 5, 2026
@github-project-automation github-project-automation Bot moved this from In progress to Done in ACS Project Tracker Nov 5, 2026
@bar-capsule
bar-capsule deleted the refimpl/adapters-10-nat-run-lifecycle branch November 8, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants