feat(triage): add Failure Triage Pack for test-time structured diagnostics
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 30
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Introduce Failure Triage Pack (Phase 2) to accelerate root-cause analysis for failures during test execution.
This feature is not "replay logging".
It produces structured diagnostics for fast triage and next-action decision.
- Phase 1 (already done): Contract Guard = pre-execution prevention
- Phase 2 (this issue): Failure Triage Pack = post-failure diagnosis
- Phase 3 (later): Runtime Trace Assist = continuous observability
Scope (MVP)
In Scope
- Target: test execution only (e.g.
ztd testpath) - Structured error normalization and artifact output
- JSON artifact as source of truth, Markdown generated from JSON
- Security-first defaults:
- params masked
- SQL body excluded
- include only
sqlHead(first N chars) + references (specId, paths)
Out of Scope (for MVP)
- dev runtime aggregation (
ztd run, local repository runtime path) - production/staging observability integration
- full SQL body logging by default
Fixed stage enum (8)
CATALOG_RESOLVESQL_PARSESQL_REWRITECONTRACT_VALIDATEMAPPING_BUILDREPOSITORY_EXECTEST_TRANSFORMTEST_RUN
Domain categories (MVP set)
CATALOGPARSE_UNSUPPORTEDPARSE_SYNTAXREWRITE_BUILDMAPPINGTYPE_CONTRACTSTRUCTUREREPOSITORY_RUNTIMETEST_FIXTURE_DRIFTTEST_CASE_INVALIDTEST_TRANSFORM_FAILURE
Error code policy
- Format:
ZTD-<DOMAIN>-NNN(e.g.ZTD-PARSE-002) - Once published, meaning must not change
- Deprecated codes are not removed (
deprecated: true), no hard deletion
nextActionId dictionary (MVP)
OPEN_SQLOPEN_SPECRUN_LINTRUN_FIXTURE_REGENCHECK_MAPPINGUPGRADE_RAWSQLREPORT_BUG
Artifact output
artifacts/failure/<runId>.jsonartifacts/failure/<runId>.md
runId format:
YYYYMMDDTHHMMSS.mmmZ_<env>_<pid>_<rand4>
Example:
20260215T034556.789Z_test_12345_a1b2
env enum (fixed): test | dev | ci
(MVP uses test first)
Minimum JSON shape (artifact)
{
"runId": "20260215T034556.789Z_test_12345_a1b2",
"occurredAt": "2026-02-15T03:45:56.789Z",
"specId": "user.findById",
"stage": "SQL_PARSE",
"domain": "PARSE_SYNTAX",
"errorCode": "ZTD-PARSE-002",
"isTestSide": true,
"causeSummary": "Syntax error near \"fromm\"",
"nextAction": {
"id": "OPEN_SQL",
"message": "Open SQL file and fix token near line 12."
},
"refs": {
"specPath": "src/catalog/specs/user.findById.ts",
"sqlPath": "src/sql/user/find_by_id.sql",
"sqlHead": "select * fromm user where user_id = :user_id"
},
"security": {
"paramsMasked": true,
"sqlBodyIncluded": false
}
}
Acceptance Criteria (DoD)
- On test-time failure, triage artifact JSON is always generated with:
• specId, stage, domain, errorCode, causeSummary, nextAction.id - Markdown report is generated from JSON (no duplicated logic)
- security block is always present and accurate
- At least these test-side failures are classified:
• fixture drift
• test case invalid
• test transform failure - Reviewer can identify first action within ~1 minute without rerun
- Existing Phase 1 guard behavior remains unchanged
Implementation Notes
• Error production responsibility: each package emits structured error hints
• Aggregation responsibility: ztd-cli normalizes and writes artifact
• Keep CLI thin; core value is structured error design + message quality
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names the ztd test path, ztd-cli, and artifacts/failure/.json and .md, but no source files or tests. Start by locating the test execution entry point and CLI aggregation writer, then inspect existing structured error handling. Done means the listed JSON and Markdown artifacts, security defaults, classifications, and Phase 1 behavior are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql, typescript
- Domain
- cli, testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100