Skip to content

refactor: extract shared utilities from duplicated patterns#4

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1782480086-refactor-shared-utilities
Open

refactor: extract shared utilities from duplicated patterns#4
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1782480086-refactor-shared-utilities

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 26, 2026

Copy link
Copy Markdown

Summary

The non-adoption boundary rules, adoption requirements, and protocol metadata were duplicated across README.md, spec/non_adoption_boundary.md, ontology/graphite.yaml, protocol/envelope.schema.json, and spec/graphite.protocol.md — with content drift already present (e.g. README used "use" where YAML says "invoke").

New lib/ modules make ontology/graphite.yaml and envelope.schema.json the single programmatic source of truth:

lib/paths.mjs      — rootDir resolution
lib/meta.mjs       — loadMeta(), getStatus(), getAdoption(), getNonAdoptionBoundary()
                      reads and caches ontology/graphite.yaml via `yaml` package
lib/envelope.mjs   — createEnvelope({ kind, payload, gate }), validateEnvelope(obj)
                      reads protocol/envelope.schema.json; validates required fields, types, patterns
lib/boundary.mjs   — checkBoundary(), isAdopted(), getBoundaryRules()
                      delegates to meta.mjs; returns { enforced, status, rules }
lib/index.mjs      — barrel re-export

scripts/check.mjs now uses the shared lib instead of only checking file existence — it also validates meta loading, boundary rules, and envelope creation/validation.

New scripts/validate-consistency.mjs (npm run validate) detects cross-file drift:

  • package.json version ↔ ontology status
  • README boundary rules ↔ YAML non_adoption_boundary
  • spec/non_adoption_boundary.md ↔ YAML non_adoption_boundary
  • spec/adoption_gate.md ↔ YAML adoption.requires_signed_decision
  • spec/graphite.protocol.md protocol prefix ↔ envelope.schema.json pattern

Fixed 3 existing drifts found by the validator:

  • README: "use" → "invoke" to match YAML
  • spec/non_adoption_boundary.md: added the 3 YAML boundary rules that were missing from the "Do not use" block

CI: added npm ci step to workflow since the project now has a runtime dependency (yaml).

Link to Devin session: https://app.devin.ai/sessions/a98b817d59c748e1b0e6949367039970
Requested by: @cemphlvn

- lib/paths.mjs: shared root directory resolution
- lib/meta.mjs: single source of truth from ontology/graphite.yaml
- lib/envelope.mjs: envelope creation and validation from schema
- lib/boundary.mjs: non-adoption boundary checks from meta
- lib/index.mjs: barrel export

- Refactored scripts/check.mjs to use shared lib (meta, boundary, envelope)
- Added scripts/validate-consistency.mjs to detect cross-file drift
- Fixed content drift: README and boundary spec now aligned with YAML
- Added yaml dependency for ontology parsing
- Added .gitignore for node_modules

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cemphlvn cemphlvn self-assigned this Jun 26, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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