Skip to content

Commit c8fd5ec

Browse files
authored
[aw] Make spec-librarian reliably emit a safe output (#37321)
1 parent 51480c7 commit c8fd5ec

4 files changed

Lines changed: 16 additions & 151 deletions

File tree

.github/workflows/spec-librarian.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/spec-librarian.md

Lines changed: 9 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,23 @@ Perform a comprehensive daily audit of all Go package specifications under `pkg/
9292

9393
**🚨 MANDATORY: You MUST call either `noop` or `create_issue` before exiting, regardless of outcome.**
9494
This workflow has `strict: true` and `create-issue` as its only write safe output. If no issue is needed, call `noop` as your LAST action before finishing.
95+
Do not use background sub-agents for this workflow. Run checks directly with shell commands, keep intermediate output concise, and reserve enough time to emit a final safe output.
9596

9697
## Phase 1: Inventory All Packages and Specifications
9798

98-
Use the `coverage-checker` agent. It returns JSON with `total_packages`, `packages_with_specs`,
99-
`coverage_pct`, `all_pkgs`, `has_spec`, and `missing_specs`. Use this output for all subsequent phases.
99+
Run direct shell commands to compute `total_packages`, `packages_with_specs`,
100+
`coverage_pct`, `all_pkgs`, `has_spec`, and `missing_specs`. Use these values for all subsequent phases.
100101

101102
## Phase 2: Staleness Detection
102103

103-
Use the `staleness-detector` agent, passing the `has_spec` list from Phase 1.
104-
It returns stale packages with `spec_date`, `source_date`, `days_behind`, `undocumented_funcs`,
105-
and `phantom_funcs`.
104+
Run direct shell commands for each package in `has_spec` to detect stale specifications with
105+
`spec_date`, `source_date`, `days_behind`, `undocumented_funcs`, and `phantom_funcs`.
106106

107107
## Phase 3: Cross-Package Consistency Checks
108108

109-
Use the `consistency-checker` agent to validate import paths, naming conventions,
110-
and dependency graphs. It returns `import_issues`, `naming_issues`, and `dependency_issues`.
111-
Perform terminology consistency analysis (Check 3) yourself using the spec content
112-
collected in Phase 1.
109+
Run direct shell commands to validate import paths, naming conventions, and dependency graphs.
110+
Produce `import_issues`, `naming_issues`, and `dependency_issues`.
111+
Perform terminology consistency analysis (Check 3) using the spec content collected in Phase 1.
113112

114113
### Check 3: Terminology Consistency
115114

@@ -142,7 +141,7 @@ For each specification, assess quality on these dimensions:
142141
Call the `noop` safe-output tool:
143142

144143
```json
145-
{"noop": {"message": "All package specifications are consistent and up-to-date. Coverage: N/20 packages. No issues found."}}
144+
{"message":"All package specifications are consistent and up-to-date. Coverage: N/20 packages. No issues found."}
146145
```
147146

148147
### If issues ARE found
@@ -267,117 +266,3 @@ The following specifications are outdated:
267266
- ✅ Issue created if problems found, or noop if all is well
268267

269268
{{#runtime-import shared/noop-reminder.md}}
270-
271-
## agent: `coverage-checker`
272-
---
273-
model: small
274-
description: Lists all pkg/ packages and reports README.md coverage metrics as JSON
275-
---
276-
You are a coverage auditor for a Go repository. Your task is to enumerate all packages
277-
under `pkg/` and check which ones have a `README.md` specification file.
278-
279-
Run the following commands and collect the results:
280-
281-
```bash
282-
find pkg/* -maxdepth 0 -type d | sort
283-
```
284-
285-
```bash
286-
find pkg -name 'README.md' -type f | sort
287-
```
288-
289-
From the output, compute:
290-
- `total_packages`: count of directories under `pkg/`
291-
- `packages_with_specs`: count of `pkg/*/README.md` files found
292-
- `coverage_pct`: `packages_with_specs / total_packages * 100` (rounded to one decimal)
293-
- `all_pkgs`: sorted list of all package names (basename only)
294-
- `has_spec`: sorted list of package names that have a `README.md`
295-
- `missing_specs`: sorted list of package names that are missing a `README.md`
296-
297-
Return ONLY a JSON object with these six fields and no additional text.
298-
299-
## agent: `staleness-detector`
300-
---
301-
model: small
302-
description: Compares git timestamps for each package's source vs spec and detects API drift
303-
---
304-
You are a staleness detector for Go package specifications. You receive a list of packages
305-
that have a `README.md` (`has_spec`). For each package, determine whether its specification
306-
is stale and whether there is API drift.
307-
308-
For each package in the `has_spec` list:
309-
310-
1. Compare git timestamps:
311-
312-
```bash
313-
git log -1 --format=%ci -- pkg/<package>/README.md
314-
git log -1 --format=%ci -- "pkg/<package>/*.go"
315-
```
316-
317-
A specification is **stale** if the source was modified more than 7 days after the README.md.
318-
319-
2. Check for API drift:
320-
321-
```bash
322-
grep -h "^func [A-Z]" pkg/<package>/*.go 2>/dev/null | sed 's/(.*//' | sort
323-
grep -h "| \`[A-Z]" pkg/<package>/README.md 2>/dev/null | sort
324-
```
325-
326-
Return a JSON object with a single key `stale_packages` — an array of objects, one per stale
327-
package. Each object has:
328-
- `package`: package name
329-
- `spec_date`: ISO date of last README.md commit
330-
- `source_date`: ISO date of last source commit
331-
- `days_behind`: integer days the spec lags behind the source
332-
- `undocumented_funcs`: list of exported functions present in source but absent from spec
333-
- `phantom_funcs`: list of exported functions present in spec but absent from source
334-
335-
Return ONLY the JSON object and no additional text.
336-
337-
## agent: `consistency-checker`
338-
---
339-
model: small
340-
description: Validates import paths, naming conventions, and dependency declarations across all specs
341-
---
342-
You are a cross-package consistency checker for Go package specifications. Your task is to
343-
validate three aspects across all `pkg/*/README.md` files.
344-
345-
**Check 1 — Import Path Consistency**
346-
347-
```bash
348-
grep -rn 'github.com/github/gh-aw/pkg/' pkg --include='*.go' | grep -v _test.go
349-
```
350-
351-
For each cross-package reference found, verify:
352-
- The referenced package directory exists under `pkg/`
353-
- The import path is well-formed (no typos)
354-
355-
**Check 2 — Naming Convention Consistency**
356-
357-
For each `pkg/*/README.md`, verify:
358-
- Title line matches `# <Name> Package`
359-
- Sections present: Overview, Public API, Usage Examples
360-
- API table uses markdown table format
361-
- Footer contains attribution to spec-extractor workflow
362-
363-
**Check 4 — Dependency Graph Validation**
364-
365-
```bash
366-
for dir in $(find pkg/* -maxdepth 0 -type d | sort); do
367-
pkg=$(basename "$dir")
368-
if [ -f "$dir/README.md" ]; then
369-
echo "=== $pkg ==="
370-
grep -h "import" "$dir"/*.go 2>/dev/null | grep "gh-aw/pkg/" | sort -u
371-
fi
372-
done
373-
```
374-
375-
For each package, compare the internal imports found in source code against any dependency
376-
references documented in `README.md`.
377-
378-
Return a JSON object with three keys:
379-
- `import_issues`: list of objects with `package`, `issue` for each import path problem
380-
- `naming_issues`: list of objects with `package`, `issue` for each naming convention violation
381-
- `dependency_issues`: list of objects with `package`, `documented`, `actual` for each mismatch
382-
383-
Return ONLY the JSON object and no additional text.

pkg/actionpins/data/action_pins.json

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,10 @@
173173
"version": "v4.36.0",
174174
"sha": "7211b7c8077ea37d8641b6271f6a365a22a5fbfa"
175175
},
176-
"github/gh-aw-actions/setup-cli@v0.78.2": {
177-
"repo": "github/gh-aw-actions/setup-cli",
178-
"version": "v0.78.2",
179-
"sha": "268bf92726cb8153337c07166f382ee46e4fd897"
180-
},
181-
"github/gh-aw-actions/setup@v0.78.2": {
176+
"github/gh-aw-actions/setup@v0.76.1": {
182177
"repo": "github/gh-aw-actions/setup",
183-
"version": "v0.78.2",
184-
"sha": "268bf92726cb8153337c07166f382ee46e4fd897"
185-
},
186-
"github/gh-aw/actions/setup-cli@v0.78.2": {
187-
"repo": "github/gh-aw/actions/setup-cli",
188-
"version": "v0.78.2",
189-
"sha": "a7d4043a8224182262356a32931099b76fd332eb"
178+
"version": "v0.76.1",
179+
"sha": "46d564922b082d0db93244972e8005ea6904ee5f"
190180
},
191181
"github/stale-repos@v9.0.14": {
192182
"repo": "github/stale-repos",

pkg/workflow/data/action_pins.json

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,10 @@
173173
"version": "v4.36.0",
174174
"sha": "7211b7c8077ea37d8641b6271f6a365a22a5fbfa"
175175
},
176-
"github/gh-aw-actions/setup-cli@v0.78.2": {
177-
"repo": "github/gh-aw-actions/setup-cli",
178-
"version": "v0.78.2",
179-
"sha": "268bf92726cb8153337c07166f382ee46e4fd897"
180-
},
181-
"github/gh-aw-actions/setup@v0.78.2": {
176+
"github/gh-aw-actions/setup@v0.76.1": {
182177
"repo": "github/gh-aw-actions/setup",
183-
"version": "v0.78.2",
184-
"sha": "268bf92726cb8153337c07166f382ee46e4fd897"
185-
},
186-
"github/gh-aw/actions/setup-cli@v0.78.2": {
187-
"repo": "github/gh-aw/actions/setup-cli",
188-
"version": "v0.78.2",
189-
"sha": "a7d4043a8224182262356a32931099b76fd332eb"
178+
"version": "v0.76.1",
179+
"sha": "46d564922b082d0db93244972e8005ea6904ee5f"
190180
},
191181
"github/stale-repos@v9.0.14": {
192182
"repo": "github/stale-repos",

0 commit comments

Comments
 (0)