Repository navigation
fix(skills): payload-cli's PTY driver stalls — chalk colours break its prompt regex - #762
Conversation
`interactive.py` exists so `migrate:create` cannot hang on drizzle's
rename-vs-create prompt. It stopped answering that prompt: the child runs on
a PTY, so chalk colours the column and table names, and `\w+` cannot span the
escapes now sitting inside the match:
Is \x1b[1m\x1b[34mcommon_chrome\x1b[39m\x1b[22m column in …
`Starting migration` and the data-loss prompt still matched, because chalk
does not colour those — which is why the phase-boundary reset looked healthy
right up to the first real prompt. The driver then waited until the caller's
`timeout` killed it: exit 124, no migration, and nothing in the log saying
why.
Match on an ANSI-stripped copy. The bytes going to `/tmp/payload-pty.log`
stay raw, so the log still shows what the terminal saw.
A question left silent for `PAYLOAD_PTY_STALL_SECONDS` (default 90) now ends
the run with exit 3 and the last 200 characters, rather than letting the
caller's `timeout` decide between the two documented failure modes. Ordinary
work does not trip it: any output restarts the clock, drizzle's re-render of
an answered prompt included.
`PAYLOAD_PTY_CWD` runs the child somewhere other than the repo root this file
sits in, so a patched copy no longer has to live four directories deep.
Refs #751
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DfBVHWawcqnWmwCaR9DCjC
The driver has now shipped four silent bugs and had no gate at all. Its own documented check needs a schema change and a database, so nobody ran it. Three cases drive the real driver over a real PTY against a node child that prints one prompt: the coloured rename prompt from a real log, an unparseable question that must end the run, and `PAYLOAD_PTY_CWD`. Each was watched failing against its own defect reintroduced at the site that caused it. The hang case needs the `driver ended on its own` assertion beside the exit code: a killed process also exits non-zero, so `returncode != 0` passes for the hang this case exists to catch. Run it with `python3 .claude/skills/payload-cli/test_interactive.py`. It is not wired into CI — the file is a skill asset, outside every lane. Refs #751 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DfBVHWawcqnWmwCaR9DCjC
The sentence filing this bug is the only thing standing between the next reader and the same 400-second wait, so the count in the heading is load-bearing rather than decorative. Also documents exit 3, the two environment overrides, and the self-test, none of which the driver had before. Closes #751 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DfBVHWawcqnWmwCaR9DCjC
|
🚅 Deployed to the SahajCloud-pr-762 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
|
The session for this item did not finish after 3 attempts. I have stopped retrying. A comment, a verb, or a push from you starts me again. 🤖 sydevs dispatcher |
|
The session for this item did not finish after 3 attempts. I have stopped retrying. A comment, a verb, or a push from you starts me again. 🤖 sydevs dispatcher |
|
The session for this item did not finish after 3 attempts. I have stopped retrying. A comment, a verb, or a push from you starts me again. 🤖 sydevs dispatcher |
|
The session for this item did not finish after 3 attempts. I have stopped retrying. A comment, a verb, or a push from you starts me again. 🤖 sydevs dispatcher |
|
The session for this item did not finish after 3 attempts. I have stopped retrying. A comment, a verb, or a push from you starts me again. 🤖 sydevs dispatcher |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Holistic. The three-line ANSI strip is the ticket's ask, and is right. Around it the diff grew to ~3×: 126 of 198 lines are an unrequested, un-run self-test, plus a stall detector and two knobs. I would not merge the detector. Its 90s default is under this repo's measured 2m08s silent boot (src/migrations/AGENTS.md:48-52), and it cannot tell an answered prompt from an unparsed one.
Findings
- should-fix
interactive.py:115— arms on answered prompts and misreports them. - should-fix
interactive.py:63— 90s default is under the documented 128s boot. - consider
interactive.py:68—ANSImisses\x1b[?25l, the bug being fixed. - consider
interactive.py:59—PAYLOAD_PTY_CWDdoes not revert alone, per the body. - consider
test_interactive.py:5— prose-run, and one assertion cannot fail.
Checked. #751, the PR body, three commits, both .py files whole, payload-cli/SKILL.md, src/migrations/AGENTS.md:38-78 — exit 3 lands in its "Other error" row. Consumers: AGENTS.md:75, migrations/AGENTS.md:47,73,74.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
|
||
| python3 .claude/skills/payload-cli/test_interactive.py | ||
|
|
||
| Nothing in CI runs this. It exists because the driver has now shipped four |
There was a problem hiding this comment.
Worth asking what this earns. It is 126 lines against a 59-line fix, and the only thing that runs it is a sentence in SKILL.md — the same prose-only enforcement that let four bugs ship. Could pnpm test:unit shell out to it, or is a Python step not worth it in that lane?
Line 95 also asserts returncode != 0, which the PR body says passed against the reintroduced defect. An assertion that cannot fail is worth deleting — line 94 already carries the case.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
There was a problem hiding this comment.
Assertion adopted in dc7b7f9, as returncode == 3 rather than a deletion — exit 3 is the contract SKILL.md and the migrations guide tell a caller to read. Watched failing with give_up exiting 4. It stayed green today while 4 assertions beside it went red.
On CI: ubuntu-latest ships python3, so a spec could shell out. The cost is wall-clock — the cases wait on real PTY clocks, ~35s, against a 17s unit lane. Your call.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The detector could not tell an answered prompt from an unparsed one. Answering clears `buf`, but drizzle re-renders the prompt afterwards and that echo lands straight back in it. The echo is output, so it restarts the silence clock and cannot trip the detector itself — but it stays in `buf` armed. The next genuinely quiet stretch, the migration write or a slow boot, then exits 3 saying "saw a prompt I could not parse" about a prompt the driver did answer. `unanswered()` matches each question line against what `seen` already records, so only a question this driver never answered can end the run. The new case drives the real driver over a PTY: answer a coloured prompt, echo it back, then go silent past the bound. Watched failing against the defect reintroduced at its own site — `unanswered(stalled)` back to `QUESTION_LINE.search(stalled)` — 2 of its 3 assertions red. Reported in review: #762 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012tsfQ56ZoU9hXgNjppCCkR
The 90s default sat under this repo's own documented silence. `src/migrations/AGENTS.md` records `db:migrations:create` booting the Payload config in 2m08s, twice, and that measurement is why the caller's `timeout` is 300 and not 150. A healthy run that went quiet for 128s exited 3. 240 clears the measured boot and still ends the run before the caller's 300s bound, so a genuine hang keeps its useful message instead of a bare exit 124. Reported in review: #762 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012tsfQ56ZoU9hXgNjppCCkR
`[0-9;]*` cannot take `?`, so `\x1b[?25l` and `\x1b[?25h` survived the strip — the cursor hide/show a prompt library emits around a select. That is the same shape as the bug this branch fixes, an escape sitting inside the text we match on, and it has a concrete cost: the cursor-show lands after the question mark, so `QUESTION_LINE`'s `\?[ \t\r]*$` stops matching and an unanswerable prompt hangs again, which is the failure exit 3 exists to replace. The existing unparsed-prompt case now ends its question with `\x1b[?25h`. Watched failing against the narrow class restored: 4 of its 5 assertions red, the driver hanging until the test's own timeout killed it. Reported in review: #762 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012tsfQ56ZoU9hXgNjppCCkR
`returncode != 0` could not fail. `subprocess` kills a timed-out child, so a hang gives a non-zero code too — the PR body already recorded it passing against the reintroduced defect, and it did so again in this session while four assertions beside it went red. Exit 3 is the contract `payload-cli/SKILL.md` and `src/migrations/AGENTS.md` tell a caller to read, so assert that instead of deleting the line. Watched failing with `give_up` exiting 4. Reported in review: #762 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012tsfQ56ZoU9hXgNjppCCkR
|
Addressed the adversarial review. Pushed Adopted
Open. That thread also asks whether Detector stays, both findings fixed. 14 checks, each watched failing. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
interactive.pyanswers drizzle's rename-vs-create prompt again — it now matches on ANSI-stripped text, while the log keeps the raw, coloured bytes.timeoutkills it. It arms on an unanswered question only.Changes
.claude/skills/payload-cli/interactive.py— strip ANSI (SGR and private-mode) before matching; give up loudly on an unanswered prompt;PAYLOAD_PTY_CWDandPAYLOAD_PTY_STALL_SECONDSoverrides..claude/skills/payload-cli/test_interactive.py— new. Run withpython3 .claude/skills/payload-cli/test_interactive.py..claude/skills/payload-cli/SKILL.md— the fourth bug, exit 3, the overrides, the stall bound's two constraints, and how to run the self-test.Preview
Preview pending — Railway posts the URL as a commit status once the PR environment deploys. No application code changed, so it exercises nothing new.
Test results
.claude/skills/pr-prep/check.sh— lint, typecheck (src), typecheck (tests), 1671 unit tests in 128 files.test_interactive.py.Each case was watched failing against its own defect, reintroduced at the site that caused it: matching on raw text (4 assertions red), the
give_upcall removed (4 red), the narrow ANSI class restored (4 red),unanswered()back to a bareQUESTION_LINEsearch (2 red),give_upexiting 4 (1 red), thePAYLOAD_PTY_CWDlookup removed (1 red).Manual verification
SKILL.mddocuments it, and confirmgrep -c '\[pty\] answered' /tmp/payload-pty.logis greater than zero and a migration file appears. The self-test proves the prompt-matching, but only a real drizzle run proves the prompt text still looks the way this driver expects.Notes for reviewer
Edit(.claude/skills/**)/Write(.claude/skills/**), and the files here were written from the shell in any case, so Protected Paths never came up. Worth correcting wherever else that warning is repeated.PAYLOAD_PTY_CWDdoes not revert alone. An earlier version of this body claimed it did. It sits in9004694with the ANSI strip andgive_up, and splitting it now means rewriting pushed history, which this branch does not do. It removes the reason the feat(translations): rewrite the Sahaj Atlas schema by widget view, seed all ten locales, and gate availableLocales on them #706 workaround needed a patched copy four directories deep.PAYLOAD_PTY_STALL_SECONDSraises the bound. A false positive costs a re-run with a message saying exactly that; the failure it replaces cost 400 seconds and said nothing.src/migrations/AGENTS.md:48-52measured twice, and stays under the caller's 300stimeoutso a genuine hang still ends with a message rather than a bare exit 124.Detail
Why the old regex failed. On a PTY chalk colours the column and table names, so the bytes are
Is \x1b[1m\x1b[34mcommon_chrome\x1b[39m\x1b[22m column in …and\w+cannot span the escapes.Starting migrationandAccept warnings and push schema to database?are uncoloured and kept matching, which is why the phase-boundary reset looked healthy right up to the first real prompt.The strip takes
?in its parameter class.\x1b[?25l/\x1b[?25hare the cursor hide/show a prompt library wraps a select in, and[0-9;]*could not match them. Left in, the cursor-show lands after the question mark, soQUESTION_LINE's\?[ \t\r]*$stops matching and an unanswerable prompt hangs again — the exact failure exit 3 exists to replace.One clock was never the problem; the buffer was. A first draft tracked
last_answerbesidelast_outputso an answered prompt's echo could not read as a new one. The echo is output, so it already restartslast_output. But it also lands back inbufand stays there, armed, and the next quiet stretch gave up over a prompt the driver had answered.unanswered()fixes that at the buffer, matching each question line against whatseenrecords.The hang case needs two assertions, not one.
subprocesskills a timed-out child, soreturncode != 0held for the hang as much as for the intended exit 3 — it could not fail, and stayed green while four assertions beside it went red. It now assertsreturncode == 3, the codeSKILL.mdandsrc/migrations/AGENTS.mdtell a caller to read.Not wired into CI. The file is a skill asset, outside every lane this repo runs.
ubuntu-latestdoes ship python3, so a unit spec could shell out to it — the cost is wall-clock, since the cases wait on real PTY clocks (~35s) against a 17s unit lane. Left open for the reviewer.SKILL.mdsays to run it after touching the driver.Closes #751
🤖 Generated with Claude Code
https://claude.ai/code/session_012tsfQ56ZoU9hXgNjppCCkR