feat: API catalog surface, protocol v2 tooling, MCP expansion, on+re update
## Summary
Session 2026-03-23. Closes the loop between handler code and discoverability
across all three surfaces (browser, CLI, MCP agent) via compile-time inventory
registration. Adds protocol v2 update tooling, extends MCP from 21 to 29 tools,
and brings the self-description up to date.
## API Catalog Surface (#[onto_api] proc-macro)
- crates/ontoref-derive: new proc-macro crate; `#[onto_api(method, path,
description, auth, actors, params, tags)]` emits `inventory::submit!(ApiRouteEntry{...})`
at link time
- crates/ontoref-daemon/src/api_catalog.rs: `catalog()` — pure fn over
`inventory::iter::<ApiRouteEntry>()`, zero runtime allocation
- GET /api/catalog: returns full annotated HTTP surface as JSON
- templates/pages/api_catalog.html: new page with client-side filtering by
method, auth, path/description; detail panel per route (params table,
feature flag); linked from dashboard card and nav
- UI nav: "API" link (</> icon) added to mobile dropdown and desktop bar
- inventory = "0.3" added to workspace.dependencies (MIT, zero transitive deps)
## Protocol Update Mode
- reflection/modes/update_ontoref.ncl: 9-step DAG (5 detect parallel, 2 update
idempotent, 2 validate, 1 report) — brings any project from protocol v1 to v2
by adding manifest.ncl and connections.ncl if absent, scanning ADRs for
deprecated check_hint, validating with nickel export
- reflection/templates/update-ontology-prompt.md: 8-phase reusable prompt for
agent-driven ontology enrichment (infrastructure → audit → core.ncl →
state.ncl → manifest.ncl → connections.ncl → ADR migration → validation)
## CLI — describe group extensions
- reflection/bin/ontoref.nu: `describe diff [--fmt] [--file]` and
`describe api [--actor] [--tag] [--auth] [--fmt]` registered as canonical
subcommands with log-action; aliases `df` and `da` added; QUICK REFERENCE
and ALIASES sections updated
## MCP — two new tools (21 → 29 total)
- ontoref_api_catalog: filters catalog() output by actor/tag/auth; returns
{ routes, total } — no HTTP roundtrip, calls inventory directly
- ontoref_file_versions: reads ProjectContext.file_versions DashMap per slug;
returns BTreeMap<filename, u64> reload counters
- insert_mcp_ctx: audited and updated from 15 to 28 entries in 6 groups
- HelpTool JSON: 8 new entries (validate_adrs, validate, impact, guides,
bookmark_list, bookmark_add, api_catalog, file_versions)
- ServerHandler::get_info instructions updated to mention new tools
## Web UI — dashboard additions
- Dashboard: "API Catalog" card (9th); "Ontology File Versions" section showing
per-file reload counters from file_versions DashMap
- dashboard_mp: builds BTreeMap<String, u64> from ctx.file_versions and injects
into Tera context
## on+re update
- .ontology/core.ncl: describe-query-layer and adopt-ontoref-tooling descriptions
updated; ontoref-daemon updated ("11 pages", "29 tools", API catalog,
per-file versioning, #[onto_api]); new node api-catalog-surface (Yang/Practice)
with 3 edges; artifact_paths extended across 3 nodes
- .ontology/state.ncl: protocol-maturity blocker updated (protocol v2 complete);
self-description-coverage catalyst updated with session 2026-03-23 additions
- ADR-007: "API Surface Discoverability via #[onto_api] Proc-Macro" — Accepted
## Documentation
- README.md: crates table updated (11 pages, 29 MCP tools, ontoref-derive row);
MCP representative table expanded; API Catalog, Semantic Diff, Per-File
Versioning paragraphs added; update_ontoref onboarding section added
- CHANGELOG.md: [Unreleased] section with 4 change groups
- assets/web/src/index.html: tool counts 19→29 (EN+ES), page counts 12→11
(EN+ES), daemon description paragraph updated with API catalog + #[onto_api]
191 lines
8.9 KiB
Plaintext
191 lines
8.9 KiB
Plaintext
let s = import "../schema.ncl" in
|
|
|
|
# Mode: update_ontoref
|
|
# Brings an EXISTING ontoref-adopted project up to the current protocol version.
|
|
# All steps are idempotent — safe to run multiple times and on already-current projects.
|
|
#
|
|
# What this mode adds (if not already present):
|
|
# .ontology/manifest.ncl — content assets and template declarations (v2)
|
|
# .ontology/connections.ncl — cross-project federation addressing (v2)
|
|
#
|
|
# What this mode reports (advisory, no auto-migration):
|
|
# ADRs with deprecated check_hint field — need manual migration to typed check
|
|
# ADRs missing check field entirely — not yet validated by the daemon
|
|
#
|
|
# What this mode verifies:
|
|
# New files parse correctly under the current schema
|
|
# Daemon /api/catalog is reachable (confirms daemon has v2 capabilities)
|
|
#
|
|
# Required params (substituted in cmd via {param}):
|
|
# {project_name} — identifier for this project (kebab-case)
|
|
# {project_dir} — absolute path to the project root
|
|
# {ontoref_dir} — absolute path to the ontoref checkout
|
|
|
|
{
|
|
id = "update_ontoref",
|
|
trigger = "Bring an existing ontoref project up to the current protocol version",
|
|
|
|
preconditions = [
|
|
"{project_dir}/.ontoref/config.ncl exists (project was previously adopted)",
|
|
"{project_dir}/.ontology/core.ncl exists",
|
|
"nickel is available in PATH",
|
|
"nu is available in PATH (>= 0.110.0)",
|
|
"{ontoref_dir}/templates/ontology/manifest.ncl exists",
|
|
"{ontoref_dir}/templates/ontology/connections.ncl exists",
|
|
],
|
|
|
|
steps = [
|
|
|
|
# ── DETECT (all parallel, Continue — detection never blocks) ───────────────
|
|
|
|
{
|
|
id = "detect-manifest",
|
|
action = "Detect whether .ontology/manifest.ncl is present",
|
|
actor = 'Agent,
|
|
cmd = "test -f {project_dir}/.ontology/manifest.ncl && echo 'present' || echo 'missing'",
|
|
depends_on = [],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Detection only — result informs add-manifest step.",
|
|
},
|
|
|
|
{
|
|
id = "detect-connections",
|
|
action = "Detect whether .ontology/connections.ncl is present",
|
|
actor = 'Agent,
|
|
cmd = "test -f {project_dir}/.ontology/connections.ncl && echo 'present' || echo 'missing'",
|
|
depends_on = [],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Detection only — result informs add-connections step.",
|
|
},
|
|
|
|
{
|
|
id = "detect-adr-hints",
|
|
action = "Scan ADRs for deprecated check_hint field",
|
|
actor = 'Agent,
|
|
cmd = "grep -rl 'check_hint' {project_dir}/adrs/ 2>/dev/null && echo 'MIGRATION NEEDED: check_hint found' || echo 'ok: no check_hint found'",
|
|
depends_on = [],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Advisory scan. ADRs using check_hint need manual migration to the typed check field.",
|
|
},
|
|
|
|
{
|
|
id = "detect-adr-no-check",
|
|
action = "Scan ADRs for constraints missing typed check entirely",
|
|
actor = 'Agent,
|
|
cmd = "grep -rL 'check =' {project_dir}/adrs/adr-*.ncl 2>/dev/null | head -20 || echo 'all ADRs have check field'",
|
|
depends_on = [],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Advisory scan. ADRs without check are not validated by the daemon's /validate/adrs endpoint.",
|
|
},
|
|
|
|
{
|
|
id = "detect-daemon-api",
|
|
action = "Check whether daemon exposes /api/catalog (v2 capability)",
|
|
actor = 'Agent,
|
|
cmd = "curl -sf ${ONTOREF_DAEMON_URL:-http://127.0.0.1:7891}/api/catalog > /dev/null && echo 'daemon: v2 api catalog available' || echo 'daemon: not reachable or pre-v2 (start/restart the daemon)'",
|
|
depends_on = [],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Non-blocking check. Daemon must be restarted to expose new API catalog endpoint.",
|
|
},
|
|
|
|
# ── UPDATE (parallel, Continue — each is individually idempotent) ──────────
|
|
|
|
{
|
|
id = "add-manifest",
|
|
action = "Create .ontology/manifest.ncl stub if missing",
|
|
actor = 'Agent,
|
|
cmd = "test -f {project_dir}/.ontology/manifest.ncl || sed 's/{{ project_name }}/{project_name}/g' {ontoref_dir}/templates/ontology/manifest.ncl > {project_dir}/.ontology/manifest.ncl",
|
|
depends_on = [{ step = "detect-manifest", kind = 'Always }],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Adds content asset and template declarations. Skipped if file already exists.",
|
|
},
|
|
|
|
{
|
|
id = "add-connections",
|
|
action = "Create .ontology/connections.ncl stub if missing",
|
|
actor = 'Agent,
|
|
cmd = "test -f {project_dir}/.ontology/connections.ncl || sed 's/{{ project_name }}/{project_name}/g' {ontoref_dir}/templates/ontology/connections.ncl > {project_dir}/.ontology/connections.ncl",
|
|
depends_on = [{ step = "detect-connections", kind = 'Always }],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Adds cross-project federation stub. Skipped if file already exists.",
|
|
},
|
|
|
|
# ── VALIDATE (depends on updates, Continue — partial success is still progress) ──
|
|
|
|
{
|
|
id = "validate-manifest",
|
|
action = "Nickel typecheck .ontology/manifest.ncl",
|
|
actor = 'Agent,
|
|
cmd = "cd {project_dir} && nickel export --import-path {ontoref_dir}/ontology:{ontoref_dir}/ontology/schemas:{ontoref_dir}/ontology/defaults:{ontoref_dir} .ontology/manifest.ncl > /dev/null",
|
|
depends_on = [{ step = "add-manifest", kind = 'OnSuccess }],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Confirms manifest.ncl parses under the current content schema.",
|
|
},
|
|
|
|
{
|
|
id = "validate-connections",
|
|
action = "Nickel typecheck .ontology/connections.ncl",
|
|
actor = 'Agent,
|
|
cmd = "cd {project_dir} && nickel export --import-path {ontoref_dir}/reflection/schemas:{ontoref_dir} .ontology/connections.ncl > /dev/null",
|
|
depends_on = [{ step = "add-connections", kind = 'OnSuccess }],
|
|
on_error = { strategy = 'Continue },
|
|
note = "Confirms connections.ncl parses under the connections schema.",
|
|
},
|
|
|
|
# ── REPORT (aggregate — depends on all previous steps) ────────────────────
|
|
|
|
{
|
|
id = "report",
|
|
action = "Print protocol update summary",
|
|
actor = 'Both,
|
|
cmd = "nu -c '
|
|
print \"\"
|
|
print $\"(ansi white_bold)ontoref protocol update — {project_name}(ansi reset)\"
|
|
print \"\"
|
|
|
|
let has_manifest = (\"{project_dir}/.ontology/manifest.ncl\" | path exists)
|
|
let has_connections = (\"{project_dir}/.ontology/connections.ncl\" | path exists)
|
|
|
|
print $\" manifest.ncl (if $has_manifest { \"(ansi green)✓(ansi reset)\" } else { \"(ansi red)✗(ansi reset)\" })\"
|
|
print $\" connections.ncl (if $has_connections { \"(ansi green)✓(ansi reset)\" } else { \"(ansi red)✗(ansi reset)\" })\"
|
|
|
|
let hint_scan = (do { ^grep -rl check_hint {project_dir}/adrs/ } | complete)
|
|
let hint_files = if $hint_scan.exit_code == 0 { $hint_scan.stdout | str trim | lines | where { |l| $l | is-not-empty } } else { [] }
|
|
if ($hint_files | is-not-empty) {
|
|
print \"\"
|
|
print $\" (ansi yellow_bold)ADR migration needed(ansi reset) — check_hint is deprecated; migrate to typed check field:\"
|
|
for f in $hint_files { print $\" (ansi yellow)($f)(ansi reset)\" }
|
|
print \" See: adrs/adr-schema.ncl for the typed check ADT\"
|
|
} else {
|
|
print $\" ADR check fields (ansi green)✓ up to date(ansi reset)\"
|
|
}
|
|
|
|
print \"\"
|
|
print \" New capabilities (daemon must be running):\"
|
|
print \" GET /api/catalog — full annotated API surface\"
|
|
print \" GET /describe/guides — actor-aware operational context\"
|
|
print \" GET /graph/impact?include_external=true — cross-project BFS\"
|
|
print \" GET /projects/{slug}/ontology/versions — per-file change counters\"
|
|
print \" describe api — Nu command for API surface\"
|
|
print \" describe diff — semantic ontology diff vs HEAD\"
|
|
print \"\"
|
|
'",
|
|
depends_on = [
|
|
{ step = "validate-manifest", kind = 'Always },
|
|
{ step = "validate-connections", kind = 'Always },
|
|
{ step = "detect-adr-hints", kind = 'Always },
|
|
{ step = "detect-daemon-api", kind = 'Always },
|
|
],
|
|
on_error = { strategy = 'Stop },
|
|
},
|
|
|
|
],
|
|
|
|
postconditions = [
|
|
"{project_dir}/.ontology/manifest.ncl exists and parses",
|
|
"{project_dir}/.ontology/connections.ncl exists and parses",
|
|
"Report printed: ADR migration status, daemon capability checklist",
|
|
"No existing files were overwritten",
|
|
],
|
|
} | (s.Mode String)
|