Skip to content

feat: HC-121 — dogfooding: the real Ontology examcalc package via IR v2#30

Merged
SoundBlaster merged 6 commits into
mainfrom
feat/hc-121-dogfooding
Jun 12, 2026
Merged

feat: HC-121 — dogfooding: the real Ontology examcalc package via IR v2#30
SoundBlaster merged 6 commits into
mainfrom
feat/hc-121-dogfooding

Conversation

@SoundBlaster

Copy link
Copy Markdown
Member

First artifact of the dogfooding adoption path (stacked on #29) — the worked example of DOCS/Backends.md, made runnable against a real document.

The hand-written examcalc DomainOntologyPackage from the Ontology repo (13 classes, 8 relations, 4 policies, a 7-state machine — 240 lines of YAML) is modeled as examcalc.{hc,hcs} and regenerated by a consumer-side adapter from the emitted IR v2. CI compares the result semantically against a verbatim copy of the original:

$ python3 backend.py --check
generated DomainOntologyPackage is semantically identical to the Ontology repo original (240 lines of YAML)

What the cascade buys on a real document:

  • kind defaults (.entity/.command/Relation/Policy) carry everything the YAML restates per entry;
  • approvalStatus becomes a @stage context — approving the package is a one-node hypercode diff;
  • contracts gate a document that previously had none;
  • every derived value is explain-able to its rule.

The honest part: size parity for a single package (201 vs 212 meaningful lines) — compression starts at the second package via an @imported shared baseline (HC-116). DOCS/Dogfooding.md starts the friction log: F1 no list values in core (comma-joined strings), F2 single-typed contracts can't express int | "*", F3 synthetic ids for same-type siblings, F4 id-selector quoting noise, F5 flat property names. These feed the M9 discussion.

Remaining HC-121 scope (recorded in the workplan): the import-hypercode step inside ontologyc itself and the same exercise for a Hyperprompt configuration — both live in the consumer repos.

Train complete: #27 (HC-116) → #28 (HC-114) → #29 (HC-120) → this.

🤖 Generated with Claude Code

First artifact of the adoption path: the hand-written examcalc
DomainOntologyPackage (Ontology repo, 13 classes / 8 relations /
4 policies / 7-state machine, 240 lines of YAML) modeled as
examcalc.{hc,hcs} and regenerated by a consumer-side adapter
(backend.py) from the emitted IR v2. CI compares the result
semantically against a verbatim copy of the original — it matched on
the first complete run.

- Kind defaults via selectors (.entity/.command/...) carry what the
  YAML restates per entry; per-node rules hold only specifics.
- approvalStatus is a @stage context, not an edited field: approving
  the package is a one-node hypercode diff.
- Contracts gate a document that previously had none (card_min >= 0,
  required domain/range/text).
- All schema knowledge (envelope, key spelling, comma-joined list
  encoding) stays in the adapter — Hypercode never learns the
  ontology schema (DOCS/Backends.md rule, now demonstrated).

The honest finding: size parity for one package (201 vs 212
meaningful lines) — compression starts at the second package via an
@imported shared baseline. DOCS/Dogfooding.md starts the friction log
(F1 no list values, F2 single-typed contracts, F3 synthetic sibling
ids, F4 id-quoting noise, F5 flat property names); remaining HC-121
scope (ontologyc import step, Hyperprompt exercise) recorded in the
workplan.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Homebrew-managed system Python on macos-latest rejects
'pip install' into the global environment; a throwaway venv is the
self-contained fix (no extra action dependency).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the first “dogfooding” real-world artifact to the repo by modeling the Ontology repo’s examcalc DomainOntologyPackage as Hypercode (.hc + .hcs), emitting IR v2, and regenerating the original YAML via a consumer-side backend with a semantic equality check in CI.

Changes:

  • Introduces Examples/ontology-backend/ (spec + backend adapter + expected YAML) to round-trip a real Ontology package through IR v2.
  • Adds a dogfooding friction log (DOCS/Dogfooding.md) and updates the workplan to mark HC-121’s first artifact shipped.
  • Extends CI to run the ontology backend semantic check.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
workplan.md Updates HC-121 status/description to reflect the shipped first artifact and remaining scope.
Examples/ontology-backend/README.md Documents the runnable backend pipeline and what the example demonstrates.
Examples/ontology-backend/expected/domain-ontology-package.yaml Adds the verbatim expected Ontology package YAML for semantic comparison.
Examples/ontology-backend/examcalc.hcs Adds kind defaults, per-node rules, @stage context, and contracts for the examcalc package.
Examples/ontology-backend/examcalc.hc Adds the examcalc package topology (nodes/relationships) used to emit IR v2.
Examples/ontology-backend/backend.py Adds the consumer-side IR v2 → DomainOntologyPackage adapter and CI semantic comparer.
DOCS/Dogfooding.md Adds the HC-121 dogfooding log entry with friction items (F1–F5).
.github/workflows/swift.yml Adds a CI step to run the ontology backend --check comparison.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Examples/ontology-backend/backend.py
Comment thread Examples/ontology-backend/backend.py
Comment thread Examples/ontology-backend/backend.py
SoundBlaster and others added 4 commits June 12, 2026 21:21
…in backend.py

- subprocess decodes the emitted IR as UTF-8 explicitly (the example's
  Cyrillic source path must not depend on the process locale);
- expected-YAML read and --out write are context-managed UTF-8;
- duplicate or missing top-level package sections fail with a clear
  error instead of a silent dict overwrite and a confusing diff.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Residual-risk follow-up on #30: classes, relations, policies, state
machines and fields now insert through a guard that fails with
'malformed package: duplicate <kind>' instead of silently overwriting
the earlier entry and surfacing as a confusing semantic diff.
(Top-level sections were already strict.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@SoundBlaster SoundBlaster changed the base branch from feat/hc-120-kustomize-demo to main June 12, 2026 22:04
@SoundBlaster SoundBlaster merged commit b40a412 into main Jun 12, 2026
5 checks passed
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.

2 participants