@lamentis/naome 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/Cargo.lock +2 -2
  2. package/README.md +11 -2
  3. package/bin/naome.js +62 -24
  4. package/crates/naome-cli/Cargo.toml +1 -1
  5. package/crates/naome-cli/src/context_commands.rs +47 -0
  6. package/crates/naome-cli/src/dispatcher.rs +6 -0
  7. package/crates/naome-cli/src/main.rs +43 -6
  8. package/crates/naome-cli/src/quality_commands.rs +31 -46
  9. package/crates/naome-cli/src/quality_output.rs +34 -0
  10. package/crates/naome-cli/src/quality_reconcile_command.rs +45 -0
  11. package/crates/naome-cli/src/repository_model_commands.rs +84 -0
  12. package/crates/naome-cli/src/task_commands.rs +62 -0
  13. package/crates/naome-cli/src/workflow_commands.rs +100 -3
  14. package/crates/naome-core/Cargo.toml +1 -1
  15. package/crates/naome-core/src/context/helpers.rs +75 -0
  16. package/crates/naome-core/src/context/select.rs +134 -0
  17. package/crates/naome-core/src/context/types.rs +43 -0
  18. package/crates/naome-core/src/context.rs +6 -0
  19. package/crates/naome-core/src/decision/states.rs +1 -1
  20. package/crates/naome-core/src/decision.rs +4 -1
  21. package/crates/naome-core/src/install_plan.rs +18 -0
  22. package/crates/naome-core/src/intent/resolver_catalog/active.rs +38 -0
  23. package/crates/naome-core/src/intent/resolver_catalog/baseline.rs +44 -0
  24. package/crates/naome-core/src/intent/resolver_catalog/completed.rs +56 -0
  25. package/crates/naome-core/src/intent/resolver_catalog/dirty.rs +32 -0
  26. package/crates/naome-core/src/intent/resolver_catalog/ready.rs +32 -0
  27. package/crates/naome-core/src/intent/resolver_catalog/system.rs +20 -0
  28. package/crates/naome-core/src/intent/resolver_catalog.rs +12 -166
  29. package/crates/naome-core/src/journal.rs +2 -7
  30. package/crates/naome-core/src/lib.rs +33 -10
  31. package/crates/naome-core/src/quality/adapter_ios.rs +131 -0
  32. package/crates/naome-core/src/quality/adapter_support.rs +67 -0
  33. package/crates/naome-core/src/quality/adapters.rs +81 -18
  34. package/crates/naome-core/src/quality/cache.rs +7 -9
  35. package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +4 -7
  36. package/crates/naome-core/src/quality/config.rs +21 -3
  37. package/crates/naome-core/src/quality/mod.rs +138 -7
  38. package/crates/naome-core/src/quality/reconcile.rs +138 -0
  39. package/crates/naome-core/src/quality/reconcile_anchors.rs +64 -0
  40. package/crates/naome-core/src/quality/scanner/analysis.rs +20 -5
  41. package/crates/naome-core/src/quality/scanner.rs +62 -17
  42. package/crates/naome-core/src/quality/semantic/checks.rs +17 -0
  43. package/crates/naome-core/src/quality/semantic/route.rs +1 -1
  44. package/crates/naome-core/src/quality/structure/adapter_ios.rs +149 -0
  45. package/crates/naome-core/src/quality/structure/adapters.rs +60 -42
  46. package/crates/naome-core/src/quality/structure/checks/directory.rs +6 -4
  47. package/crates/naome-core/src/quality/structure/classify/roles.rs +51 -5
  48. package/crates/naome-core/src/quality/structure/config.rs +24 -3
  49. package/crates/naome-core/src/quality/structure/mod.rs +3 -0
  50. package/crates/naome-core/src/quality/types.rs +20 -1
  51. package/crates/naome-core/src/repository_model/detect.rs +188 -0
  52. package/crates/naome-core/src/repository_model/explain.rs +121 -0
  53. package/crates/naome-core/src/repository_model/path_scan.rs +67 -0
  54. package/crates/naome-core/src/repository_model/path_support.rs +59 -0
  55. package/crates/naome-core/src/repository_model/types.rs +152 -0
  56. package/crates/naome-core/src/repository_model/world.rs +48 -0
  57. package/crates/naome-core/src/repository_model/world_adapters.rs +145 -0
  58. package/crates/naome-core/src/repository_model/world_path_facts.rs +55 -0
  59. package/crates/naome-core/src/repository_model/world_paths.rs +168 -0
  60. package/crates/naome-core/src/repository_model.rs +164 -0
  61. package/crates/naome-core/src/route/builtin_checks.rs +40 -1
  62. package/crates/naome-core/src/task_ledger/import.rs +142 -0
  63. package/crates/naome-core/src/task_ledger/model.rs +13 -0
  64. package/crates/naome-core/src/task_ledger/proof_record.rs +52 -0
  65. package/crates/naome-core/src/task_ledger/read.rs +118 -0
  66. package/crates/naome-core/src/task_ledger/render.rs +55 -0
  67. package/crates/naome-core/src/task_ledger/write.rs +38 -0
  68. package/crates/naome-core/src/task_ledger.rs +48 -0
  69. package/crates/naome-core/src/task_state/api.rs +4 -2
  70. package/crates/naome-core/src/task_state/completed_refresh.rs +5 -16
  71. package/crates/naome-core/src/task_state/diff.rs +2 -2
  72. package/crates/naome-core/src/task_state/evidence.rs +8 -3
  73. package/crates/naome-core/src/task_state/mod.rs +1 -1
  74. package/crates/naome-core/src/task_state/progress.rs +13 -0
  75. package/crates/naome-core/src/task_state/proof_model.rs +8 -8
  76. package/crates/naome-core/src/task_state/repair.rs +2 -2
  77. package/crates/naome-core/src/task_state/task_diff_api.rs +9 -18
  78. package/crates/naome-core/src/task_state/types.rs +24 -0
  79. package/crates/naome-core/src/verification.rs +29 -18
  80. package/crates/naome-core/src/workflow/agent/capability.rs +194 -0
  81. package/crates/naome-core/src/workflow/agent/context_delta.rs +42 -0
  82. package/crates/naome-core/src/workflow/agent/decision.rs +32 -0
  83. package/crates/naome-core/src/workflow/agent/execution.rs +80 -0
  84. package/crates/naome-core/src/workflow/agent/proof.rs +24 -0
  85. package/crates/naome-core/src/workflow/agent/support.rs +58 -0
  86. package/crates/naome-core/src/workflow/agent/watchdog.rs +47 -0
  87. package/crates/naome-core/src/workflow/agent.rs +34 -0
  88. package/crates/naome-core/src/workflow/agent_types.rs +105 -0
  89. package/crates/naome-core/src/workflow/doctor.rs +39 -0
  90. package/crates/naome-core/src/workflow/mod.rs +11 -0
  91. package/crates/naome-core/src/workflow/output.rs +8 -2
  92. package/crates/naome-core/src/workflow/phase_inference.rs +1 -1
  93. package/crates/naome-core/tests/context.rs +99 -0
  94. package/crates/naome-core/tests/harness_health.rs +33 -40
  95. package/crates/naome-core/tests/install_plan.rs +12 -0
  96. package/crates/naome-core/tests/quality.rs +178 -2
  97. package/crates/naome-core/tests/quality_performance.rs +39 -2
  98. package/crates/naome-core/tests/quality_structure_adapters.rs +39 -0
  99. package/crates/naome-core/tests/repo_support/mod.rs +7 -1
  100. package/crates/naome-core/tests/repo_support/verification_values.rs +148 -1
  101. package/crates/naome-core/tests/repository_model.rs +281 -0
  102. package/crates/naome-core/tests/route_user_diff.rs +49 -1
  103. package/crates/naome-core/tests/semantic_legacy.rs +72 -38
  104. package/crates/naome-core/tests/task_ledger.rs +328 -0
  105. package/crates/naome-core/tests/task_state.rs +34 -14
  106. package/crates/naome-core/tests/task_state_support/mod.rs +2 -1
  107. package/crates/naome-core/tests/task_state_support/states.rs +28 -11
  108. package/crates/naome-core/tests/verification.rs +14 -39
  109. package/crates/naome-core/tests/verification_contract.rs +6 -52
  110. package/crates/naome-core/tests/workflow_agent.rs +233 -0
  111. package/crates/naome-core/tests/workflow_agent_support/mod.rs +159 -0
  112. package/crates/naome-core/tests/workflow_doctor.rs +21 -0
  113. package/crates/naome-core/tests/workflow_integrity.rs +2 -20
  114. package/crates/naome-core/tests/workflow_support/mod.rs +59 -20
  115. package/installer/codex-hooks.js +121 -0
  116. package/installer/context.js +10 -0
  117. package/installer/filesystem.js +4 -0
  118. package/installer/flows.js +8 -4
  119. package/installer/harness-files.js +6 -0
  120. package/installer/install-plan.js +4 -0
  121. package/installer/main.js +1 -1
  122. package/installer/native.js +1 -1
  123. package/native/darwin-arm64/naome +0 -0
  124. package/native/linux-x64/naome +0 -0
  125. package/package.json +1 -1
  126. package/templates/naome-root/.codex/config.toml +2 -0
  127. package/templates/naome-root/.codex/hooks.json +70 -0
  128. package/templates/naome-root/.naome/bin/check-harness-health.js +8 -6
  129. package/templates/naome-root/.naome/bin/check-task-state.js +12 -7
  130. package/templates/naome-root/.naome/bin/codex-hook-io.js +122 -0
  131. package/templates/naome-root/.naome/bin/codex-hook-policy.js +180 -0
  132. package/templates/naome-root/.naome/bin/codex-hook-runtime.js +174 -0
  133. package/templates/naome-root/.naome/bin/codex-hook.js +6 -0
  134. package/templates/naome-root/.naome/bin/naome.js +35 -4
  135. package/templates/naome-root/.naome/manifest.json +12 -6
  136. package/templates/naome-root/.naome/repository-model.json +6 -0
  137. package/templates/naome-root/.naome/repository-quality.json +3 -1
  138. package/templates/naome-root/.naome/verification.json +15 -1
  139. package/templates/naome-root/AGENTS.md +38 -83
  140. package/templates/naome-root/docs/naome/agent-workflow.md +54 -18
  141. package/templates/naome-root/docs/naome/codex-hooks.md +82 -0
  142. package/templates/naome-root/docs/naome/context-economy.md +73 -0
  143. package/templates/naome-root/docs/naome/first-run.md +25 -14
  144. package/templates/naome-root/docs/naome/index.md +18 -10
  145. package/templates/naome-root/docs/naome/repository-model.md +92 -0
  146. package/templates/naome-root/docs/naome/repository-quality.md +47 -7
  147. package/templates/naome-root/docs/naome/repository-structure.md +10 -3
  148. package/templates/naome-root/docs/naome/task-ledger.md +71 -0
  149. package/templates/naome-root/docs/naome/testing.md +16 -3
@@ -0,0 +1,82 @@
1
+ # Optional Codex Hooks
2
+
3
+ NAOME can install repo-local Codex hooks as an optional acceleration layer for coding agents.
4
+
5
+ Hooks are not the source of truth. They provide earlier feedback before an agent spends tokens on work that normal NAOME gates would reject later.
6
+
7
+ Authoritative enforcement remains in:
8
+
9
+ - `.naome/task-state.json` validation
10
+ - `naome route`
11
+ - `naome quality` and `naome semantic` gates
12
+ - `naome commit`
13
+ - repository Git hooks
14
+ - verification proof checks
15
+
16
+ ## Install Or Skip
17
+
18
+ `naome install` and `naome sync` may ask whether to install optional Codex hooks.
19
+
20
+ Answering no is valid. The repository remains fully usable for humans, CI, and agents without Codex hook support.
21
+
22
+ For non-interactive environments, NAOME skips optional hooks unless explicitly requested:
23
+
24
+ ```sh
25
+ NAOME_CODEX_HOOKS=1 naome sync
26
+ NAOME_CODEX_HOOKS=0 naome sync
27
+ ```
28
+
29
+ ## Events
30
+
31
+ The installed dispatcher listens to these Codex events:
32
+
33
+ - `UserPromptSubmit`: performs read-only prompt classification and repo/task inspection. Codex Desktop currently accepts no non-blocking warning decision here, so advisory output is intentionally silent.
34
+ - `PreToolUse`: blocks clear unsafe commands before execution, including destructive Git operations, hook bypasses, force pushes, `.naome/archive` reads, `.naomeignore` reads, and broad searches that do not honor NAOME search boundaries. It also runs commit/push preflight checks.
35
+ - `PostToolUse`: after edits, records changed-file state, narrows checks to files touched by the current tool call when Codex provides a path, compares those files with active task ownership, checks repository-model freshness, and runs cheap path-scoped gates. Non-blocking edit guidance is cached for later Stop/preflight decisions rather than emitted as an unsupported warning.
36
+ - `PermissionRequest`: performs read-only escalation risk classification. Codex Desktop currently accepts no non-blocking warning decision here, so advisory output is intentionally silent.
37
+ - `Stop`: prevents misleading completion claims when scope drift, stale repository-model data, missing proof, an unpushed requested branch, or unresolved requested review comments are still visible.
38
+
39
+ ## Blocking And Advisory Checks
40
+
41
+ Hard blocks are reserved for clear safety violations:
42
+
43
+ - destructive commands such as hard resets, forced cleans, and deleting `.git`
44
+ - hook bypasses such as `--no-verify`
45
+ - force pushes, including `--force`, `--force-with-lease`, and `-f`
46
+ - reads or searches inside `.naome/archive` or paths matched by `.naomeignore`
47
+ - broad search commands that fail NAOME search-profile validation
48
+ - commit/push attempts that would skip required ownership, scope, proof, or repository-model checks
49
+ - final responses that would claim completion while required proof or scope checks are still failing
50
+
51
+ Hook output is conservative for Codex Desktop compatibility: hooks emit `{}` for allowed/advisory outcomes and emit only `{"decision":"block","reason":"..."}` for true blocks. Stable reason codes are embedded in the block reason text.
52
+
53
+ ## Edit-Time Gates
54
+
55
+ After file edits, hooks run only fast deterministic gates. When the tool input identifies touched files, PostToolUse scopes these checks to those files instead of the whole diff:
56
+
57
+ - `git diff --check -- <touched-paths>`
58
+ - `node .naome/bin/naome.js quality check --path <touched-path>`
59
+ - `node .naome/bin/naome.js semantic check --path <touched-path>`
60
+ - active-task scope checking for the touched paths
61
+
62
+ If the touched paths cannot be inferred, PostToolUse falls back to the current changed-file set. These checks are debounced by the current diff signature plus the checked path set. Repeated hook calls over the same content reuse the previous result so normal editing stays responsive.
63
+
64
+ Stop, commit, and push preflight stay full-diff checks. They verify the complete changed-file set so earlier unrelated drift or proof failures cannot be hidden by a later narrow edit.
65
+
66
+ Full suites such as installer tests, Rust builds, package dry-runs, and CI-like workflows are treated as owed proof based on changed paths. They are not run automatically after every edit because they are too slow and noisy for real-time feedback.
67
+
68
+ Every hook advisory calculation maps to a normal NAOME command or gate. If hooks are unavailable, disabled, or not installed, humans can keep working by following the normal route, context-selection, task-state, quality, semantic, verification, and commit gates directly.
69
+
70
+ ## Local Files
71
+
72
+ Opting in installs:
73
+
74
+ - `.codex/config.toml`
75
+ - `.codex/hooks.json`
76
+ - `.naome/bin/codex-hook.js`
77
+ - `.naome/bin/codex-hook-io.js`
78
+ - `.naome/bin/codex-hook-policy.js`
79
+ - `.naome/bin/codex-hook-runtime.js`
80
+ - `docs/naome/codex-hooks.md`
81
+
82
+ These files are repo-local. They are managed only after opt-in and are not required by repositories that decline hooks.
@@ -0,0 +1,73 @@
1
+ # Context Economy
2
+
3
+ NAOME reduces agent token use by selecting task context before broad reading.
4
+
5
+ ## Commands
6
+
7
+ - `node .naome/bin/naome.js workflow agent-plan --json` returns the full
8
+ deterministic run-control bundle for the current task: execution plan,
9
+ context delta, proof plan, capability graph, edit watchdog, and decision
10
+ gate.
11
+ - `node .naome/bin/naome.js context select --prompt-file <path> --json`
12
+ selects context from explicit file/path mentions in a user request.
13
+ - `node .naome/bin/naome.js context select --changed --json` selects context
14
+ from the current diff.
15
+ - `node .naome/bin/naome.js context select --prompt <text> --json` is useful
16
+ for diagnostics and small local prompts.
17
+
18
+ ## Output
19
+
20
+ The selector returns:
21
+
22
+ - `requiredContext`: read these files first.
23
+ - `optionalContext`: read only when required context is insufficient.
24
+ - `forbiddenContext`: paths that must not be used as agent context.
25
+ - `capsule`: compact task type, such as `quality-work` or `source-work`.
26
+ - `commands`: early path-scoped checks plus final changed gates.
27
+ - `budgetLedger`: selected file count, avoided file count, estimated lines, and
28
+ estimated tokens.
29
+
30
+ ## Agent Rule
31
+
32
+ After routing a task, run context selection and read only `requiredContext`.
33
+ Do not read broad NAOME docs just because they exist. Use `optionalContext`
34
+ only when blocked, and prefer path-specific commands such as
35
+ `repo explain --path`, `structure explain --path`, and
36
+ `quality check --path`.
37
+
38
+ ## Run-Control Models
39
+
40
+ The agent-run plan combines seven token-saving models:
41
+
42
+ - Execution plan ledger: ordered read, edit, quality, progress, and proof
43
+ steps for the active task.
44
+ - Context delta: which already-read files are reusable, stale, or still
45
+ required.
46
+ - Proof planner: the next minimal checks in verification phase order, with
47
+ broad checks withheld until earlier gates pass.
48
+ - Output digest: stable command summaries that keep exit code, command, cwd,
49
+ relevant lines, affected paths, and artifacts without expanding full logs.
50
+ - Capability graph: machine-readable languages, build systems, adapters, roots,
51
+ and verification edges.
52
+ - Edit-session watchdog: path-scoped quality commands and scope-drift findings
53
+ for touched files.
54
+ - Decision gate: `continue`, `create_task`, `ask_human`, or `stop` with reason
55
+ codes.
56
+
57
+ Use the focused subcommands when only one model is needed:
58
+
59
+ ```text
60
+ node .naome/bin/naome.js workflow context-delta --read-path <path> --json
61
+ node .naome/bin/naome.js workflow proof-plan --json
62
+ node .naome/bin/naome.js workflow capabilities --json
63
+ node .naome/bin/naome.js workflow edit-watchdog --path <path> --json
64
+ node .naome/bin/naome.js workflow decision-gate --json
65
+ node .naome/bin/naome.js workflow digest --command <cmd> --exit-code <code> --output-file <path> --json
66
+ ```
67
+
68
+ ## Why Runs Get Faster
69
+
70
+ Agent runs become faster because fewer files are loaded, fewer long outputs are
71
+ expanded, and quality or structure issues are caught while the touched file is
72
+ still small. The final changed-file gates remain required; context selection is
73
+ an early feedback and read-boundary tool, not a replacement for verification.
@@ -30,21 +30,32 @@ context.
30
30
 
31
31
  1. Read `.naomeignore` and exclude every matched path from intake.
32
32
  2. Inspect existing repository instructions and docs, including README,
33
- contributing docs, architecture docs, agent instruction files, and CI config.
34
- 3. Detect stack, frameworks, package managers, project layout, entrypoints,
35
- test tools, lint/typecheck/build commands, and deployment hints.
36
- 4. Identify risky areas such as auth, billing, secrets, migrations, production
33
+ contributing docs, agent instruction files, and CI config.
34
+ 3. Refresh deterministic repository facts with
35
+ `naome repo model --write --json`. This records stack, package managers,
36
+ source roots, test roots, generated roots, and verification ids in
37
+ `.naome/repository-model.json`.
38
+ 4. Detect entrypoints, test tools, lint/typecheck/build commands, deployment
39
+ hints, and sensitive areas that are not yet derivable from deterministic
40
+ files.
41
+ Run `naome quality reconcile --json` after policy files exist; if detected
42
+ repository signals require missing adapters, use
43
+ `naome quality reconcile --write` so quality and structure policy match the
44
+ observed stack.
45
+ 5. Identify risky areas such as auth, billing, secrets, migrations, production
37
46
  config, customer data, generated files, or fragile inherited code.
38
- 5. Build the Proof Harness:
47
+ 6. Build the Proof Harness:
39
48
  - inspect package files, build files, Makefiles, and CI workflows
40
49
  - record real checks in `.naome/verification.json`
41
- - mirror the human-readable map in `testing.md`
50
+ - keep `testing.md` as a human-readable view, not the source of truth
42
51
  - run the fastest safe check when possible and record the result
43
52
  - preserve the JSON keys and allowed values documented below
44
- 6. Fill `repo-profile.md`, `testing.md`, `architecture.md`, and `security.md`.
45
- 7. Ask the user for critical missing product intent, forbidden zones, or
53
+ 7. Fill only the minimal human-readable notes still needed in `repo-profile.md`,
54
+ `testing.md`, `architecture.md`, and `security.md`. Do not duplicate facts
55
+ that already live in deterministic JSON.
56
+ 8. Ask the user for critical missing product intent, forbidden zones, or
46
57
  verification commands only if repository evidence is insufficient.
47
- 8. Update `.naome/init-state.json`:
58
+ 9. Update `.naome/init-state.json`:
48
59
  - use `intakeStatus: "complete"` and `initialized: true` only when the
49
60
  completion gate is satisfied
50
61
  - use `intakeStatus: "needs_user_context"` and keep `initialized: false`
@@ -57,11 +68,11 @@ context.
57
68
  Initialization is complete only when:
58
69
 
59
70
  - `repo-profile.md` describes this specific repository.
60
- - `testing.md` records at least one real verification path.
61
- - `.naome/verification.json` contains the same durable checks and change-type
62
- rules recorded in `testing.md`.
63
- - `architecture.md` describes observed structure and known or assumed
64
- boundaries.
71
+ - `.naome/repository-model.json` is current.
72
+ - `.naome/verification.json` contains durable checks and change-type rules.
73
+ - `testing.md` records a readable summary of the real verification paths.
74
+ - `architecture.md` records only structure or boundaries that are not already
75
+ represented in deterministic model or structure policy.
65
76
  - `security.md` records sensitive areas or states that none are known yet.
66
77
  - remaining unknowns are explicit.
67
78
 
@@ -13,18 +13,23 @@ for the current step.
13
13
  6. `execution.md`, before accepting or completing feature work
14
14
  7. `first-run.md`, only when `initialized` is `false`
15
15
  8. `upgrade.md`, only when upgrade `status` is `needs_agent_upgrade`
16
- 9. `repo-profile.md`
17
- 10. `architecture.md`
18
- 11. `testing.md`
16
+ 9. `.naome/repository-model.json`
17
+ 10. `context-economy.md`, when selecting task context
18
+ 11. `repository-model.md`, when stack, build, or path facts matter
19
19
  12. `.naome/verification.json`
20
- 13. `repository-quality.md`, when repository-quality checks or cleanup are relevant
21
- 14. `repository-structure.md`, when path roles or structure cleanup are relevant
22
- 15. `security.md`
23
- 16. `agent-workflow.md`
24
- 17. `decisions.md`, when changing durable project policy
20
+ 13. `repo-profile.md`, only for legacy human-readable project notes
21
+ 14. `architecture.md`, only for legacy human-readable project notes
22
+ 15. `testing.md`
23
+ 16. `repository-quality.md`, when repository-quality checks or cleanup are relevant
24
+ 17. `repository-structure.md`, when path roles or structure cleanup are relevant
25
+ 18. `security.md`
26
+ 19. `agent-workflow.md`
27
+ 20. `decisions.md`, when changing durable project policy
25
28
 
26
29
  ## Source Types
27
30
 
31
+ - Deterministic repository facts live in `.naome/repository-model.json` and are
32
+ refreshed with `naome repo model --write`.
28
33
  - Discovered facts come from repository files and commands.
29
34
  - Confirmed facts were explicitly confirmed by a human or existing
30
35
  authoritative documentation.
@@ -33,8 +38,11 @@ for the current step.
33
38
 
34
39
  ## Context Rule
35
40
 
36
- Do not load every NAOME document by default. Start from this index, then open the
37
- smallest set of files needed for the task.
41
+ Do not load every NAOME document by default. Run
42
+ `node .naome/bin/naome.js context select --prompt-file <path> --json` after
43
+ routing natural-language work, or `node .naome/bin/naome.js context select
44
+ --changed --json` for an existing diff. Read `requiredContext` first and
45
+ `optionalContext` only when blocked.
38
46
  Do not search for generic root `ARCHITECTURE.md` or `docs/index.md` files unless
39
47
  this repository's NAOME docs explicitly reference them.
40
48
 
@@ -0,0 +1,92 @@
1
+ # Repository World Model
2
+
3
+ The repository model is the deterministic source for machine-readable facts
4
+ about this repository. It keeps stack and layout facts out of free-form
5
+ Markdown so agents can make repeatable decisions.
6
+
7
+ ## Files
8
+
9
+ - `.naome/repository-model.json` stores canonical facts.
10
+ - `.naome/verification.json` stores runnable checks and change-type proof
11
+ policy.
12
+ - Repository-quality and repository-structure policy store quality adapters and
13
+ layout rules.
14
+ - Markdown documents explain workflow and summarize human context; they are not
15
+ the primary store for build, stack, or path-role facts.
16
+
17
+ ## Commands
18
+
19
+ - `naome repo model --write --json` refreshes the model from repository files.
20
+ - `naome repo check --json` verifies the committed model is current.
21
+ - `naome repo explain --path <path> --json` explains the role and language for a
22
+ path using the canonical model.
23
+
24
+ ## Facts
25
+
26
+ `naome.repository-model.v2` keeps the backward-compatible flat `facts[]` list
27
+ and adds typed world-model sections. `naome.repository-model.v1` remains
28
+ readable; new writes prefer v2.
29
+
30
+ Flat facts are deterministic records with stable ids:
31
+
32
+ - `language:<value>`
33
+ - `packageManager:<value>`
34
+ - `buildSystem:<value>`
35
+ - `sourceRoot:<path>`
36
+ - `testRoot:<path>`
37
+ - `docsRoot:<path>`
38
+ - `generatedRoot:<path>`
39
+ - `artifactRoot:<path>`
40
+ - `verificationCheck:<id>`
41
+
42
+ Each fact includes evidence paths and a source. Do not hand-edit generated facts
43
+ as normal workflow. Refresh them with the command above.
44
+
45
+ ## World Sections
46
+
47
+ The v2 model stores typed sections so agents do not need to infer repository
48
+ shape from prose:
49
+
50
+ - `languages`, `packageManagers`, and `buildSystems`
51
+ - `adapters` detected from deterministic stack signals
52
+ - `roots` for source, test, docs, generated, and artifact paths
53
+ - `entities` for packages, apps, and modules
54
+ - `pathFacts` for significant paths with role, module, entity, language, and
55
+ generated/artifact flags
56
+ - `verificationChecks` copied from `.naome/verification.json`
57
+
58
+ These sections are generic and adapter-extensible. Product defaults must not
59
+ contain repository-specific exceptions.
60
+
61
+ ## Agent Rule
62
+
63
+ When a task depends on the stack, package manager, build system, source roots,
64
+ test roots, generated roots, or verification ids, read or refresh the repository
65
+ model instead of searching broad Markdown files. If the model is stale, update it
66
+ first, then continue with the task.
67
+
68
+ For a specific path, use:
69
+
70
+ ```text
71
+ naome repo explain --path <path> --json
72
+ ```
73
+
74
+ The explanation returns the canonical role, language, module, entity, matching
75
+ facts, and evidence for that path.
76
+
77
+ ## Drift Gates
78
+
79
+ NAOME does not silently rewrite `.naome/repository-model.json` during normal
80
+ gates. Instead, stale facts are reported deterministically:
81
+
82
+ - `naome doctor --json` reports a stale repository model section.
83
+ - `node .naome/bin/check-task-state.js --progress` blocks active work until the
84
+ model is refreshed.
85
+ - `naome quality check --changed --json` emits `repository-model-stale` as a
86
+ changed-code finding.
87
+
88
+ The fix is explicit and idempotent:
89
+
90
+ ```text
91
+ naome repo model --write --json
92
+ ```
@@ -6,7 +6,17 @@ NAOME keeps legacy debt visible without blocking unrelated feature work.
6
6
 
7
7
  - `naome quality check --changed` blocks only on files changed in the current
8
8
  diff. If a legacy file is touched, that file must satisfy the configured
9
- quality rules before commit.
9
+ quality and semantic changed rules before commit.
10
+ - `naome quality check --path <path>` is the early touched-file gate. Run it
11
+ immediately after editing a file to catch file length, diff growth, function
12
+ length, top-level symbol count, same-file duplicate regions, structure
13
+ issues, and stale adapter/model policy before a large task accumulates.
14
+ Repeat `--path` for a small touched set. This is a fast local feedback gate;
15
+ the final `--changed` gate still remains required.
16
+ - `naome semantic check --changed` is also exposed as the explicit semantic
17
+ changed gate. Fresh verification profiles require it next to
18
+ `repository-quality-check`; `quality check --changed` includes the same
19
+ semantic changed findings for backward compatibility with older profiles.
10
20
  - `naome quality report` scans the repository with normal budgets and reports
11
21
  debt without failing feature work. Full repository duplicate,
12
22
  near-duplicate, and semantic grouping checks are deep-only.
@@ -33,12 +43,41 @@ Adapters are plug-and-play profiles such as `rust` or
33
43
  path rules at runtime without hard-coding a specific product repository into
34
44
  the generic template.
35
45
 
46
+ Repository stacks can change after setup. `quality check --changed` and
47
+ `quality report` compare current repository signals with committed
48
+ `enabledAdapters`; when a new stack is present but not enabled, they emit
49
+ `adapter-policy-stale`. Use `naome quality reconcile --json` to inspect the
50
+ delta and `naome quality reconcile --write` to update
51
+ `.naome/repository-quality.json` and `.naome/repository-structure.json`
52
+ deterministically. Do not hand-edit adapter lists as the normal path.
53
+
54
+ Built-in adapter detection is path/manifest based and deterministic:
55
+
56
+ - `rust`: `Cargo.toml` or `.rs` files.
57
+ - `javascript-typescript`: `package.json` or JS/TS files.
58
+ - `swift`: `Package.swift` or `.swift` files.
59
+ - `xcode`: `.xcodeproj` or `.xcworkspace` content.
60
+ - `xctest`: Swift test targets such as `Tests`, `*Tests`, or `*UITests`.
61
+ - `swiftui`: SwiftUI-style app/view paths such as `*App.swift`,
62
+ `*View.swift`, `Views`, or Preview Content.
63
+ - `ios-app-structure`: iOS app entrypoints, `Info.plist`, entitlements, or
64
+ asset catalogs.
65
+ - `swift-package`: Swift Package Manager `Sources` and `Tests` layout.
66
+ - `ios-resources`: `.xcassets`, `.strings`, `.plist`, `.storyboard`, `.xib`,
67
+ and entitlements.
68
+ - `generated-ios`: SwiftGen, Sourcery, protobuf, and `*.generated.swift`
69
+ outputs.
70
+
36
71
  Local `pathRules` are project overrides, not product defaults. They may document
37
72
  repo-specific debt or special file roles, but loosening a rule to pass a feature
38
73
  diff requires human review.
39
74
 
40
75
  The scanner has three modes:
41
76
 
77
+ - `PathScoped`: explicitly requested touched files are read fully, with the
78
+ repository path index used for path/structure context. It avoids fully
79
+ analyzing unrelated changed files, making it suitable directly after file
80
+ writes.
42
81
  - `ChangedFast`: changed files are read fully; unchanged files may contribute
43
82
  cached facts for duplicate comparison.
44
83
  - `Report`: repository-wide, budgeted debt visibility. If budgets are hit, JSON
@@ -64,29 +103,30 @@ path roles, module/layer policy, adapters, and cleanup routing.
64
103
  Agents may propose stricter repo-specific rules after inspecting the language
65
104
  and stack.
66
105
 
67
- ## Planned Semantic Cleanup
106
+ ## Semantic Cleanup
68
107
 
69
108
  Some maintainability debt is semantic rather than purely syntactic. Examples
70
109
  include inline legacy compatibility fixtures, copied config objects, stale test
71
110
  builders, hand-written schema snapshots, and helper data that should move into a
72
111
  shared factory after enough call sites accumulate.
73
112
 
74
- NAOME should detect these with a generic semantic-cleanup layer instead of
75
- hard-coding product paths or deleting compatibility fixtures opportunistically.
76
- The planned model is:
113
+ NAOME detects these with a generic semantic-cleanup layer instead of hard-coding
114
+ product paths or deleting compatibility fixtures opportunistically. The model
115
+ is:
77
116
 
78
117
  - detect repeated object shapes, schema literals, fixture builders, and config
79
118
  snapshots across changed and report-mode files;
80
119
  - classify each finding as `legacy fixture`, `duplicated fixture`,
81
120
  `schema snapshot`, `generated metadata`, or `inline builder`;
82
121
  - keep existing report-mode debt visible without blocking unrelated work;
83
- - block only changed/new semantic debt unless local policy marks it report-only;
122
+ - block changed/new semantic debt through `quality check --changed` and
123
+ `semantic check --changed`;
84
124
  - route cleanup to extract a shared fixture, builder, schema writer, or generated
85
125
  metadata refresh command;
86
126
  - preserve behavior by requiring tests before removing or consolidating legacy
87
127
  compatibility fixtures.
88
128
 
89
- The first implementation exposes this as a scout, not an auto-fixer:
129
+ Semantic cleanup is a scout and gate, not an auto-fixer:
90
130
 
91
131
  - `naome semantic report --json` runs a budgeted semantic report.
92
132
  - `naome semantic report --deep --json` runs repo-wide semantic grouping.
@@ -36,9 +36,16 @@ module location is more appropriate.
36
36
  ## Adapters
37
37
 
38
38
  The core is language-independent. Adapters add deterministic signals for stack
39
- conventions. Built-in adapters currently include `rust` and
40
- `javascript-typescript`; future adapters can add source roots, test roots,
41
- module roots, and allowed root files without changing gate behavior.
39
+ conventions. Built-in adapters currently include `rust`,
40
+ `javascript-typescript`, `swift`, `xcode`, `xctest`, `swiftui`,
41
+ `ios-app-structure`, `swift-package`, `ios-resources`, and `generated-ios`.
42
+ Future adapters can add source roots, test roots, module roots, and allowed
43
+ root files without changing gate behavior.
44
+
45
+ If the repository later adds a new stack, `quality check --changed` and
46
+ `quality report` emit `adapter-policy-stale` until
47
+ `naome quality reconcile --write` updates the committed quality and structure
48
+ policy files.
42
49
 
43
50
  ## Local Policy
44
51
 
@@ -0,0 +1,71 @@
1
+ # Task Ledger
2
+
3
+ NAOME task state is moving from one mutable aggregate file to a canonical task
4
+ ledger. The compatibility file `.naome/task-state.json` remains supported, but
5
+ new deterministic task tooling can use `.naome/tasks/` as the source of truth.
6
+
7
+ ## Layout
8
+
9
+ ```text
10
+ .naome/tasks/
11
+ active.json
12
+ <task-id>/
13
+ task.json
14
+ events.jsonl
15
+ mutations.json
16
+ proofs/
17
+ <check-id>.json
18
+ ```
19
+
20
+ - `active.json` identifies the primary task and leaves room for future
21
+ worklanes.
22
+ - `task.json` contains the stable task contract: request, prompt, admission,
23
+ allowed paths, change types, required checks, and human-review policy.
24
+ - `events.jsonl` is append-only. Status changes, blockers, and later decisions
25
+ are added as events instead of rewriting the whole task.
26
+ - `mutations.json` records touched paths and mutation ownership.
27
+ - `proofs/<check-id>.json` stores one verification result per check so parallel
28
+ checks do not rewrite the same file.
29
+
30
+ ## Compatibility
31
+
32
+ Existing `naome.task-state.v1` and `naome.task-state.v2` files remain valid. If
33
+ `.naome/tasks/active.json` exists, NAOME readers build a canonical task model
34
+ from the ledger and render a `naome.task-state.v2` projection. If no ledger is
35
+ present, readers fall back to `.naome/task-state.json`.
36
+
37
+ Use this command when an external tool needs the compatibility file refreshed:
38
+
39
+ ```text
40
+ node .naome/bin/naome.js task render-state --write --json
41
+ ```
42
+
43
+ `naome sync` automatically splits an active legacy `task-state` file into the
44
+ ledger layout. The explicit command remains available for repair or tests:
45
+
46
+ ```text
47
+ node .naome/bin/naome.js task migrate-ledger --write --json
48
+ ```
49
+
50
+ After `.naome/tasks/active.json` exists, `.naome/task-state.json` is a rendered
51
+ compatibility projection. NAOME gates reject a stale projection and report the
52
+ render command instead of accepting hand-edited aggregate state.
53
+
54
+ ## Conflict Policy
55
+
56
+ `.naome/tasks/` is NAOME control state. It is not task feature scope and is not
57
+ required as proof evidence. Gates ignore ledger control files when checking
58
+ whether product changes stay inside `allowedPaths`.
59
+
60
+ The intended long-term model is:
61
+
62
+ ```text
63
+ task spec + events + mutations + proofs + verification config
64
+ => canonical task model
65
+ => generated task-state projection
66
+ => gates / route / commit / completion
67
+ ```
68
+
69
+ This keeps old repositories backward-compatible while making future parallel
70
+ agents safer: separate agents and checks can write separate event/proof files
71
+ instead of all competing for `.naome/task-state.json`.
@@ -9,6 +9,18 @@ Status: Uninitialized
9
9
  | NAOME baseline | Built-in harness proof | See Known Checks | Seeded by installer; extend during first-run intake. |
10
10
  | Repository-specific work | Unknown | Unknown | Fill during first-run intake. |
11
11
 
12
+ ## Early Feedback
13
+
14
+ After writing or heavily editing a file, run
15
+ `node .naome/bin/naome.js quality check --path <path>` for immediate
16
+ touched-file feedback. This catches local size, symbol, duplicate, structure,
17
+ and stale-policy issues before the task grows. It does not replace the final
18
+ `repository-quality-check`; always run the changed-file gate before completion.
19
+
20
+ Optional Codex hooks can provide the same kind of early feedback during an
21
+ agent run. They are acceleration only; final proof still comes from the
22
+ commands in this document and `.naome/verification.json`.
23
+
12
24
  ## Known Checks
13
25
 
14
26
  | Check id | Command | Cwd | Cost | Last verified |
@@ -17,6 +29,7 @@ Status: Uninitialized
17
29
  | naome-harness-health | `node .naome/bin/check-harness-health.js` | `.` | fast | null |
18
30
  | naome-task-state | `node .naome/bin/check-task-state.js` | `.` | fast | null |
19
31
  | repository-quality-check | `node .naome/bin/naome.js quality check --changed` | `.` | fast | null |
32
+ | repository-semantic-check | `node .naome/bin/naome.js semantic check --changed` | `.` | fast | null |
20
33
 
21
34
  ## Verification Phases
22
35
 
@@ -57,8 +70,8 @@ phase is failing or missing.
57
70
  and 10 release gates.
58
71
  - Store long command output as a compact summary that preserves command, cwd,
59
72
  exit code, relevant lines, affected paths, and artifacts.
60
- - When intake defines change types, include `repository-quality-check` as a
61
- required check for source, structure, documentation, harness, template, and
62
- CI changes.
73
+ - When intake defines change types, include `repository-quality-check` and
74
+ `repository-semantic-check` as required checks for source, structure,
75
+ documentation, harness, template, and CI changes.
63
76
  - Before completion, select proof from the Verification Map when possible.
64
77
  - Report exact commands and results. Do not claim proof that did not run.