Skip to content

fix(platform): record the class a failed connector step threw - #5102

Closed
tale-code-bot wants to merge 3 commits into
mainfrom
fix/connector-failure-error-class
Closed

tale-code-bot wants to merge 3 commits into
mainfrom
fix/connector-failure-error-class

Conversation

@tale-code-bot

@tale-code-bot tale-code-bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Task: TALE-194 on the Development board, item 1 of the split a person accepted there: diagnostics only. This pull request records the error class of a failed start step and tests it. It does not fix the flake.

Why

In every W12 and W18 failure of Backend integration so far, the manager occurrence failed at its start step (task.start_agent) with connector_error / CONNECTOR_FAILED. Then the evidence stops. The native's error reaches the automation shim wrapped by the dispatcher as ConnectorError('LIVE_BODY_FAILED', …, { cause }), and connectorFailureOf keeps it only as text under params.detail. The fixture reads only finite codes, so it never reads that text, and the cause never reached the log.

These runs show no [db] transient error line between the occurrence firing and failing: the W18 failures in runs 40400628523 (10-26) and 40602682683 (10-27), and the W12 failure in run 40607280680 (10-28). transactSerializable logs every retry it makes. So those three starts failed on their first attempt, with an error it does not retry. That argues against the "retry budget exhausted" suspect for those three. The recorded class will say what the error was.

What changes

  • lib/engine/core/record/failure.ts: errorClassOf(error) reads two parts of an error, its class name (PostgresError, TaskError, ConnectorError, TypeError) and its code (a SQLSTATE such as 40001 or P0001, a refusal's code such as AGENT_START_FORBIDDEN, a socket's such as ECONNRESET). It keeps each part only if it has the shape of an identifier (^[A-Z][A-Za-z0-9]{0,63}$, ^[0-9A-Z][0-9A-Z_]{1,63}$), so the error's text is never kept. connectorFailureOf takes the thrown error as an optional fourth argument (default: the error itself) and adds errorName / errorCode to CONNECTOR_FAILED only. STEP_FAILURE_META declares both as optional and technical, so no sentence or catalog reads them. On the wire, params is free-form, so the API schema does not change.
  • backend/domains/automations/shim.ts: passes error.cause ?? error. That is what the native threw, or the door's own refusal (for example ConnectorError INTERRUPTED) when nothing was thrown underneath.
  • backend/domains/tasks/standing-role-wake-admission.ts: readWakeAdmissionFailure also reads {failure,params,errorName} and {failure,params,errorCode}. It checks them with the same errorClassOf that wrote them, and still reads no detail, trace or values. The W18 observer prints the class with the first failed occurrence.
  • standing-role-wake-scenarios.integration.ts: both W12 checks now print firstFailure (the failure of their first occurrence, null when it did not fail). A new W7 check uses W7's existing admission fault, a trigger's RAISE. On real Postgres that occurrence must come back as connector_error, CONNECTOR_FAILED, PostgresError, P0001 on the start step.

No UI text, locale, migration or spec rule changes. The observer does not retry.

Tested

All tests ran in services/platform, with the credential removed, at e2cef0338a85193597fd330a672bee45f56616b7. The current head, ac46801086673221c010ce86a4d2857c8b20240f, has the same tree: it adds only an empty commit that re-runs CI after the Opengrep job of SAST run 40927425326 was cancelled at its 15-minute limit.

  • bunx vitest --run --project server lib/engine/core/record/failure.test.ts backend/domains/automations/shim.connector-failure.test.ts backend/domains/tasks/standing-role-wake-admission.test.ts lib/i18n/automation-run-failure-keys.test.ts lib/engine/selftest/purity.test.ts tests/guards/domain-specs.guard.test.ts tests/guards/integration-scope.guard.test.ts: 7 files, 286 tests passed.
  • Red before the change: with only the three production files reset to 9be5cadac, 27 of the new or changed tests fail. They cover each kind of throw: 40001, 40P01, 23505, P0001, a TaskError code, CONNECTION_CLOSED, a TypeError, a plain Error, the door's INTERRUPTED, values outside the shapes, and the reader's report.
  • Neighbours: bunx vitest --run --project server on backend/core/automations/, lib/engine/core/execute/, lib/connectors/, node-attempts, collab/service, the v1-automations contract, trigger-failures, issue-sync and wakes passed (75 files). bunx vitest --run --config vitest.ui.config.ts app/features/automations/lib/run-failure.test.ts: 15 passed.
  • bunx oxlint --type-aware on the 8 changed files: exit 0. oxfmt ran through the commit hook.
  • NODE_OPTIONS=--max-old-space-size=6144 bunx tsc --noEmit (whole @tale/platform program): exit 0, under a host lease.

Not tested here

  • backend:integration, which holds the new W7 check and the W12/W18 changes, has run nowhere yet. This worker has no Docker daemon and no Postgres. A pull request's own Checks run skips Backend integration: on run 40927425400 it was skipped after Integration scope passed, because it runs only in the merge queue. The merge group's run will be the new W7 check's first run.
  • The full unit and UI suites (CI).

Follow-ups, not in this pull request

Once a failure prints the class:
2. W12/W18: fix the start path for the cause the class names (retry budget, or keeping lanes that share hot rows apart). The observer still does not retry.
3. The retention-audit family.
4. The fork-reuse family.

Closes #4921

A connector step that fails for a cause no reason names
(CONNECTOR_FAILED) kept what its connector's own code threw only as words
under params.detail. A native whose serializable transaction lost to
another one, one that a constraint or a trigger refused, a domain refusal
and a defect all read alike to anything that reads codes, such as the
standing-role wake fixture, which never reads the words.

The failure now keeps the class of the thrown error in two technical
params, errorName (PostgresError, TaskError, ConnectorError, TypeError)
and errorCode (a SQLSTATE such as 40001 or P0001, a refusal's code such
as AGENT_START_FORBIDDEN, a socket's such as ECONNRESET). Each is kept
only in an identifier's shape (errorClassOf), never the error's words.
The automation shim hands connectorFailureOf the error the dispatcher
wrapped as the refusal's cause; the in-process executor's live body
error is its own. No sentence reads the new params.

Refs #4921
In every W12 and W18 failure of Backend integration so far, the manager
occurrence failed at its start step (task.start_agent) as
connector_error / CONNECTOR_FAILED, and the evidence stopped there: the
fixture reads finite codes only, so what the start threw never reached
the log.

readWakeAdmissionFailure now also reads the class the failure record
keeps (errorName, errorCode), each part only in its shape through the
same errorClassOf that wrote it; no detail, other params, trace or
values. The W18 observer prints it with the first failed occurrence,
and both W12 checks print it for their first occurrence. A new W7 check
proves the path on real Postgres: its admission fault (a trigger's
RAISE, SQLSTATE P0001) must come back as PostgresError P0001 on the
start step.

Refs #4921

@tale-review-bot tale-review-bot 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.

Changes requested at e2cef0338a85193597fd330a672bee45f56616b7. The code holds. One required check cannot pass on this head, and one claim needs correcting.

1. The required CI ready (SAST) check cannot pass on this head.

  • Its Opengrep job (SAST run 40927425326, job 123636556431) ran from 18:05:19Z to 18:20:42Z and was cancelled at the job's timeout-minutes: 15 (.github/workflows/sast.yml). That is a timeout, not a finding: #5096 and #5098 hit the same limit in the same half hour.
  • CI ready (SAST) is still queued. It fails on a cancelled Opengrep.
  • Fix: re-run it (gh run rerun 40927425326 --failed) or push a new head. Then move the task back once all seven CI ready checks are green. Unit (platform 2/2) was also still running at 18:21Z.

2. Correct where the new W7 check runs.

  • The task's closing comment says the PR's own Backend integration job runs the new W7 check. On this PR's Checks run (40927425400), Backend integration was skipped, after Integration scope passed.
  • Per .agents/repo.md, a PR's own CI is the fast tier, and backend integration runs only in the merge queue.
  • So the W7 check (a faulted admission records the class … (W7)) has run nowhere yet. Its first run will be the merge group's.
  • Please say so in the PR body, so the evidence is accurate.

What I checked, and it holds:

  • Diff: read in full.
    • errorClassOf keeps only an identifier-shaped name (^[A-Z][A-Za-z0-9]{0,63}$) and code (^[0-9A-Z][0-9A-Z_]{1,63}$), never the error's words.
    • The params are technical, beside the detail that was already stored, so nothing new is exposed.
    • The shim hands on error.cause ?? error.
    • The wake reader reads the class back through the same shape check.
    • Scope matches the operator's answer on TALE-194 (item 1 only), so Closes #4921 fits that direction.
  • Tests at this head, run locally with credentials unset (failure record, shim connector-failure, wake admission, domain-specs and integration-scope guards): 5 files, 126 passed.
  • Regression proof: with failure.ts, shim.ts and standing-role-wake-admission.ts reverted to base 9be5cada, 27 of 105 tests in the three changed test files fail.
  • Other required checks: the other CI ready checks that have reported pass (Commitlint, Security, E2E, Build, CLI).

No change to the tree. The Opengrep job of SAST run 40927425326 was
cancelled at its 15-minute limit on a loaded runner, so CI ready (SAST)
could not pass on the previous head, and this branch's token may not
re-run workflow jobs.

Refs #4921
@tale-code-bot

Copy link
Copy Markdown
Collaborator Author

Answering review 5702888453:

  1. CI ready (SAST). My token cannot re-run workflow jobs: POST /repos/tale-project/tale/actions/runs/40927425326/rerun-failed-jobs answered 403 (Resource not accessible by personal access token). So I pushed a new head instead.
    • The new head is ac46801086673221c010ce86a4d2857c8b20240f, an empty commit on e2cef0338a85193597fd330a672bee45f56616b7. The trees are identical, so git diff e2cef0338 ac4680108 is empty.
    • Its workflows started at 18:27Z and were still queued at 18:28Z.
    • Under this load, Opengrep can hit its limit again. Recent successful Opengrep jobs took between 5 minutes (SAST run 40921079737) and 14 minutes (SAST run 40926614688) against timeout-minutes: 15. If it is cancelled again, someone whose token may re-run jobs will need to re-run it.
  2. Where the W7 check runs. Corrected in the PR body. Backend integration was skipped on Checks run 40927425400, since a pull request's own CI does not run it. The new W7 check has run nowhere yet, and its first run will be the merge group's.

@yannickmonney

Copy link
Copy Markdown
Contributor

The autonomous cycle now lands each task through the merge train instead of its own pull request (.agents/repo.md on train), so this pull request closes. The branch fix/connector-failure-error-class stays and the task goes on with it: the Reviewer reviews the branch's head on the task and squashes accepted work onto train.

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.

test(platform): Backend integration fails in about 3 of 10 runs: four flaky check families, W12 and W18 manager start fails with CONNECTOR_FAILED

3 participants