ontoref/reflection/modes/coder-workflow.ncl
Jesús Pérez 13b03d6edf
Some checks failed
Nickel Type Check / Nickel Type Checking (push) Has been cancelled
Rust CI / Security Audit (push) Has been cancelled
Rust CI / Check + Test + Lint (nightly) (push) Has been cancelled
Rust CI / Check + Test + Lint (stable) (push) Has been cancelled
feat: mode guards, convergence, manifest coverage, doc authoring pattern
## 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.
2026-03-30 19:08:25 +01:00

106 lines
4.8 KiB
Plaintext

let d = import "../defaults.ncl" in
let ncl_export = import "../templates/step-nickel-export.ncl" in
d.make_mode String {
id = "coder-workflow",
trigger = "Manage .coder/ process memory — initialize authors, record structured entries, triage markdown, publish and graduate knowledge",
preconditions = [
"ONTOREF_PROJECT_ROOT is set",
"reflection/modules/coder.nu is accessible via ONTOREF_ROOT",
"Nushell >= 0.110.0 is available",
],
guards = [
{
id = "coder-dir-exists",
cmd = "test -d .coder",
reason = "No .coder/ directory — run coder init first.",
severity = 'Block,
},
],
steps = [
{
id = "init-author",
action = "Initialize an author workspace with inbox/ and author.ncl. Each human, agent, or CI actor gets their own workspace.",
cmd = "./ontoref coder init <author> --actor Human|AgentClaude|AgentCustom|CI",
actor = 'Both,
on_error = { strategy = 'Stop },
},
{
id = "record-json",
action = "Write a structured JSON entry to entries.jsonl. Use for insights, summaries, completed features, decisions. Entries are immediately queryable via coder log.",
cmd = "./ontoref coder record <author> '<content>' --title '<title>' --kind info --category insights --tags '[tag1,tag2]' --relates_to '[nodo-id]' --trigger '<why>' --domain Architecture",
actor = 'Both,
depends_on = [{ step = "init-author" }],
on_error = { strategy = 'Continue },
},
{
id = "dump-markdown",
action = "Copy or paste markdown files into .coder/<author>/inbox/. Zero ceremony — just dump. Files are named YYYY-MM-DD-description.{kind}.md where kind is done|plan|info|review|audit|commit.",
actor = 'Human,
depends_on = [{ step = "init-author" }],
on_error = { strategy = 'Continue },
},
{
id = "triage",
action = "Classify inbox/ files into categories (insights, features, bugfixes, investigations, decisions, reviews, resources). Generates companion NCL with validated metadata. Use --interactive for manual review.",
cmd = "./ontoref coder triage <author> --interactive",
actor = 'Both,
depends_on = [{ step = "dump-markdown" }],
on_error = { strategy = 'Continue },
},
{
id = "query",
action = "Query JSONL entries across authors and categories. Filter by tag, kind, domain, or author. Export as JSON, JSONL, or CSV for external tools.",
cmd = "./ontoref coder log --author <author> --tag <tag> --domain <domain>",
actor = 'Both,
depends_on = [{ step = "record-json" }],
on_error = { strategy = 'Continue },
},
{
id = "novelty-check",
action = "Compare pending entries against published entries and QA store. Flags entries with >60% Jaccard overlap as REDUNDANT (potential slop). SIMILAR entries (42-60%) get warnings. NOVEL entries pass. Prevents promoting content that duplicates existing knowledge.",
cmd = "./ontoref coder novelty-check <author>",
actor = 'Both,
depends_on = [{ step = "triage" }],
on_error = { strategy = 'Continue },
note = "Anti-slop guard: entries flagged REDUNDANT should be reviewed before publish. High overlap means the knowledge already exists in the project.",
},
{
id = "publish",
action = "Promote entries from an author workspace to .coder/general/<category>/. Files are prefixed with author name for attribution.",
cmd = "./ontoref coder publish <author> <category>",
actor = 'Human,
depends_on = [{ step = "novelty-check" }],
on_error = { strategy = 'Continue },
},
{
id = "graduate",
action = "Copy graduated entries from .coder/ to a committed path (reflection/knowledge/). Only categories marked graduable=true in context.ncl are eligible.",
cmd = "./ontoref coder graduate general/insights --target reflection/knowledge",
actor = 'Human,
depends_on = [{ step = "publish" }],
on_error = { strategy = 'Stop },
},
ncl_export {
id = "validate-ontology-core",
action = "After creating new systems or schemas, register them in .ontology/core.ncl with artifact_paths. Validate core.ncl exports without contract errors.",
file = ".ontology/core.ncl",
},
ncl_export {
id = "validate-ontology-state",
action = "Update state.ncl if maturity changed. Validate state.ncl exports without contract errors.",
file = ".ontology/state.ncl",
depends_on = [{ step = "validate-ontology-core" }],
},
],
postconditions = [
"coder authors lists all active author workspaces",
"coder log returns queryable structured entries",
"New systems have nodes in .ontology/core.ncl with artifact_paths",
],
}