## 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.
119 lines
4.6 KiB
Rust
119 lines
4.6 KiB
Rust
/// A single query/path/body parameter declared on an API route.
|
|
#[derive(serde::Serialize, Clone)]
|
|
pub struct ApiParam {
|
|
pub name: &'static str,
|
|
/// Rust-like type hint: string | u32 | bool | i64 | json.
|
|
pub kind: &'static str,
|
|
/// "required" | "optional" | "default=<value>"
|
|
pub constraint: &'static str,
|
|
pub description: &'static str,
|
|
}
|
|
|
|
/// Static metadata for an HTTP endpoint.
|
|
///
|
|
/// Registered at link time via `inventory::submit!` — generated by
|
|
/// `#[onto_api(...)]` proc-macro attribute on each handler function.
|
|
/// Collected via `inventory::iter::<ApiRouteEntry>()`.
|
|
#[derive(serde::Serialize, Clone)]
|
|
pub struct ApiRouteEntry {
|
|
pub method: &'static str,
|
|
pub path: &'static str,
|
|
pub description: &'static str,
|
|
/// Authentication required: "none" | "viewer" | "bearer" | "admin"
|
|
pub auth: &'static str,
|
|
/// Which actors typically call this endpoint.
|
|
pub actors: &'static [&'static str],
|
|
pub params: &'static [ApiParam],
|
|
/// Semantic grouping tags (e.g. "graph", "federation", "describe").
|
|
pub tags: &'static [&'static str],
|
|
/// Non-empty when the endpoint is only compiled under a feature flag.
|
|
pub feature: &'static str,
|
|
/// Source file path (relative to workspace root) captured via `file!()`.
|
|
pub source_file: &'static str,
|
|
}
|
|
|
|
inventory::collect!(ApiRouteEntry);
|
|
|
|
/// Serialize all statically-registered [`ApiRouteEntry`] items to a
|
|
/// pretty-printed JSON array, sorted by path then method.
|
|
pub fn dump_catalog_json() -> String {
|
|
let mut routes: Vec<&'static ApiRouteEntry> = inventory::iter::<ApiRouteEntry>().collect();
|
|
routes.sort_by(|a, b| a.path.cmp(b.path).then(a.method.cmp(b.method)));
|
|
serde_json::to_string_pretty(&routes).unwrap_or_else(|_| "[]".to_string())
|
|
}
|
|
|
|
/// Serialize all statically-registered [`ApiRouteEntry`] items to a Nickel
|
|
/// record that imports `../reflection/schemas/api-catalog.ncl`.
|
|
///
|
|
/// The output path is `artifacts/api-catalog-{crate_name}.ncl` relative to
|
|
/// the project root. Enum tags are capitalised to match the schema contracts:
|
|
/// `"GET"` → `'GET`, `"viewer"` → `'Viewer`, `"developer"` → `'Developer`.
|
|
pub fn dump_catalog_ncl(crate_name: &str) -> String {
|
|
let mut routes: Vec<&'static ApiRouteEntry> = inventory::iter::<ApiRouteEntry>().collect();
|
|
routes.sort_by(|a, b| a.path.cmp(b.path).then(a.method.cmp(b.method)));
|
|
|
|
let routes_ncl = routes
|
|
.iter()
|
|
.map(|r| {
|
|
let actors = r
|
|
.actors
|
|
.iter()
|
|
.map(|a| format!("'{}", ncl_capitalize(a)))
|
|
.collect::<Vec<_>>()
|
|
.join(", ");
|
|
let tags = r
|
|
.tags
|
|
.iter()
|
|
.map(|t| format!("\"{}\"", ncl_escape(t)))
|
|
.collect::<Vec<_>>()
|
|
.join(", ");
|
|
let params = r
|
|
.params
|
|
.iter()
|
|
.map(|p| {
|
|
format!(
|
|
"{{ name = \"{}\", kind = \"{}\", constraint = \"{}\", description = \
|
|
\"{}\" }}",
|
|
ncl_escape(p.name),
|
|
ncl_escape(p.kind),
|
|
ncl_escape(p.constraint),
|
|
ncl_escape(p.description),
|
|
)
|
|
})
|
|
.collect::<Vec<_>>()
|
|
.join(", ");
|
|
format!(
|
|
" {{\n method = '{method},\n path = \"{path}\",\n description = \
|
|
\"{desc}\",\n auth = '{auth},\n actors = [{actors}],\n tags = \
|
|
[{tags}],\n params = [{params}],\n feature = \"{feature}\",\n \
|
|
source_file = \"{source_file}\",\n }}",
|
|
method = r.method,
|
|
path = ncl_escape(r.path),
|
|
desc = ncl_escape(r.description),
|
|
auth = ncl_capitalize(r.auth),
|
|
feature = ncl_escape(r.feature),
|
|
source_file = ncl_escape(r.source_file),
|
|
)
|
|
})
|
|
.collect::<Vec<_>>()
|
|
.join(",\n");
|
|
|
|
format!(
|
|
"let schema = import \"../reflection/schemas/api-catalog.ncl\" in\n{{\n crate = \
|
|
\"{crate_name}\",\n routes | Array schema.Route = [\n{routes_ncl}\n ],\n}} | \
|
|
schema.Catalog\n"
|
|
)
|
|
}
|
|
|
|
fn ncl_capitalize(s: &str) -> String {
|
|
let mut chars = s.chars();
|
|
match chars.next() {
|
|
None => String::new(),
|
|
Some(c) => c.to_uppercase().to_string() + chars.as_str(),
|
|
}
|
|
}
|
|
|
|
fn ncl_escape(s: &str) -> String {
|
|
s.replace('\\', "\\\\").replace('"', "\\\"")
|
|
}
|