@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.
- package/Cargo.lock +2 -2
- package/README.md +11 -2
- package/bin/naome.js +62 -24
- package/crates/naome-cli/Cargo.toml +1 -1
- package/crates/naome-cli/src/context_commands.rs +47 -0
- package/crates/naome-cli/src/dispatcher.rs +6 -0
- package/crates/naome-cli/src/main.rs +43 -6
- package/crates/naome-cli/src/quality_commands.rs +31 -46
- package/crates/naome-cli/src/quality_output.rs +34 -0
- package/crates/naome-cli/src/quality_reconcile_command.rs +45 -0
- package/crates/naome-cli/src/repository_model_commands.rs +84 -0
- package/crates/naome-cli/src/task_commands.rs +62 -0
- package/crates/naome-cli/src/workflow_commands.rs +100 -3
- package/crates/naome-core/Cargo.toml +1 -1
- package/crates/naome-core/src/context/helpers.rs +75 -0
- package/crates/naome-core/src/context/select.rs +134 -0
- package/crates/naome-core/src/context/types.rs +43 -0
- package/crates/naome-core/src/context.rs +6 -0
- package/crates/naome-core/src/decision/states.rs +1 -1
- package/crates/naome-core/src/decision.rs +4 -1
- package/crates/naome-core/src/install_plan.rs +18 -0
- package/crates/naome-core/src/intent/resolver_catalog/active.rs +38 -0
- package/crates/naome-core/src/intent/resolver_catalog/baseline.rs +44 -0
- package/crates/naome-core/src/intent/resolver_catalog/completed.rs +56 -0
- package/crates/naome-core/src/intent/resolver_catalog/dirty.rs +32 -0
- package/crates/naome-core/src/intent/resolver_catalog/ready.rs +32 -0
- package/crates/naome-core/src/intent/resolver_catalog/system.rs +20 -0
- package/crates/naome-core/src/intent/resolver_catalog.rs +12 -166
- package/crates/naome-core/src/journal.rs +2 -7
- package/crates/naome-core/src/lib.rs +33 -10
- package/crates/naome-core/src/quality/adapter_ios.rs +131 -0
- package/crates/naome-core/src/quality/adapter_support.rs +67 -0
- package/crates/naome-core/src/quality/adapters.rs +81 -18
- package/crates/naome-core/src/quality/cache.rs +7 -9
- package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +4 -7
- package/crates/naome-core/src/quality/config.rs +21 -3
- package/crates/naome-core/src/quality/mod.rs +138 -7
- package/crates/naome-core/src/quality/reconcile.rs +138 -0
- package/crates/naome-core/src/quality/reconcile_anchors.rs +64 -0
- package/crates/naome-core/src/quality/scanner/analysis.rs +20 -5
- package/crates/naome-core/src/quality/scanner.rs +62 -17
- package/crates/naome-core/src/quality/semantic/checks.rs +17 -0
- package/crates/naome-core/src/quality/semantic/route.rs +1 -1
- package/crates/naome-core/src/quality/structure/adapter_ios.rs +149 -0
- package/crates/naome-core/src/quality/structure/adapters.rs +60 -42
- package/crates/naome-core/src/quality/structure/checks/directory.rs +6 -4
- package/crates/naome-core/src/quality/structure/classify/roles.rs +51 -5
- package/crates/naome-core/src/quality/structure/config.rs +24 -3
- package/crates/naome-core/src/quality/structure/mod.rs +3 -0
- package/crates/naome-core/src/quality/types.rs +20 -1
- package/crates/naome-core/src/repository_model/detect.rs +188 -0
- package/crates/naome-core/src/repository_model/explain.rs +121 -0
- package/crates/naome-core/src/repository_model/path_scan.rs +67 -0
- package/crates/naome-core/src/repository_model/path_support.rs +59 -0
- package/crates/naome-core/src/repository_model/types.rs +152 -0
- package/crates/naome-core/src/repository_model/world.rs +48 -0
- package/crates/naome-core/src/repository_model/world_adapters.rs +145 -0
- package/crates/naome-core/src/repository_model/world_path_facts.rs +55 -0
- package/crates/naome-core/src/repository_model/world_paths.rs +168 -0
- package/crates/naome-core/src/repository_model.rs +164 -0
- package/crates/naome-core/src/route/builtin_checks.rs +40 -1
- package/crates/naome-core/src/task_ledger/import.rs +142 -0
- package/crates/naome-core/src/task_ledger/model.rs +13 -0
- package/crates/naome-core/src/task_ledger/proof_record.rs +52 -0
- package/crates/naome-core/src/task_ledger/read.rs +118 -0
- package/crates/naome-core/src/task_ledger/render.rs +55 -0
- package/crates/naome-core/src/task_ledger/write.rs +38 -0
- package/crates/naome-core/src/task_ledger.rs +48 -0
- package/crates/naome-core/src/task_state/api.rs +4 -2
- package/crates/naome-core/src/task_state/completed_refresh.rs +5 -16
- package/crates/naome-core/src/task_state/diff.rs +2 -2
- package/crates/naome-core/src/task_state/evidence.rs +8 -3
- package/crates/naome-core/src/task_state/mod.rs +1 -1
- package/crates/naome-core/src/task_state/progress.rs +13 -0
- package/crates/naome-core/src/task_state/proof_model.rs +8 -8
- package/crates/naome-core/src/task_state/repair.rs +2 -2
- package/crates/naome-core/src/task_state/task_diff_api.rs +9 -18
- package/crates/naome-core/src/task_state/types.rs +24 -0
- package/crates/naome-core/src/verification.rs +29 -18
- package/crates/naome-core/src/workflow/agent/capability.rs +194 -0
- package/crates/naome-core/src/workflow/agent/context_delta.rs +42 -0
- package/crates/naome-core/src/workflow/agent/decision.rs +32 -0
- package/crates/naome-core/src/workflow/agent/execution.rs +80 -0
- package/crates/naome-core/src/workflow/agent/proof.rs +24 -0
- package/crates/naome-core/src/workflow/agent/support.rs +58 -0
- package/crates/naome-core/src/workflow/agent/watchdog.rs +47 -0
- package/crates/naome-core/src/workflow/agent.rs +34 -0
- package/crates/naome-core/src/workflow/agent_types.rs +105 -0
- package/crates/naome-core/src/workflow/doctor.rs +39 -0
- package/crates/naome-core/src/workflow/mod.rs +11 -0
- package/crates/naome-core/src/workflow/output.rs +8 -2
- package/crates/naome-core/src/workflow/phase_inference.rs +1 -1
- package/crates/naome-core/tests/context.rs +99 -0
- package/crates/naome-core/tests/harness_health.rs +33 -40
- package/crates/naome-core/tests/install_plan.rs +12 -0
- package/crates/naome-core/tests/quality.rs +178 -2
- package/crates/naome-core/tests/quality_performance.rs +39 -2
- package/crates/naome-core/tests/quality_structure_adapters.rs +39 -0
- package/crates/naome-core/tests/repo_support/mod.rs +7 -1
- package/crates/naome-core/tests/repo_support/verification_values.rs +148 -1
- package/crates/naome-core/tests/repository_model.rs +281 -0
- package/crates/naome-core/tests/route_user_diff.rs +49 -1
- package/crates/naome-core/tests/semantic_legacy.rs +72 -38
- package/crates/naome-core/tests/task_ledger.rs +328 -0
- package/crates/naome-core/tests/task_state.rs +34 -14
- package/crates/naome-core/tests/task_state_support/mod.rs +2 -1
- package/crates/naome-core/tests/task_state_support/states.rs +28 -11
- package/crates/naome-core/tests/verification.rs +14 -39
- package/crates/naome-core/tests/verification_contract.rs +6 -52
- package/crates/naome-core/tests/workflow_agent.rs +233 -0
- package/crates/naome-core/tests/workflow_agent_support/mod.rs +159 -0
- package/crates/naome-core/tests/workflow_doctor.rs +21 -0
- package/crates/naome-core/tests/workflow_integrity.rs +2 -20
- package/crates/naome-core/tests/workflow_support/mod.rs +59 -20
- package/installer/codex-hooks.js +121 -0
- package/installer/context.js +10 -0
- package/installer/filesystem.js +4 -0
- package/installer/flows.js +8 -4
- package/installer/harness-files.js +6 -0
- package/installer/install-plan.js +4 -0
- package/installer/main.js +1 -1
- package/installer/native.js +1 -1
- package/native/darwin-arm64/naome +0 -0
- package/native/linux-x64/naome +0 -0
- package/package.json +1 -1
- package/templates/naome-root/.codex/config.toml +2 -0
- package/templates/naome-root/.codex/hooks.json +70 -0
- package/templates/naome-root/.naome/bin/check-harness-health.js +8 -6
- package/templates/naome-root/.naome/bin/check-task-state.js +12 -7
- package/templates/naome-root/.naome/bin/codex-hook-io.js +122 -0
- package/templates/naome-root/.naome/bin/codex-hook-policy.js +180 -0
- package/templates/naome-root/.naome/bin/codex-hook-runtime.js +174 -0
- package/templates/naome-root/.naome/bin/codex-hook.js +6 -0
- package/templates/naome-root/.naome/bin/naome.js +35 -4
- package/templates/naome-root/.naome/manifest.json +12 -6
- package/templates/naome-root/.naome/repository-model.json +6 -0
- package/templates/naome-root/.naome/repository-quality.json +3 -1
- package/templates/naome-root/.naome/verification.json +15 -1
- package/templates/naome-root/AGENTS.md +38 -83
- package/templates/naome-root/docs/naome/agent-workflow.md +54 -18
- package/templates/naome-root/docs/naome/codex-hooks.md +82 -0
- package/templates/naome-root/docs/naome/context-economy.md +73 -0
- package/templates/naome-root/docs/naome/first-run.md +25 -14
- package/templates/naome-root/docs/naome/index.md +18 -10
- package/templates/naome-root/docs/naome/repository-model.md +92 -0
- package/templates/naome-root/docs/naome/repository-quality.md +47 -7
- package/templates/naome-root/docs/naome/repository-structure.md +10 -3
- package/templates/naome-root/docs/naome/task-ledger.md +71 -0
- package/templates/naome-root/docs/naome/testing.md +16 -3
|
@@ -3,6 +3,7 @@ use std::path::Path;
|
|
|
3
3
|
use serde_json::Value;
|
|
4
4
|
|
|
5
5
|
use crate::models::NaomeError;
|
|
6
|
+
use crate::task_ledger::{read_task_state_projection, validate_task_state_projection_is_current};
|
|
6
7
|
|
|
7
8
|
use super::completion::{
|
|
8
9
|
validate_admission, validate_commit_gate, validate_complete_task, validate_progress,
|
|
@@ -16,7 +17,7 @@ use super::shape::{
|
|
|
16
17
|
};
|
|
17
18
|
use super::task_diff_api::validate_harness_health_gate;
|
|
18
19
|
use super::types::*;
|
|
19
|
-
|
|
20
|
+
|
|
20
21
|
pub fn validate_task_state(
|
|
21
22
|
root: &Path,
|
|
22
23
|
options: TaskStateOptions,
|
|
@@ -25,10 +26,11 @@ pub fn validate_task_state(
|
|
|
25
26
|
errors: Vec::new(),
|
|
26
27
|
notices: Vec::new(),
|
|
27
28
|
};
|
|
28
|
-
let Some(task_state) =
|
|
29
|
+
let Some(task_state) = read_task_state_projection(root)? else {
|
|
29
30
|
return Ok(report);
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
validate_task_state_projection_is_current(root, &mut report.errors)?;
|
|
32
34
|
validate_task_state_shape(&task_state, &mut report.errors);
|
|
33
35
|
let status = task_state
|
|
34
36
|
.get("status")
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
use std::path::Path;
|
|
2
2
|
|
|
3
|
-
use serde_json::Value;
|
|
4
|
-
|
|
5
3
|
use crate::models::NaomeError;
|
|
6
4
|
|
|
7
5
|
use super::api::validate_task_state;
|
|
8
6
|
use super::git_io::read_git_changed_paths;
|
|
9
7
|
use super::repair::is_safe_harness_refresh_path;
|
|
10
8
|
use super::types::{
|
|
11
|
-
|
|
9
|
+
is_control_state_path, read_complete_active_task, CompletedTaskHarnessRefreshDiff,
|
|
10
|
+
TaskStateMode, TaskStateOptions,
|
|
12
11
|
};
|
|
13
|
-
use super::util::{matches_any_pattern,
|
|
12
|
+
use super::util::{matches_any_pattern, string_array};
|
|
14
13
|
pub(super) fn add_completed_task_diff_notice(
|
|
15
14
|
root: &Path,
|
|
16
15
|
notices: &mut Vec<String>,
|
|
@@ -27,17 +26,7 @@ pub(super) fn add_completed_task_diff_notice(
|
|
|
27
26
|
pub fn completed_task_harness_refresh_diff(
|
|
28
27
|
root: &Path,
|
|
29
28
|
) -> Result<Option<CompletedTaskHarnessRefreshDiff>, NaomeError> {
|
|
30
|
-
let
|
|
31
|
-
let Some(task_state) = read_json(root, ".naome/task-state.json", &mut read_errors)? else {
|
|
32
|
-
return Ok(None);
|
|
33
|
-
};
|
|
34
|
-
if !read_errors.is_empty() {
|
|
35
|
-
return Ok(None);
|
|
36
|
-
}
|
|
37
|
-
if task_state.get("status").and_then(Value::as_str) != Some("complete") {
|
|
38
|
-
return Ok(None);
|
|
39
|
-
}
|
|
40
|
-
let Some(active_task) = task_state.get("activeTask") else {
|
|
29
|
+
let Some((_, active_task)) = read_complete_active_task(root)? else {
|
|
41
30
|
return Ok(None);
|
|
42
31
|
};
|
|
43
32
|
|
|
@@ -47,7 +36,7 @@ pub fn completed_task_harness_refresh_diff(
|
|
|
47
36
|
let mut other_paths = Vec::new();
|
|
48
37
|
|
|
49
38
|
for path in read_git_changed_paths(root)? {
|
|
50
|
-
if path
|
|
39
|
+
if is_control_state_path(&path) {
|
|
51
40
|
continue;
|
|
52
41
|
}
|
|
53
42
|
if matches_any_pattern(&path, &allowed_paths) {
|
|
@@ -6,7 +6,7 @@ use serde_json::Value;
|
|
|
6
6
|
use crate::models::NaomeError;
|
|
7
7
|
|
|
8
8
|
use super::git_io::read_git_changed_entries;
|
|
9
|
-
use super::types::{ChangedEntry, TaskDiff
|
|
9
|
+
use super::types::{is_control_state_path, ChangedEntry, TaskDiff};
|
|
10
10
|
use super::util::{matches_any_pattern, normalize_path, string_array};
|
|
11
11
|
pub(super) fn validate_changed_paths(
|
|
12
12
|
active_task: &Value,
|
|
@@ -80,7 +80,7 @@ pub(super) fn task_diff_from_entries(active_task: &Value, entries: &[ChangedEntr
|
|
|
80
80
|
let diff_paths: Vec<String> = entries
|
|
81
81
|
.iter()
|
|
82
82
|
.map(|entry| entry.path.clone())
|
|
83
|
-
.filter(|path| path
|
|
83
|
+
.filter(|path| !is_control_state_path(path))
|
|
84
84
|
.collect();
|
|
85
85
|
let outside_paths = diff_paths
|
|
86
86
|
.iter()
|
|
@@ -7,7 +7,7 @@ use crate::models::NaomeError;
|
|
|
7
7
|
|
|
8
8
|
use super::deleted_paths::read_historical_deleted_paths;
|
|
9
9
|
use super::git_io::read_git_changed_entries;
|
|
10
|
-
use super::types::{ALLOWED_EVIDENCE_STATUS, CONTROL_STATE_PATH};
|
|
10
|
+
use super::types::{is_control_state_path, ALLOWED_EVIDENCE_STATUS, CONTROL_STATE_PATH};
|
|
11
11
|
use super::util::{
|
|
12
12
|
is_non_empty_string, matches_any_pattern, normalize_path, require_string, string_array,
|
|
13
13
|
};
|
|
@@ -68,7 +68,12 @@ pub(super) fn validate_control_state_patterns(
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
for pattern in patterns {
|
|
71
|
-
if matches_any_pattern(CONTROL_STATE_PATH, std::slice::from_ref(&pattern))
|
|
71
|
+
if matches_any_pattern(CONTROL_STATE_PATH, std::slice::from_ref(&pattern))
|
|
72
|
+
|| matches_any_pattern(
|
|
73
|
+
".naome/tasks/example/task.json",
|
|
74
|
+
std::slice::from_ref(&pattern),
|
|
75
|
+
)
|
|
76
|
+
{
|
|
72
77
|
errors.push(format!(
|
|
73
78
|
"{field_name} cannot include NAOME control state: {pattern}"
|
|
74
79
|
));
|
|
@@ -89,7 +94,7 @@ pub(super) fn validate_control_state_paths(
|
|
|
89
94
|
let Some(path) = evidence_entry_path(entry) else {
|
|
90
95
|
continue;
|
|
91
96
|
};
|
|
92
|
-
if normalize_path(&path)
|
|
97
|
+
if is_control_state_path(&normalize_path(&path)) {
|
|
93
98
|
errors.push(format!(
|
|
94
99
|
"{field_name} cannot include NAOME control state: {path}"
|
|
95
100
|
));
|
|
@@ -30,7 +30,7 @@ mod util;
|
|
|
30
30
|
|
|
31
31
|
pub use api::validate_task_state;
|
|
32
32
|
pub use completed_refresh::completed_task_harness_refresh_diff;
|
|
33
|
-
pub(crate) use proof_model::canonical_proof_check_ids;
|
|
33
|
+
pub(crate) use proof_model::{canonical_proof_check_ids, canonical_proofs};
|
|
34
34
|
pub use task_diff_api::{
|
|
35
35
|
completed_task_commit_diff, completed_task_commit_paths, harness_refresh_diff,
|
|
36
36
|
harness_refresh_with_unrelated_diff,
|
|
@@ -3,6 +3,7 @@ use std::path::Path;
|
|
|
3
3
|
use serde_json::Value;
|
|
4
4
|
|
|
5
5
|
use crate::models::NaomeError;
|
|
6
|
+
use crate::repository_model_drift;
|
|
6
7
|
|
|
7
8
|
use super::diff::validate_changed_paths;
|
|
8
9
|
use super::git_io::read_git_changed_paths;
|
|
@@ -33,6 +34,7 @@ pub(super) fn validate_progress(
|
|
|
33
34
|
if let Some(active_task) = task_state.get("activeTask") {
|
|
34
35
|
validate_changed_paths(active_task, root, errors)?;
|
|
35
36
|
}
|
|
37
|
+
validate_repository_model_current(root, errors)?;
|
|
36
38
|
}
|
|
37
39
|
"needs_human_review" => {
|
|
38
40
|
validate_human_review_state(task_state, root, errors)?;
|
|
@@ -60,6 +62,17 @@ pub(super) fn validate_progress(
|
|
|
60
62
|
Ok(())
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
fn validate_repository_model_current(
|
|
66
|
+
root: &Path,
|
|
67
|
+
errors: &mut Vec<String>,
|
|
68
|
+
) -> Result<(), NaomeError> {
|
|
69
|
+
let drift = repository_model_drift(root)?;
|
|
70
|
+
if drift.model_present && drift.stale {
|
|
71
|
+
errors.extend(drift.messages);
|
|
72
|
+
}
|
|
73
|
+
Ok(())
|
|
74
|
+
}
|
|
75
|
+
|
|
63
76
|
pub(super) fn checked_status<'a>(
|
|
64
77
|
task_state: &'a Value,
|
|
65
78
|
root: &Path,
|
|
@@ -8,13 +8,13 @@ use super::compact_proof::compact_proofs;
|
|
|
8
8
|
use super::proof_sources::{check_id_from_proof, read_verification_defaults};
|
|
9
9
|
|
|
10
10
|
#[derive(Debug, Clone)]
|
|
11
|
-
pub(
|
|
12
|
-
pub(
|
|
13
|
-
pub(
|
|
14
|
-
pub(
|
|
15
|
-
pub(
|
|
16
|
-
pub(
|
|
17
|
-
pub(
|
|
11
|
+
pub(crate) struct CanonicalProof {
|
|
12
|
+
pub(crate) check_id: String,
|
|
13
|
+
pub(crate) command: String,
|
|
14
|
+
pub(crate) cwd: String,
|
|
15
|
+
pub(crate) exit_code: i64,
|
|
16
|
+
pub(crate) checked_at: String,
|
|
17
|
+
pub(crate) evidence: Vec<Value>,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
#[derive(Debug, Clone)]
|
|
@@ -23,7 +23,7 @@ pub(super) struct VerificationDefaults {
|
|
|
23
23
|
pub(super) cwd: String,
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
pub(
|
|
26
|
+
pub(crate) fn canonical_proofs(
|
|
27
27
|
active_task: &Value,
|
|
28
28
|
root: &Path,
|
|
29
29
|
errors: &mut Vec<String>,
|
|
@@ -6,7 +6,7 @@ use serde_json::Value;
|
|
|
6
6
|
use crate::install_plan::MACHINE_OWNED_PATHS;
|
|
7
7
|
use crate::models::NaomeError;
|
|
8
8
|
|
|
9
|
-
use super::types::
|
|
9
|
+
use super::types::is_control_state_path;
|
|
10
10
|
use super::util::{
|
|
11
11
|
is_non_empty_string, matches_any_pattern, normalize_path, read_json, string_array,
|
|
12
12
|
};
|
|
@@ -69,7 +69,7 @@ pub(super) fn is_completed_task_diff(task_state: &Value, changed_paths: &[String
|
|
|
69
69
|
let allowed_paths = string_array(active_task.get("allowedPaths")).unwrap_or_default();
|
|
70
70
|
let task_paths: Vec<&String> = changed_paths
|
|
71
71
|
.iter()
|
|
72
|
-
.filter(|path| path
|
|
72
|
+
.filter(|path| !is_control_state_path(path))
|
|
73
73
|
.collect();
|
|
74
74
|
!task_paths.is_empty()
|
|
75
75
|
&& task_paths
|
|
@@ -16,10 +16,10 @@ use super::shape::{
|
|
|
16
16
|
validate_pending_upgrade, validate_required_check_ids, validate_task_state_shape,
|
|
17
17
|
};
|
|
18
18
|
use super::types::{
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
is_control_state_path, read_complete_active_task, CompletedTaskCommitDiff, HarnessRefreshDiff,
|
|
20
|
+
HarnessRefreshWithUnrelatedDiff, TaskStateOptions,
|
|
21
21
|
};
|
|
22
|
-
use super::util::{matches_any_pattern,
|
|
22
|
+
use super::util::{matches_any_pattern, string_array};
|
|
23
23
|
|
|
24
24
|
pub fn completed_task_commit_paths(root: &Path) -> Result<Vec<String>, NaomeError> {
|
|
25
25
|
Ok(completed_task_commit_diff(root)?
|
|
@@ -30,16 +30,7 @@ pub fn completed_task_commit_paths(root: &Path) -> Result<Vec<String>, NaomeErro
|
|
|
30
30
|
pub fn completed_task_commit_diff(
|
|
31
31
|
root: &Path,
|
|
32
32
|
) -> Result<Option<CompletedTaskCommitDiff>, NaomeError> {
|
|
33
|
-
let
|
|
34
|
-
let Some(task_state) = read_json(root, ".naome/task-state.json", &mut read_errors)? else {
|
|
35
|
-
return Ok(None);
|
|
36
|
-
};
|
|
37
|
-
if !read_errors.is_empty()
|
|
38
|
-
|| task_state.get("status").and_then(Value::as_str) != Some("complete")
|
|
39
|
-
{
|
|
40
|
-
return Ok(None);
|
|
41
|
-
}
|
|
42
|
-
let Some(active_task) = task_state.get("activeTask") else {
|
|
33
|
+
let Some((task_state, active_task)) = read_complete_active_task(root)? else {
|
|
43
34
|
return Ok(None);
|
|
44
35
|
};
|
|
45
36
|
|
|
@@ -47,7 +38,7 @@ pub fn completed_task_commit_diff(
|
|
|
47
38
|
let mut task_entries = Vec::new();
|
|
48
39
|
let mut unrelated_paths = Vec::new();
|
|
49
40
|
for entry in read_git_changed_entries(root)? {
|
|
50
|
-
if entry.path
|
|
41
|
+
if is_control_state_path(&entry.path) || matches_any_pattern(&entry.path, &allowed_paths) {
|
|
51
42
|
task_entries.push(entry);
|
|
52
43
|
} else {
|
|
53
44
|
unrelated_paths.push(entry.path);
|
|
@@ -60,16 +51,16 @@ pub fn completed_task_commit_diff(
|
|
|
60
51
|
|
|
61
52
|
let mut errors = Vec::new();
|
|
62
53
|
validate_task_state_shape(&task_state, &mut errors);
|
|
63
|
-
validate_active_task(Some(active_task), &mut errors);
|
|
54
|
+
validate_active_task(Some(&active_task), &mut errors);
|
|
64
55
|
validate_pending_upgrade(&task_state, root, &mut errors)?;
|
|
65
|
-
validate_active_task_references(Some(active_task), root, &mut errors, Some("complete"))?;
|
|
56
|
+
validate_active_task_references(Some(&active_task), root, &mut errors, Some("complete"))?;
|
|
66
57
|
if !task_state.get("blocker").is_some_and(Value::is_null) {
|
|
67
58
|
errors.push("complete task state must have blocker set to null.".to_string());
|
|
68
59
|
}
|
|
69
60
|
let check_ids = read_verification_check_ids(root, &mut errors)?;
|
|
70
|
-
validate_required_check_ids(active_task, &check_ids, &mut errors);
|
|
61
|
+
validate_required_check_ids(&active_task, &check_ids, &mut errors);
|
|
71
62
|
validate_complete_task_against_entries(
|
|
72
|
-
active_task,
|
|
63
|
+
&active_task,
|
|
73
64
|
root,
|
|
74
65
|
&check_ids,
|
|
75
66
|
&task_entries,
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
use std::path::Path;
|
|
2
|
+
|
|
3
|
+
use serde_json::Value;
|
|
4
|
+
|
|
1
5
|
use crate::harness_health::HarnessHealthOptions;
|
|
6
|
+
use crate::models::NaomeError;
|
|
7
|
+
use crate::task_ledger::read_task_state_projection;
|
|
2
8
|
|
|
3
9
|
pub(super) const CONTROL_STATE_PATH: &str = ".naome/task-state.json";
|
|
10
|
+
pub(super) const TASK_LEDGER_PATH_PREFIX: &str = ".naome/tasks/";
|
|
4
11
|
pub(super) const ALLOWED_STATUS: &[&str] = &[
|
|
5
12
|
"idle",
|
|
6
13
|
"planning",
|
|
@@ -85,3 +92,20 @@ pub(super) struct TaskDiff {
|
|
|
85
92
|
pub(super) diff_paths: Vec<String>,
|
|
86
93
|
pub(super) outside_paths: Vec<String>,
|
|
87
94
|
}
|
|
95
|
+
|
|
96
|
+
pub(super) fn is_control_state_path(path: &str) -> bool {
|
|
97
|
+
path == CONTROL_STATE_PATH || path.starts_with(TASK_LEDGER_PATH_PREFIX)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pub(super) fn read_complete_active_task(root: &Path) -> Result<Option<(Value, Value)>, NaomeError> {
|
|
101
|
+
let Some(task_state) = read_task_state_projection(root)? else {
|
|
102
|
+
return Ok(None);
|
|
103
|
+
};
|
|
104
|
+
if task_state.get("status").and_then(Value::as_str) != Some("complete") {
|
|
105
|
+
return Ok(None);
|
|
106
|
+
}
|
|
107
|
+
let Some(active_task) = task_state.get("activeTask") else {
|
|
108
|
+
return Ok(None);
|
|
109
|
+
};
|
|
110
|
+
Ok(Some((task_state.clone(), active_task.clone())))
|
|
111
|
+
}
|
|
@@ -46,7 +46,7 @@ pub fn seed_builtin_verification_checks(root: &Path) -> Result<bool, NaomeError>
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
let wired_change_types =
|
|
49
|
+
let wired_change_types = wire_repository_gate_checks(verification_object);
|
|
50
50
|
let phases_added = ensure_default_phases(verification_object);
|
|
51
51
|
|
|
52
52
|
if missing_checks.is_empty() && !wired_change_types && !phases_added {
|
|
@@ -126,7 +126,7 @@ fn default_phases() -> Vec<BuiltinPhase> {
|
|
|
126
126
|
BuiltinPhase {
|
|
127
127
|
id: "quality",
|
|
128
128
|
order: 20,
|
|
129
|
-
check_ids: &["repository-quality-check"],
|
|
129
|
+
check_ids: &["repository-quality-check", "repository-semantic-check"],
|
|
130
130
|
},
|
|
131
131
|
BuiltinPhase {
|
|
132
132
|
id: "diff-check",
|
|
@@ -136,7 +136,7 @@ fn default_phases() -> Vec<BuiltinPhase> {
|
|
|
136
136
|
]
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
fn
|
|
139
|
+
fn wire_repository_gate_checks(verification_object: &mut serde_json::Map<String, Value>) -> bool {
|
|
140
140
|
let Some(change_types) = verification_object
|
|
141
141
|
.get_mut("changeTypes")
|
|
142
142
|
.and_then(Value::as_array_mut)
|
|
@@ -155,33 +155,35 @@ fn wire_repository_quality_check(verification_object: &mut serde_json::Map<Strin
|
|
|
155
155
|
{
|
|
156
156
|
continue;
|
|
157
157
|
}
|
|
158
|
-
let already_wired = ["requiredChecks", "recommendedChecks"].iter().any(|field| {
|
|
159
|
-
change_type_object
|
|
160
|
-
.get(*field)
|
|
161
|
-
.and_then(Value::as_array)
|
|
162
|
-
.is_some_and(|checks| {
|
|
163
|
-
checks
|
|
164
|
-
.iter()
|
|
165
|
-
.any(|check| check.as_str() == Some("repository-quality-check"))
|
|
166
|
-
})
|
|
167
|
-
});
|
|
168
|
-
if already_wired {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
158
|
if !change_type_object
|
|
172
159
|
.get("requiredChecks")
|
|
173
160
|
.is_some_and(Value::is_array)
|
|
174
161
|
{
|
|
175
162
|
change_type_object.insert("requiredChecks".to_string(), Value::Array(Vec::new()));
|
|
176
163
|
}
|
|
164
|
+
let missing_checks = ["repository-quality-check", "repository-semantic-check"]
|
|
165
|
+
.into_iter()
|
|
166
|
+
.filter(|check_id| {
|
|
167
|
+
!["requiredChecks", "recommendedChecks"].iter().any(|field| {
|
|
168
|
+
change_type_object
|
|
169
|
+
.get(*field)
|
|
170
|
+
.and_then(Value::as_array)
|
|
171
|
+
.is_some_and(|checks| {
|
|
172
|
+
checks.iter().any(|check| check.as_str() == Some(*check_id))
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
.collect::<Vec<_>>();
|
|
177
177
|
let Some(required_checks) = change_type_object
|
|
178
178
|
.get_mut("requiredChecks")
|
|
179
179
|
.and_then(Value::as_array_mut)
|
|
180
180
|
else {
|
|
181
181
|
continue;
|
|
182
182
|
};
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
for check_id in missing_checks {
|
|
184
|
+
required_checks.push(Value::String(check_id.to_string()));
|
|
185
|
+
changed = true;
|
|
186
|
+
}
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
changed
|
|
@@ -247,6 +249,15 @@ fn builtin_checks() -> Vec<BuiltinCheck> {
|
|
|
247
249
|
".naome/repository-quality-baseline.json",
|
|
248
250
|
],
|
|
249
251
|
},
|
|
252
|
+
BuiltinCheck {
|
|
253
|
+
id: "repository-semantic-check",
|
|
254
|
+
command: "node .naome/bin/naome.js semantic check --changed",
|
|
255
|
+
purpose: "Validate changed files against deterministic NAOME semantic cleanup rules.",
|
|
256
|
+
evidence: &[
|
|
257
|
+
".naome/repository-quality.json",
|
|
258
|
+
".naome/repository-quality-baseline.json",
|
|
259
|
+
],
|
|
260
|
+
},
|
|
250
261
|
]
|
|
251
262
|
}
|
|
252
263
|
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
use std::path::Path;
|
|
3
|
+
|
|
4
|
+
use serde_json::Value;
|
|
5
|
+
|
|
6
|
+
use crate::models::NaomeError;
|
|
7
|
+
use crate::repository_model::refresh_repository_model;
|
|
8
|
+
use crate::workflow::agent_types::{
|
|
9
|
+
CapabilityGraph, CapabilityRoot, RepositoryCapability, VerificationEdge,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
pub fn repository_capability_graph(root: &Path) -> Result<CapabilityGraph, NaomeError> {
|
|
13
|
+
let mut model = refresh_repository_model(root, false)?.model;
|
|
14
|
+
if model.languages.is_empty() && model.build_systems.is_empty() && model.adapters.is_empty() {
|
|
15
|
+
model = fallback_capability_model(root)?;
|
|
16
|
+
}
|
|
17
|
+
let mut capabilities = Vec::new();
|
|
18
|
+
capabilities.extend(
|
|
19
|
+
model
|
|
20
|
+
.languages
|
|
21
|
+
.into_iter()
|
|
22
|
+
.map(|signal| capability_from_signal("language", signal)),
|
|
23
|
+
);
|
|
24
|
+
capabilities.extend(
|
|
25
|
+
model
|
|
26
|
+
.build_systems
|
|
27
|
+
.into_iter()
|
|
28
|
+
.map(|signal| capability_from_signal("build", signal)),
|
|
29
|
+
);
|
|
30
|
+
capabilities.extend(
|
|
31
|
+
model
|
|
32
|
+
.adapters
|
|
33
|
+
.into_iter()
|
|
34
|
+
.map(|signal| capability_from_signal("adapter", signal)),
|
|
35
|
+
);
|
|
36
|
+
capabilities.sort_by(|left, right| left.id.cmp(&right.id));
|
|
37
|
+
|
|
38
|
+
let verification_edges = if model.verification_checks.is_empty() {
|
|
39
|
+
read_verification_edges(root)?
|
|
40
|
+
} else {
|
|
41
|
+
model
|
|
42
|
+
.verification_checks
|
|
43
|
+
.into_iter()
|
|
44
|
+
.map(|check| VerificationEdge {
|
|
45
|
+
check_id: check.id,
|
|
46
|
+
command: check.command,
|
|
47
|
+
evidence: check.evidence,
|
|
48
|
+
})
|
|
49
|
+
.collect()
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Ok(CapabilityGraph {
|
|
53
|
+
schema: "naome.capability-graph.v1".to_string(),
|
|
54
|
+
capabilities,
|
|
55
|
+
roots: model
|
|
56
|
+
.roots
|
|
57
|
+
.into_iter()
|
|
58
|
+
.map(|root| CapabilityRoot {
|
|
59
|
+
role: root.role,
|
|
60
|
+
path: root.path,
|
|
61
|
+
})
|
|
62
|
+
.collect(),
|
|
63
|
+
verification_edges,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fn capability_from_signal(
|
|
68
|
+
kind: &str,
|
|
69
|
+
signal: crate::RepositoryWorldSignal,
|
|
70
|
+
) -> RepositoryCapability {
|
|
71
|
+
RepositoryCapability {
|
|
72
|
+
id: format!("{kind}:{}", signal.value),
|
|
73
|
+
kind: kind.to_string(),
|
|
74
|
+
value: signal.value,
|
|
75
|
+
evidence: signal.evidence,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn fallback_capability_model(root: &Path) -> Result<crate::RepositoryModel, NaomeError> {
|
|
80
|
+
let paths = fallback_paths(root)?;
|
|
81
|
+
let mut model = crate::RepositoryModel::default();
|
|
82
|
+
model.schema = "naome.repository-model.v2".to_string();
|
|
83
|
+
model.version = 2;
|
|
84
|
+
if paths
|
|
85
|
+
.iter()
|
|
86
|
+
.any(|path| path == "Cargo.toml" || path.ends_with(".rs"))
|
|
87
|
+
{
|
|
88
|
+
let evidence = first_evidence(&paths, &["Cargo.toml", ".rs"]);
|
|
89
|
+
model
|
|
90
|
+
.languages
|
|
91
|
+
.push(signal("language:rust", "rust", &evidence));
|
|
92
|
+
model
|
|
93
|
+
.build_systems
|
|
94
|
+
.push(signal("buildSystem:cargo", "cargo", &evidence));
|
|
95
|
+
}
|
|
96
|
+
Ok(model)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fn signal(id: &str, value: &str, evidence: &[String]) -> crate::RepositoryWorldSignal {
|
|
100
|
+
crate::RepositoryWorldSignal {
|
|
101
|
+
id: id.to_string(),
|
|
102
|
+
value: value.to_string(),
|
|
103
|
+
confidence: "detected".to_string(),
|
|
104
|
+
source: "fallback-scan".to_string(),
|
|
105
|
+
evidence: evidence.to_vec(),
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
fn read_verification_edges(root: &Path) -> Result<Vec<VerificationEdge>, NaomeError> {
|
|
110
|
+
let path = root.join(".naome/verification.json");
|
|
111
|
+
if !path.is_file() {
|
|
112
|
+
return Ok(Vec::new());
|
|
113
|
+
}
|
|
114
|
+
let verification: Value = serde_json::from_str(&fs::read_to_string(path)?)?;
|
|
115
|
+
Ok(verification
|
|
116
|
+
.get("checks")
|
|
117
|
+
.and_then(Value::as_array)
|
|
118
|
+
.into_iter()
|
|
119
|
+
.flatten()
|
|
120
|
+
.filter_map(|check| {
|
|
121
|
+
Some(VerificationEdge {
|
|
122
|
+
check_id: check.get("id")?.as_str()?.to_string(),
|
|
123
|
+
command: check.get("command")?.as_str()?.to_string(),
|
|
124
|
+
evidence: check
|
|
125
|
+
.get("evidence")
|
|
126
|
+
.and_then(Value::as_array)
|
|
127
|
+
.into_iter()
|
|
128
|
+
.flatten()
|
|
129
|
+
.filter_map(Value::as_str)
|
|
130
|
+
.map(ToString::to_string)
|
|
131
|
+
.collect(),
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
.collect())
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
fn fallback_paths(root: &Path) -> Result<Vec<String>, NaomeError> {
|
|
138
|
+
let mut paths = Vec::new();
|
|
139
|
+
collect_fallback_paths(root, root, &mut paths)?;
|
|
140
|
+
paths.sort();
|
|
141
|
+
paths.dedup();
|
|
142
|
+
Ok(paths)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
fn collect_fallback_paths(
|
|
146
|
+
root: &Path,
|
|
147
|
+
dir: &Path,
|
|
148
|
+
paths: &mut Vec<String>,
|
|
149
|
+
) -> Result<(), NaomeError> {
|
|
150
|
+
for entry in fs::read_dir(dir)? {
|
|
151
|
+
let entry = entry?;
|
|
152
|
+
let path = entry.path();
|
|
153
|
+
let relative = path
|
|
154
|
+
.strip_prefix(root)
|
|
155
|
+
.unwrap_or(&path)
|
|
156
|
+
.to_string_lossy()
|
|
157
|
+
.replace('\\', "/");
|
|
158
|
+
if is_fallback_ignored(&relative) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if path.is_dir() {
|
|
162
|
+
collect_fallback_paths(root, &path, paths)?;
|
|
163
|
+
} else if path.is_file() {
|
|
164
|
+
paths.push(relative);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
Ok(())
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
fn is_fallback_ignored(path: &str) -> bool {
|
|
171
|
+
path == ".git"
|
|
172
|
+
|| path.starts_with(".git/")
|
|
173
|
+
|| path.starts_with(".naome/archive/")
|
|
174
|
+
|| path.starts_with(".naome/cache/")
|
|
175
|
+
|| path == "node_modules"
|
|
176
|
+
|| path.starts_with("node_modules/")
|
|
177
|
+
|| path == "target"
|
|
178
|
+
|| path.starts_with("target/")
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
fn first_evidence(paths: &[String], markers: &[&str]) -> Vec<String> {
|
|
182
|
+
let mut evidence = Vec::new();
|
|
183
|
+
for marker in markers {
|
|
184
|
+
if let Some(path) = paths
|
|
185
|
+
.iter()
|
|
186
|
+
.find(|path| path.as_str() == *marker || path.ends_with(marker))
|
|
187
|
+
{
|
|
188
|
+
evidence.push(path.clone());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
evidence.sort();
|
|
192
|
+
evidence.dedup();
|
|
193
|
+
evidence
|
|
194
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
use std::collections::BTreeSet;
|
|
2
|
+
use std::path::Path;
|
|
3
|
+
|
|
4
|
+
use crate::models::NaomeError;
|
|
5
|
+
|
|
6
|
+
use super::support::{changed_paths, normalize_path, required_context};
|
|
7
|
+
use crate::workflow::agent_types::ContextDeltaReport;
|
|
8
|
+
|
|
9
|
+
pub fn context_delta_report(
|
|
10
|
+
root: &Path,
|
|
11
|
+
read_paths: &[String],
|
|
12
|
+
) -> Result<ContextDeltaReport, NaomeError> {
|
|
13
|
+
let changed = changed_paths(root)?.into_iter().collect::<BTreeSet<_>>();
|
|
14
|
+
let required = required_context(root);
|
|
15
|
+
let read = read_paths
|
|
16
|
+
.iter()
|
|
17
|
+
.map(|path| normalize_path(path))
|
|
18
|
+
.collect::<BTreeSet<_>>();
|
|
19
|
+
let reusable_context = read
|
|
20
|
+
.iter()
|
|
21
|
+
.filter(|path| !changed.contains(*path) && root.join(path.as_str()).exists())
|
|
22
|
+
.cloned()
|
|
23
|
+
.collect();
|
|
24
|
+
let stale_context = read
|
|
25
|
+
.iter()
|
|
26
|
+
.filter(|path| changed.contains(*path))
|
|
27
|
+
.cloned()
|
|
28
|
+
.collect();
|
|
29
|
+
let unread_required_context = required
|
|
30
|
+
.iter()
|
|
31
|
+
.filter(|path| !read.contains(*path))
|
|
32
|
+
.cloned()
|
|
33
|
+
.collect();
|
|
34
|
+
|
|
35
|
+
Ok(ContextDeltaReport {
|
|
36
|
+
schema: "naome.context-delta.v1".to_string(),
|
|
37
|
+
reusable_context,
|
|
38
|
+
stale_context,
|
|
39
|
+
unread_required_context,
|
|
40
|
+
reason_codes: vec!["read-set-minimization".to_string()],
|
|
41
|
+
})
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
use std::path::Path;
|
|
2
|
+
|
|
3
|
+
use crate::decision::{evaluate_decision, EvaluationOptions};
|
|
4
|
+
use crate::models::NaomeError;
|
|
5
|
+
use crate::workflow::agent_types::DecisionGate;
|
|
6
|
+
|
|
7
|
+
pub fn decision_gate(root: &Path) -> Result<DecisionGate, NaomeError> {
|
|
8
|
+
let decision = evaluate_decision(root, EvaluationOptions::offline())?;
|
|
9
|
+
let action = if decision.blocked {
|
|
10
|
+
if decision.state == "active_task_blocked" {
|
|
11
|
+
"ask_human"
|
|
12
|
+
} else {
|
|
13
|
+
"stop"
|
|
14
|
+
}
|
|
15
|
+
} else if decision.state == "ready_for_task" {
|
|
16
|
+
"create_task"
|
|
17
|
+
} else {
|
|
18
|
+
"continue"
|
|
19
|
+
};
|
|
20
|
+
let mut reason_codes = vec![decision.state.clone()];
|
|
21
|
+
if decision.state == "active_task_blocked" {
|
|
22
|
+
reason_codes.push("scope_review_required".to_string());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Ok(DecisionGate {
|
|
26
|
+
schema: "naome.decision-gate.v1".to_string(),
|
|
27
|
+
action: action.to_string(),
|
|
28
|
+
reason_codes,
|
|
29
|
+
human_options: decision.human_options,
|
|
30
|
+
next_action: decision.next_action,
|
|
31
|
+
})
|
|
32
|
+
}
|