Skip to content

Command quality gate fails successful verbose test runs when output exceeds 64KB #784

@nrslib

Description

@nrslib

Summary

Command quality gates currently fail successful long-running or verbose commands when captured stdout/stderr exceeds 64KB. The runner terminates the process on output limit, reports Output limit exceeded: 65536 bytes, and the workflow reruns the same step before applying the already-matched transition.

Observed case

Run: .takt/runs/20260604-130916-implement-using-only-the-files-01fh38
Worktree: ../takt-worktrees/20260604T1309-783-add-prompt-tempfile

The ai-antipattern-fix step repeatedly judged No fix needed / 修正不要 with matchedRuleIndex: 1 and matchedRuleMethod: structured_output. It should have moved to ai-antipattern-no-fix.

However, after step completion, WorkflowRunLoop runs quality gates before resolving the done transition. The configured command gate executes:

bash ./.takt/quality-gates/takt-check.sh

That script runs:

npm run build
npm run lint
npm test
npm run test:e2e:mock

The command gate logs contain:

Quality gate failed: takt-quality-check
Output limit exceeded: 65536 bytes
[OUTPUT TRUNCATED: exceeded 65536 bytes]

The process is killed during verbose npm test output before reaching the E2E summary, so the gate fails even though the agent-run checks reported success.

Root cause

src/core/workflow/quality-gates/commandGateRunner.ts treats output limit exceeded as a command failure and calls terminateProcess(). This makes verbose successful commands fail because of output volume, not exit code.

WorkflowRunLoop then applies the quality gate failure snapshot and continues the same step, so the workflow loops.

Expected behavior

Output capture limits should limit captured feedback, not determine command success. If the child command exits with code 0, the command gate should pass even when stdout/stderr was truncated.

Suggested fix

  • Stop appending captured stdout/stderr after MAX_OUTPUT_BYTES is reached.
  • Do not terminate the child process solely because output capture exceeded the limit.
  • Preserve an output-truncated marker in logs/feedback.
  • Fail only on non-zero exit, timeout, spawn error, or invalid cwd.
  • Add a regression test for a command that prints more than 64KB and exits 0.

Temporary workaround

Remove or disable the type: command quality gate from .takt/config.yaml, or make .takt/quality-gates/takt-check.sh quiet by redirecting each command to a log and printing only short summaries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions