@dtlabs/ai-toolkit 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
  ## 0.1.4 (2026-07-21)
2
+ ## [0.14.1](https://github.com/dtlab-tech/ai-toolkit/compare/v0.14.0...v0.14.1) (2026-09-30)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **workflows:** make gaia-validate-feature-docs a single-pass, host-owned validator ([2721088](https://github.com/dtlab-tech/ai-toolkit/commit/27210884375c7302cfcf84433d3da3412c857cc1))
8
+ * **workflows:** single-pass, host-owned document validator ([2b606fb](https://github.com/dtlab-tech/ai-toolkit/commit/2b606fb2d0df54e244abe473ea81b613eda30537))
9
+
2
10
  ## [0.14.0](https://github.com/dtlab-tech/ai-toolkit/compare/v0.13.0...v0.14.0) (2026-09-30)
3
11
 
4
12
 
@@ -89,6 +89,13 @@ calls, parallel rejection/drain, identity mismatch, cross-project cache leakage,
89
89
  negative semantic verdict, unknown scopes, paths with spaces and explicit approval.
90
90
 
91
91
  The live paid Claude model/permission flow has not been exercised by these tests.
92
+ Document validation requires both a written Validation Report and a structured
93
+ verdict (`valid: boolean`, `findings: string[]`). The validator performs one pass;
94
+ the host owns revisions. A report or JSON in the plain-text result cannot replace
95
+ `structured_output` from `--json-schema`. Missing structured output stops the
96
+ workflow with an error naming the worker and required fields. Regression tests
97
+ cover missing/malformed verdicts, a clean verdict without a report, and a negative
98
+ verdict followed by host revision and a clean result; model responses are mocked.
92
99
  The subprocess adapter reuses FTR-018's existing qualification; no new cross-platform
93
100
  process-supervision guarantee is claimed. On Windows, the full executor test suite
94
101
  requires Git Bash ahead of the WSL launcher in PATH. User-level installations are
@@ -130,7 +130,13 @@ function createControl(options) {
130
130
  if (result.exitCode !== 0 || result.parseError || result.timedOut ||
131
131
  !result.result || result.result.is_error !== false) throw new Error('Worker failed: ' + id);
132
132
  const payload = opts.schema ? result.result.structured_output : result.result.result;
133
- if (payload == null || (typeof payload === 'string' && !payload.trim())) throw new Error('Worker returned no result: ' + id);
133
+ if (payload == null || (typeof payload === 'string' && !payload.trim())) {
134
+ if (opts.schema) {
135
+ const fields = (opts.schema.required || []).join(', ') || '(see requested schema)';
136
+ throw new Error('Worker returned no structured output: ' + id + '; expected fields: ' + fields + '. The --json-schema response must populate structured_output; a report file or plain-text result is not sufficient.');
137
+ }
138
+ throw new Error('Worker returned no result: ' + id);
139
+ }
134
140
  if (opts.schema) validateSchema(payload, opts.schema);
135
141
  const usage = result.result.usage;
136
142
  const tokens = usage && [usage.input_tokens, usage.output_tokens].every(Number.isFinite)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtlabs/ai-toolkit",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "AI Toolkit — reusable agents and procedures for developers to build AI-powered applications.",
5
5
  "files": [
6
6
  "docs/",
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: gaia-validate-feature-docs
3
- description: "Validates Requirements and Tech-Spec documents against feature.md. Triggers targeted revision of failing documents if gaps are found. Input: path to feature.md"
3
+ description: "Validates Requirements and Tech-Spec documents against feature.md. Writes a validation report and returns a structured verdict; the host owns revisions. Input: path to feature.md"
4
4
  model: haiku
5
5
  tools: Read, Glob, Grep, Write
6
6
  ---
7
7
 
8
8
  # Validate Feature Docs
9
9
 
10
- A QA agent that cross-references `feature.md` against `{PREFIX}-Requirements.md` and `{PREFIX}-Tech-Spec.md`, identifies coverage gaps, and triggers targeted revisions until full coverage is achieved.
10
+ A QA agent that cross-references `feature.md` against `{PREFIX}-Requirements.md` and `{PREFIX}-Tech-Spec.md` and identifies coverage gaps in a single validation pass. The host workflow owns revisions and the three-cycle limit. Do not dispatch other agents or revise the input documents.
11
11
 
12
12
  ---
13
13
 
@@ -18,7 +18,7 @@ A QA agent that cross-references `feature.md` against `{PREFIX}-Requirements.md`
18
18
  - `feature.md` — source of truth
19
19
  - `{PREFIX}-Requirements.md`
20
20
  - `{PREFIX}-Tech-Spec.md`
21
- 3. If either output document is missing, abort and report: "Cannot validate: `{file}` not found. Run /implement-feature first."
21
+ 3. If an input document is missing, record a finding identifying it, skip checks that require it, and complete Phases 6 and 7 with `valid: false`. Never claim full coverage when an input could not be read.
22
22
 
23
23
  ---
24
24
 
@@ -101,31 +101,21 @@ Result: ✅ Full coverage — all feature claims addressed in both documents
101
101
 
102
102
  ---
103
103
 
104
- ## Phase 5 — Revision Loop
104
+ ## Phase 5 — Return Findings to the Host
105
105
 
106
- If gaps were found, trigger targeted revisions. **Only revise the documents that have gaps** — do not touch clean documents.
106
+ Collect all remaining gaps for the host's revision loop. Do not invoke agents, edit Requirements or Tech-Spec, or run a revision loop yourself.
107
107
 
108
- ### Revision instructions
108
+ Each finding must be one string prefixed with `Requirements:` or `Tech-Spec:` to identify the affected document, followed by the exact section or claim and the missing coverage. If a gap affects both documents, emit one finding per document.
109
109
 
110
- For each document with gaps, invoke the corresponding agent with a **targeted revision prompt** that includes:
111
- 1. The path to the existing document to revise (not regenerate from scratch)
112
- 2. The exact list of gaps to address
113
- 3. The instruction to revise only the affected sections
114
-
115
- ### Revision rules
116
-
117
- - **Max iterations**: 3 revision cycles. If gaps persist after 3 rounds, write the remaining gaps to the report and stop.
118
- - **After each revision**: re-run Phase 3 on the updated document to verify gaps are resolved
119
- - **Document what changed**: after each revision, note which gaps were resolved
120
- - **Never revise a document that has no gaps** — even if the other document is being revised
110
+ Use the same remaining gaps in the report and the structured verdict. Record a gap as resolved only when the current documents demonstrate that it is resolved.
121
111
 
122
112
  ---
123
113
 
124
- ## Phase 6 — Write Validation Report (MANDATORY — your final action)
114
+ ## Phase 6 — Write Validation Report (MANDATORY — before returning the verdict)
125
115
 
126
116
  **This is not optional and not the same as the Phase 4 gap report.** The coverage report you produced in Phase 4 is on-screen text; it is NOT the deliverable. Your job is not complete until the file `{PREFIX}-Validation-Report.md` exists **on disk**. You MUST call the `Write` tool to create it — even when validation is clean and zero gaps were found. Returning a summary without having called `Write` is a failure.
127
117
 
128
- Execute this phase **last, always**, regardless of outcome. Downstream agents read this file as a hard precondition; if it is missing, the entire pipeline aborts.
118
+ Execute this phase regardless of the validation outcome, then complete Phase 7. Downstream agents read this file as a hard precondition; if it is missing, the entire pipeline aborts.
129
119
 
130
120
  Write `{PREFIX}-Validation-Report.md` in the same directory:
131
121
 
@@ -154,23 +144,36 @@ Write `{PREFIX}-Validation-Report.md` in the same directory:
154
144
 
155
145
  ---
156
146
 
157
- ## Clarification Protocol
147
+ ## Phase 7 — Structured Completion (MANDATORY — your final response)
148
+
149
+ After writing the report, return a single JSON object with exactly these fields, without Markdown fences or explanatory prose:
150
+
151
+ ```json
152
+ {"valid": true, "findings": []}
153
+ ```
154
+
155
+ For remaining gaps:
158
156
 
159
- When a gap is found but the correct resolution is ambiguous (e.g., the feature.md itself is contradictory, or a gap could be filled in multiple valid ways), **stop and ask the user** before revising. Use the `AskUserQuestion` tool to present:
157
+ ```json
158
+ {"valid": false, "findings": ["Requirements: UC-01 lacks an acceptance criterion", "Tech-Spec: POST /api/users lacks a response definition"]}
159
+ ```
160
160
 
161
- 1. A clear description of the gap and why the resolution is uncertain
162
- 2. Concrete options (2–4) representing valid ways to address it
163
- 3. **Always include** an option: "Leave as open point to discuss later" — which records the gap in the Validation Report as unresolved (not a failure) and skips revision for that item
161
+ - `valid` is a boolean: `true` only when all required inputs were read, coverage is complete, and no unresolved gaps remain.
162
+ - `findings` is an array of strings, empty only for a clean validation. Missing inputs and ambiguous claims are unresolved findings.
163
+ - When the caller supplies `--json-schema`, use the runtime's structured-output mechanism to return this object in `structured_output`. Plain-text JSON alone does not satisfy that contract.
164
+ - Both deliverables are required: the report on disk **and** the structured verdict. Writing the report does not finish the task.
165
+
166
+ ## Clarification Protocol
164
167
 
165
- Do NOT guess how to fill ambiguous gaps. Ask first, then revise only with a clear direction.
168
+ If a claim is contradictory or its correct resolution is ambiguous, do not guess or request interactive input inside this worker. Describe the ambiguity in the report and the affected document's finding, with `valid: false`, so the calling orchestration can surface it to the user. An open point must not be treated as clean coverage.
166
169
 
167
170
  ---
168
171
 
169
172
  ## Guidelines
170
173
 
171
- - **Always call `Write` for the Validation Report before finishing** (Phase 6) — the on-screen gap report is not the deliverable; the file on disk is. This is your last action, clean or not.
172
- - **Do not regenerate documents from scratch** — targeted revisions only
174
+ - **Always call `Write` for the Validation Report before returning the structured verdict** (Phases 6 and 7), clean or not.
175
+ - **Validate only** — the host owns document revisions and agent dispatch
173
176
  - **Be specific about gaps** — point to the exact section, claim, and what is missing
174
- - **Stop after 3 revision cycles** — if coverage is still incomplete, report remaining gaps and exit
177
+ - **Perform one validation pass per invocation** — return remaining gaps to the host
175
178
  - **Out-of-scope items are also validated** — ensure they are not accidentally included in outputs
176
179
  - **Traceability is mandatory** — every Use Case ID in Requirements must appear in Tech-Spec