Skip to content

fix(lua-agent-builder): the post-deploy smoke check runs in the agent project the deploy ran in (1.17.2) - #31

Merged
rares04 merged 3 commits into
mainfrom
rares/smoke-runs-in-project
Oct 29, 2026
Merged

rares04 merged 3 commits into
mainfrom
rares/smoke-runs-in-project

Conversation

@rares04

@rares04 rares04 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What was wrong

After every deploy or promote, post-deploy-smoke warned agent did not respond (exit=2) even though the agent answered. bs-tester saw it on every promote, on staging and in prod (2026-10-29).

Cause, reproduced locally with lua-cli 3.62.0 and 3.63.0:

  • Claude Code runs a hook from its own directory, not from the folder the Bash command cd'd into.
  • After cd agents/shop && <deploy>, the ping lua chat --ci -e production -m ping therefore ran outside the agent project. lua-cli exits 2 there: ✖ usage: No lua.skill.yaml found.
  • The same ping run inside the project exits 0 and the agent answers pong.
  • The lua logs scan had the same problem.

Fix (the whole class: every lua command the hook runs)

  • deployProjectDir(command, cwd) finds the project the deploy ran in:
    • it starts from the shell's directory (cwd in the hook input; detect-project and inject-context already prefer it);
    • it applies any literal cd before the lua command (luaWorkingDirs in lib/tokenizer.mjs, top-level segments, using the gate's own lexer);
    • it then walks up to the nearest lua.skill.yaml.
  • The ping and both log scans run there (spawnLua takes a cwd).
  • When it can't tell which project ran the command (a computed cd, cd -, or no project there or above), the check says it was skipped. It never blames the agent.
  • A failed ping names lua-cli's own first error line. A timed-out ping says the agent did not answer within 20 s.
  • Version 1.17.2: plugin, marketplace, the MCP server and its bundle, and the CHANGELOG.

Tests

  • New tests cover:
    • the project found through a cd and from a subfolder;
    • no project means "skipped" with no ping;
    • lua-cli's reason shown on a failed ping;
    • a timeout;
    • luaWorkingDirs on 8 shapes, including computed cd, cd -, quoted paths and a cd after the lua command.
  • Without the cwd passed to the spawns, the two project-location tests fail (2 failed / 48).
  • Full plugin suite: 2560 passed. MCP: 149 passed.

🤖 Generated with Claude Code

… project the deploy ran in (1.17.2)

Claude Code runs hooks from its own directory, so after `cd agents/x && <deploy>`
the ping and log scan ran outside the project; lua-cli exited 2 (no
lua.skill.yaml) and every deploy reported "agent did not respond". The
check now resolves the project from the hook's cwd plus any literal cd
before the lua command, says it was skipped when it cannot tell, and
names lua-cli's own reason when the ping fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rares04
rares04 requested a review from selcuk-lua October 29, 2026 14:30
selcuk-lua
selcuk-lua previously approved these changes Oct 29, 2026

@selcuk-lua selcuk-lua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review — LOW risk

Focused, well-tested bug fix: post-deploy-smoke now runs its lua chat ping and lua logs scan in the agent project the deploy actually ran in (derived from the hook's cwd plus literal cd prefixes via the new luaWorkingDirs, then walking up to the nearest lua.skill.yaml), instead of the hook process's own directory. The hook remains non-blocking (warn only), distinguishes skip/timeout/failure cleanly, and the new paths are covered by tests including the cwd-passing regression. Version bumps (1.17.2) are consistent across plugin, marketplace, MCP package/lock/bundle, server, api-client and CHANGELOG. Nothing blocking.

Minor

  • hooks/post-deploy-smoke.mjs:36 — deployProjectDir trusts input.cwd without checking it exists; a vanished or relative cwd yields a benign 'skipped' message rather than a real check. Optionally guard the start directory, or document the behavior.
  • lib/tokenizer.mjs:1035 — luaWorkingDirs assumes every top-level cd before the lua command is actually taken (conditionals like false && cd a && lua … are treated as taken). Fine for a warn-only heuristic; tighten the doc comment to say so.
  • hooks/post-deploy-smoke.mjs:40 — a failed ping now echoes firstLine(ping.stderr) into the model context. Low risk given the single-line / 200-char cap; consider restricting to the known ✖ usage: prefix if you want to avoid echoing unexpected stderr.

PR Risk Reviewer — automated senior review of f4b8aca · risk: low · confidence: 0.82

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
selcuk-lua
selcuk-lua previously approved these changes Oct 29, 2026

@selcuk-lua selcuk-lua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review — LOW risk

Previously flagged

  • Previously flagged deployProjectDir trusts input.cwd without validating it exists — still open (advisory). deployProjectDir (hooks/post-deploy-smoke.mjs:36) still starts from input?.cwd ?? process.cwd() and resolves cd prefixes without checking the directory exists; a missing/relative cwd degrades to a benign 'skipped' message. Minor and acceptable.
  • Previously flagged luaWorkingDirs cd-ordering semantics — still open (advisory). luaWorkingDirs (lib/tokenizer.mjs:1035) still assumes every top-level cd before the lua command is taken; the doc comment was not tightened. Fine for a warn-only heuristic.
  • Previously flagged firstLine surfaces lua-cli stderr into Claude context — still open (advisory). A failed ping still echoes firstLine(ping.stderr) (capped to one line / 200 chars). Low risk.

This revision is effectively the same code reviewed at f4b8aca015; the new commits did not change the smoke-check logic or luaWorkingDirs, and all three carryover items are minor, non-blocking notes. Version bumps to 1.17.2 are consistent across plugin, marketplace, MCP package/lock/bundle, server and api-client, and the new behavior stays non-blocking (warn only) with good test coverage. Safe to merge.

Minor

  • hooks/post-deploy-smoke.mjs:36 — deployProjectDir trusts input.cwd without checking it exists; a vanished or relative cwd yields 'skipped' rather than a real check. Optionally guard the start dir or document the behavior.
  • lib/tokenizer.mjs:1035 — luaWorkingDirs counts every top-level cd before the lua command as taken (e.g. false && cd a && lua …). Tighten the doc comment to state the assumption.
  • hooks/post-deploy-smoke.mjs:40 — a failed ping echoes firstLine(ping.stderr) into model context. Consider restricting to the known ✖ usage: prefix if you want to avoid passing arbitrary stderr through.

PR Risk Reviewer — automated senior review of b616c0e · risk: low · confidence: 0.82


PR Risk Reviewer — automated senior review of b616c0e · risk: low · confidence: 0.82 · re-review · round 2

… ping

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rares04

rares04 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Two follow-ups since the approval, both from CI: the skipped-check hint now suggests a ping on a fresh thread (-t, the plugin's own lint rule), and two tests cover the home-folder cd and a failed ping with no output, so hooks/ stays at 100% coverage. npm test -- --coverage (2562 passed) and npm run lint both exit 0 locally.

@selcuk-lua selcuk-lua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review — LOW risk

Previously flagged

  • Previously flagged deployProjectDir trusts input.cwd without validating it exists — still open (advisory). hooks/post-deploy-smoke.mjs:36 still starts from input?.cwd ?? process.cwd() with no existence check; a missing/relative cwd degrades to a benign 'skipped' message. The new commits only added the -t hint and two tests, not a guard. Minor.
  • Previously flagged luaWorkingDirs cd-ordering semantics — still open (advisory). lib/tokenizer.mjs:1035 is unchanged; the doc comment still does not note that short-circuited cd segments are assumed taken. Fine for a warn-only heuristic.
  • Previously flagged firstLine surfaces lua-cli stderr into Claude context — still open (advisory). A failed ping still echoes firstLine(ping.stderr) (one trimmed line, 200-char cap). Low risk.

The round-3 changes are small and safe: the skipped-check message now suggests pinging on a fresh thread (-t, matching the plugin's own lint rule), and two new tests (home-folder cd resolution, a failed ping with no output) hold hooks/ at 100% coverage. The smoke-check logic and luaWorkingDirs are otherwise unchanged from the prior round, the hook stays non-blocking (warn only), and version bumps to 1.17.2 are consistent across plugin, marketplace, MCP package/lock/bundle, server and api-client. All three carryover items are minor, non-blocking notes. Safe to merge.

Minor

  • hooks/post-deploy-smoke.mjs:36 — deployProjectDir trusts input.cwd without checking it exists; a vanished or relative cwd yields 'skipped' rather than a real check. Optionally guard the start dir or document the behavior.
  • lib/tokenizer.mjs:1035 — luaWorkingDirs counts every top-level cd before the lua command as taken (e.g. false && cd a && lua …). Tighten the doc comment to state the assumption.
  • hooks/post-deploy-smoke.mjs:40 — a failed ping echoes firstLine(ping.stderr) into model context. Consider restricting to the known ✖ usage: prefix if you want to avoid passing arbitrary stderr through.

PR Risk Reviewer — automated senior review of 3087bf4 · risk: low · confidence: 0.85 · re-review · round 3

@rares04
rares04 merged commit 181bd58 into main Oct 29, 2026
7 checks passed
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.

2 participants