Skip to content

fix(skills): validate project metadata at build time#488

Open
Sk-Azraf-Sami wants to merge 1 commit into
Egonex-AI:mainfrom
Sk-Azraf-Sami:fix/validate-project-metadata
Open

fix(skills): validate project metadata at build time#488
Sk-Azraf-Sami wants to merge 1 commit into
Egonex-AI:mainfrom
Sk-Azraf-Sami:fix/validate-project-metadata

Conversation

@Sk-Azraf-Sami

Copy link
Copy Markdown

Summary

The default (no --review) Phase 6 graph validator in /understand only checked nodes, edges, layers, and tour — it never validated graph.project. A graph missing a required project field (in my case description) passed the build clean ("0 issues"), but the dashboard rejected it on load with "Missing or invalid project metadata", because the dashboard runs the stricter ProjectMetaSchema (packages/core/src/schema.ts) which treats missing project metadata as fatal. So the build-time validator was a weaker subset of the load-time one — and the exact field the dashboard requires was the field the build never checked.

This PR closes that gap and hardens the assembly step:

  • Extract the inline ua-inline-validate.cjs that SKILL.md wrote to the project tmp dir on every run into a bundled skills/understand/validate-graph.mjs (same pattern as the earlier generate-ignore.mjs extraction in a0155c5), preserving its exact { issues, warnings, stats } output contract so Phase 6 step 5 and the Phase 7 report are unchanged.
  • Add a graph.project check to the validator covering the six required fields (name, description, languages, frameworks, analyzedAt, gitCommitHash), mirroring ProjectMetaSchema. A graph that would be rejected on dashboard load is now flagged at build time.
  • Clarify the Phase 6 assembly instructions: project fields come from scan-result.json's literal name/description keys (not projectName/projectDescription), and step 5 now repopulates them on failure instead of shipping invalid metadata.

Linked issue(s)

How I tested this

  • Reproduced the original failure: a knowledge graph with project.description dropped passes the old inline validator but the dashboard shows "Missing or invalid project metadata". With this change, validate-graph.mjs reports the issue at build time.

  • Added tests/skill/understand/test_validate_graph.test.mjs (10 cases): valid graph passes; missing / empty-string / missing-object / non-array project fields each flagged; regression coverage for dangling edges, file-node-not-in-layer, node-in-multiple-layers, orphan warning, and malformed-JSON exit.

  • pnpm lint

  • pnpm --filter @understand-anything/core test (753 passed)

  • pnpm test (217 passed, incl. the 10 new cases)

  • Manual smoke test (described above)

Versioning

  • Version bumped in all five manifests (2.8.1 → 2.8.2) — user-visible behavior change in /understand validation
  • N/A — internal/docs-only change

🤖 Generated with Claude Code

The default (no --review) Phase 6 validator only checked nodes, edges,
layers, and tour — never graph.project. A graph missing a required
project field (e.g. description) passed the build clean, but the
dashboard rejected it on load with "Missing or invalid project
metadata" (ProjectMetaSchema in packages/core/src/schema.ts).

- Extract the inline ua-inline-validate.cjs from SKILL.md into a bundled
  validate-graph.mjs (mirrors the generate-ignore.mjs extraction),
  preserving its {issues, warnings, stats} output contract.
- Add a graph.project check covering the six required fields (name,
  description, languages, frameworks, analyzedAt, gitCommitHash), so a
  graph that would be rejected on dashboard load is now caught at build
  time.
- Clarify Phase 6 assembly that project fields come from scan-result's
  name/description keys, and have step 5 repopulate them on failure.
- Add test_validate_graph.test.mjs (10 cases).

Bump 2.8.1 -> 2.8.2.
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.

1 participant