From 13b03d6edf480a0b695de0a7d616be05cfd81947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Pe=CC=81rez?= Date: Mon, 30 Mar 2026 19:08:25 +0100 Subject: [PATCH] feat: mode guards, convergence, manifest coverage, doc authoring pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Mode guards and convergence loops (ADR-011) - `Guard` and `Converge` types added to `reflection/schema.ncl` and `reflection/defaults.ncl`. Guards run pre-flight checks (Block/Warn); converge loops iterate until a condition is met (RetryFailed/RetryAll). - `sync-ontology.ncl`: 3 guards + converge (zero-drift condition, max 2 iter). - `coder-workflow.ncl`: guard (coder-dir-exists) + `novelty-check` step. - Rust types in `ontoref-reflection/src/mode.rs`; executor in `executor.rs` evaluates guards before steps and convergence loop after. - `adrs/adr-011-mode-guards-and-convergence.ncl` added. ## Manifest capability completeness - `.ontology/manifest.ncl`: 3 → 19 declared capabilities covering the full action surface (daemon API, modes, Task Composer, QA, bookmarks, etc.). - `sync.nu`: `audit-manifest-coverage` + `sync manifest-check` command. - `validate-project.ncl`: 6th category `manifest-cov`. - Pre-commit hook `manifest-coverage` added. - Migrations `0010-manifest-capability-completeness`, `0011-manifest-coverage-hooks`. ## Rust doc authoring pattern — canonical `///` convention - `#[onto_api]`: `description = "..."` optional when `///` doc comment exists above handler — first line used as fallback. `#[derive(OntologyNode)]` same. - `ontoref-daemon/src/api.rs`: 42 handlers migrated to `///` doc comments; `description = "..."` removed from all `#[onto_api]` blocks. - `sync diff --docs --fail-on-drift`: exits 1 on crate `//!` drift; used by new `docs-drift` pre-commit hook. `docs-links` hook checks rustdoc broken links. - `generator.nu`: mdBook `crates/` chapter — per-crate page from `//!` doc, coverage badge, feature flags, implementing practice nodes. - `.claude/CLAUDE.md`: `### Documentation Authoring (Rust)` section added. - Migration `0012-rust-doc-authoring-pattern`. ## OntologyNode derive fixes - `#[derive(OntologyNode)]`: `name` and `paths` attributes supported; `///` doc fallback for `description`; `artifact_paths` correctly populated. - `Core::from_value` calls `merge_contributors()` behind `#[cfg(feature = "derive")]`. ## Bug fixes - `sync.nu` drift check: exact crate path match (not `str starts-with`); first-path-only rule; split on `. ` not `.` to avoid `.ontology/` truncation. - `find-unclaimed-artifacts`: fixed absolute vs relative path comparison. - Rustdoc broken intra-doc links fixed across all three crates. - `ci-docs` recipe now sets `RUSTDOCFLAGS` and actually fails on errors. mode guards/converge, manifest coverage validation, 19 capabilities (ADR-011) Extend the mode schema with Guard (pre-flight Block/Warn checks) and Converge (RetryFailed/RetryAll post-execution loops) — protocol pushes back on invalid state and iterates until convergence. ADR-011 records the decision to extend modes rather than create a separate action subsystem. Manifest expanded from 3 to 19 capabilities covering the full action surface (compose, plans, backlog graduation, notifications, coder pipeline, forms, templates, drift, quick actions, migrations, config, onboarding). New audit-manifest-coverage validator + pre-commit hook + SessionStart hook ensure agents always see complete project self-description. Bug fix: find-unclaimed-artifacts absolute vs relative path comparison — 19 phantom MISSING items resolved. Health 43% → 100%. Anti-slop: coder novelty-check step (Jaccard overlap against published+QA) inserted between triage and publish in coder-workflow. Justfile restructured into 5 modules (build/test/dev/ci/assets). Migrations 0010-0011 propagate requirements to consumer projects. --- .ontology/core.ncl | 23 +- .ontology/manifest.ncl | 187 +++++++++- .ontology/state.ncl | 4 +- .pre-commit-config.yaml | 24 ++ CHANGELOG.md | 125 +++++++ README.md | 32 +- adrs/adr-010-protocol-migration-system.ncl | 8 + adrs/adr-011-mode-guards-and-convergence.ncl | 113 ++++++ crates/ontoref-daemon/src/api.rs | 139 ++++---- crates/ontoref-daemon/src/lib.rs | 12 + crates/ontoref-daemon/src/sync.rs | 7 +- crates/ontoref-derive/src/lib.rs | 135 +++++-- crates/ontoref-ontology/src/api.rs | 4 +- crates/ontoref-ontology/src/contrib.rs | 3 +- crates/ontoref-ontology/src/lib.rs | 10 + crates/ontoref-ontology/src/ontology.rs | 9 +- crates/ontoref-reflection/src/executor.rs | 141 +++++++- crates/ontoref-reflection/src/lib.rs | 14 +- crates/ontoref-reflection/src/mode.rs | 46 +++ justfile | 3 + justfiles/build.just | 25 ++ justfiles/ci.just | 75 +--- justfiles/dev.just | 53 +++ justfiles/test.just | 24 ++ reflection/bin/ontoref.nu | 11 +- reflection/defaults.ncl | 2 + reflection/hooks/git-event.nu | 9 + .../0006-claude-agent-entrypoint.ncl | 26 +- .../0008-claude-ontology-context.ncl | 40 +++ .../0009-claude-session-context.ncl | 73 ++++ .../0010-manifest-capability-completeness.ncl | 39 ++ .../0011-manifest-coverage-hooks.ncl | 44 +++ .../0012-rust-doc-authoring-pattern.ncl | 80 +++++ reflection/modes/coder-workflow.ncl | 20 +- reflection/modes/sync-ontology.ncl | 42 ++- reflection/modes/validate-project.ncl | 28 +- reflection/modules/coder.nu | 120 +++++++ reflection/modules/describe.nu | 334 +++++++++++++++++- reflection/modules/generator.nu | 147 ++++++++ reflection/modules/run.nu | 13 + reflection/modules/sync.nu | 278 ++++++++++++++- reflection/nulib/modes.nu | 92 +++++ reflection/schema.ncl | 43 +++ 43 files changed, 2405 insertions(+), 252 deletions(-) create mode 100644 adrs/adr-011-mode-guards-and-convergence.ncl create mode 100644 justfiles/build.just create mode 100644 justfiles/dev.just create mode 100644 justfiles/test.just create mode 100644 reflection/migrations/0008-claude-ontology-context.ncl create mode 100644 reflection/migrations/0009-claude-session-context.ncl create mode 100644 reflection/migrations/0010-manifest-capability-completeness.ncl create mode 100644 reflection/migrations/0011-manifest-coverage-hooks.ncl create mode 100644 reflection/migrations/0012-rust-doc-authoring-pattern.ncl diff --git a/.ontology/core.ncl b/.ontology/core.ncl index 4bc5eeb..9e1dc77 100644 --- a/.ontology/core.ncl +++ b/.ontology/core.ncl @@ -83,9 +83,10 @@ let d = import "../ontology/defaults/core.ncl" in "adrs/adr-008-ncl-first-config-validation-and-override-layer.ncl", "adrs/adr-009-manifest-self-interrogation-layer-three-semantic-axes.ncl", "adrs/adr-010-protocol-migration-system.ncl", + "adrs/adr-011-mode-guards-and-convergence.ncl", "CHANGELOG.md", ], - adrs = ["adr-001", "adr-002", "adr-003", "adr-004", "adr-005", "adr-006", "adr-007", "adr-008", "adr-009", "adr-010"], + adrs = ["adr-001", "adr-002", "adr-003", "adr-004", "adr-005", "adr-006", "adr-007", "adr-008", "adr-009", "adr-010", "adr-011"], }, d.make_node { @@ -93,8 +94,8 @@ let d = import "../ontology/defaults/core.ncl" in name = "Reflection Modes", pole = 'Yang, level = 'Practice, - description = "Operational procedures are first-class artifacts encoded as NCL DAG contracts. Modes declare actors, steps, dependencies, and error strategies — not prose.", - artifact_paths = ["reflection/modes/", "reflection/schemas/", "crates/ontoref-reflection/"], + description = "Operational procedures are first-class artifacts encoded as NCL DAG contracts. Modes declare actors, steps, dependencies, and error strategies — not prose. Forms (reflection/forms/) provide structured input schemas that feed into modes and the compose pipeline.", + artifact_paths = ["reflection/modes/", "reflection/schemas/", "crates/ontoref-reflection/", "reflection/forms/"], }, d.make_node { @@ -212,7 +213,7 @@ let d = import "../ontology/defaults/core.ncl" in name = "Ontoref Daemon", pole = 'Yang, level = 'Practice, - description = "Runtime support daemon for the ontoref protocol. Provides NCL export caching, file watching, actor registry, notification barrier, HTTP API (11 pages), MCP server (29 tools, stdio + streamable-HTTP), Q&A NCL persistence, quick-actions catalog, passive drift observation, unified auth/session management, per-file ontology version counters (GET /projects/{slug}/ontology/versions), and annotated API catalog (GET /api/catalog). API catalog populated at link time via #[onto_api] proc-macro + inventory — zero runtime overhead. Launched via ADR-004 NCL pipe bootstrap: nickel export config.ncl | ontoref-daemon.bin --config-stdin. Graph, search, and api_catalog UI pages carry browser-style panel navigation (back/forward history stack). File artifact paths open in external tabs: card.repo (Gitea source URL) for most files, card.docs (cargo docs) for .rs files — no inline file loading. card_repo/card_docs injected into Tera context from insert_brand_ctx; | safe filter required for URL values inside