@lamentis/naome 1.1.2 → 1.2.0
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/Cargo.toml +1 -1
- package/LICENSE +180 -21
- package/README.md +49 -6
- package/bin/naome.js +54 -16
- package/crates/naome-cli/Cargo.toml +1 -1
- package/crates/naome-cli/src/check_commands.rs +135 -0
- package/crates/naome-cli/src/cli_args.rs +5 -0
- package/crates/naome-cli/src/dispatcher.rs +36 -0
- package/crates/naome-cli/src/install_bridge.rs +83 -0
- package/crates/naome-cli/src/main.rs +57 -341
- package/crates/naome-cli/src/prompt_commands.rs +68 -0
- package/crates/naome-cli/src/quality_commands.rs +141 -0
- package/crates/naome-cli/src/simple_commands.rs +53 -0
- package/crates/naome-cli/src/workflow_commands.rs +153 -0
- package/crates/naome-core/Cargo.toml +1 -1
- package/crates/naome-core/src/harness_health/integrity.rs +96 -0
- package/crates/naome-core/src/harness_health.rs +14 -126
- package/crates/naome-core/src/install_plan.rs +3 -0
- package/crates/naome-core/src/intent/classifier.rs +171 -0
- package/crates/naome-core/src/intent/envelope.rs +108 -0
- package/crates/naome-core/src/intent/legacy.rs +138 -0
- package/crates/naome-core/src/intent/legacy_response.rs +76 -0
- package/crates/naome-core/src/intent/model.rs +71 -0
- package/crates/naome-core/src/intent/patterns.rs +170 -0
- package/crates/naome-core/src/intent/resolver.rs +162 -0
- package/crates/naome-core/src/intent/resolver_active.rs +17 -0
- package/crates/naome-core/src/intent/resolver_baseline.rs +55 -0
- package/crates/naome-core/src/intent/resolver_catalog.rs +167 -0
- package/crates/naome-core/src/intent/resolver_policy.rs +72 -0
- package/crates/naome-core/src/intent/resolver_shared.rs +55 -0
- package/crates/naome-core/src/intent/risk.rs +40 -0
- package/crates/naome-core/src/intent/segment.rs +170 -0
- package/crates/naome-core/src/intent.rs +64 -879
- package/crates/naome-core/src/journal.rs +9 -20
- package/crates/naome-core/src/lib.rs +13 -0
- package/crates/naome-core/src/quality/adapters.rs +178 -0
- package/crates/naome-core/src/quality/baseline.rs +75 -0
- package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +175 -0
- package/crates/naome-core/src/quality/checks/near_duplicates.rs +130 -0
- package/crates/naome-core/src/quality/checks.rs +228 -0
- package/crates/naome-core/src/quality/cleanup.rs +72 -0
- package/crates/naome-core/src/quality/config.rs +109 -0
- package/crates/naome-core/src/quality/mod.rs +90 -0
- package/crates/naome-core/src/quality/scanner/repo_paths.rs +103 -0
- package/crates/naome-core/src/quality/scanner.rs +367 -0
- package/crates/naome-core/src/quality/types.rs +289 -0
- package/crates/naome-core/src/route.rs +62 -0
- package/crates/naome-core/src/task_state/admission.rs +63 -0
- package/crates/naome-core/src/task_state/admission_proof.rs +72 -0
- package/crates/naome-core/src/task_state/api.rs +130 -0
- package/crates/naome-core/src/task_state/commit_gate.rs +138 -0
- package/crates/naome-core/src/task_state/compact_proof.rs +160 -0
- package/crates/naome-core/src/task_state/completed_refresh.rs +89 -0
- package/crates/naome-core/src/task_state/completion.rs +72 -0
- package/crates/naome-core/src/task_state/deleted_paths.rs +47 -0
- package/crates/naome-core/src/task_state/diff.rs +95 -0
- package/crates/naome-core/src/task_state/evidence.rs +154 -0
- package/crates/naome-core/src/task_state/git_io.rs +86 -0
- package/crates/naome-core/src/task_state/git_parse.rs +86 -0
- package/crates/naome-core/src/task_state/git_refs.rs +37 -0
- package/crates/naome-core/src/task_state/human_review_state.rs +31 -0
- package/crates/naome-core/src/task_state/mod.rs +38 -0
- package/crates/naome-core/src/task_state/process_guard.rs +40 -0
- package/crates/naome-core/src/task_state/progress.rs +123 -0
- package/crates/naome-core/src/task_state/proof.rs +139 -0
- package/crates/naome-core/src/task_state/proof_entry.rs +66 -0
- package/crates/naome-core/src/task_state/proof_model.rs +70 -0
- package/crates/naome-core/src/task_state/proof_sources.rs +76 -0
- package/crates/naome-core/src/task_state/push_gate.rs +49 -0
- package/crates/naome-core/src/task_state/reconcile.rs +7 -0
- package/crates/naome-core/src/task_state/repair.rs +168 -0
- package/crates/naome-core/src/task_state/shape.rs +117 -0
- package/crates/naome-core/src/task_state/task_diff_api.rs +170 -0
- package/crates/naome-core/src/task_state/task_records.rs +131 -0
- package/crates/naome-core/src/task_state/task_references.rs +126 -0
- package/crates/naome-core/src/task_state/types.rs +87 -0
- package/crates/naome-core/src/task_state/util.rs +137 -0
- package/crates/naome-core/src/verification/render.rs +122 -0
- package/crates/naome-core/src/verification.rs +176 -58
- package/crates/naome-core/src/verification_contract.rs +49 -21
- package/crates/naome-core/src/workflow/integrity.rs +123 -0
- package/crates/naome-core/src/workflow/integrity_normalize.rs +7 -0
- package/crates/naome-core/src/workflow/integrity_support.rs +110 -0
- package/crates/naome-core/src/workflow/mod.rs +18 -0
- package/crates/naome-core/src/workflow/mutation.rs +68 -0
- package/crates/naome-core/src/workflow/output.rs +111 -0
- package/crates/naome-core/src/workflow/phase_inference.rs +73 -0
- package/crates/naome-core/src/workflow/phases.rs +169 -0
- package/crates/naome-core/src/workflow/policy.rs +156 -0
- package/crates/naome-core/src/workflow/processes.rs +91 -0
- package/crates/naome-core/src/workflow/types.rs +42 -0
- package/crates/naome-core/tests/harness_health.rs +3 -0
- package/crates/naome-core/tests/intent.rs +97 -792
- package/crates/naome-core/tests/intent_support/mod.rs +133 -0
- package/crates/naome-core/tests/intent_v2.rs +90 -0
- package/crates/naome-core/tests/quality.rs +425 -0
- package/crates/naome-core/tests/route.rs +88 -188
- package/crates/naome-core/tests/task_state.rs +3 -0
- package/crates/naome-core/tests/task_state_compact.rs +110 -0
- package/crates/naome-core/tests/task_state_compact_support/mod.rs +5 -0
- package/crates/naome-core/tests/task_state_compact_support/repo.rs +130 -0
- package/crates/naome-core/tests/task_state_compact_support/states.rs +151 -0
- package/crates/naome-core/tests/workflow_integrity.rs +85 -0
- package/crates/naome-core/tests/workflow_policy.rs +139 -0
- package/crates/naome-core/tests/workflow_support/mod.rs +194 -0
- package/native/darwin-arm64/naome +0 -0
- package/native/linux-x64/naome +0 -0
- package/package.json +2 -2
- package/templates/naome-root/.naome/bin/check-harness-health.js +66 -85
- package/templates/naome-root/.naome/bin/check-task-state.js +9 -10
- package/templates/naome-root/.naome/bin/naome.js +34 -63
- package/templates/naome-root/.naome/manifest.json +20 -18
- package/templates/naome-root/.naome/repository-quality-baseline.json +5 -0
- package/templates/naome-root/.naome/repository-quality.json +24 -0
- package/templates/naome-root/.naome/task-contract.schema.json +93 -11
- package/templates/naome-root/.naome/upgrade-state.json +1 -1
- package/templates/naome-root/.naome/verification.json +37 -0
- package/templates/naome-root/AGENTS.md +3 -0
- package/templates/naome-root/docs/naome/agent-workflow.md +25 -12
- package/templates/naome-root/docs/naome/execution.md +25 -21
- package/templates/naome-root/docs/naome/index.md +4 -3
- package/templates/naome-root/docs/naome/repository-quality.md +43 -0
- package/templates/naome-root/docs/naome/testing.md +12 -0
- package/crates/naome-core/src/task_state.rs +0 -2210
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
use serde_json::{json, Value};
|
|
2
|
+
|
|
3
|
+
const T0: &str = "2026-05-07T00:00:00.000Z";
|
|
4
|
+
|
|
5
|
+
pub fn compact_state(admission_head: &str) -> Value {
|
|
6
|
+
base_state(
|
|
7
|
+
admission_head,
|
|
8
|
+
json!({
|
|
9
|
+
"proofPathSets": {
|
|
10
|
+
"changed-readme": ["README.md"]
|
|
11
|
+
},
|
|
12
|
+
"proofBatches": [
|
|
13
|
+
{
|
|
14
|
+
"checkedAt": T0,
|
|
15
|
+
"evidencePathSet": "changed-readme",
|
|
16
|
+
"proofs": [
|
|
17
|
+
{
|
|
18
|
+
"checkId": "alpha",
|
|
19
|
+
"exitCode": 0
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"checkId": "beta",
|
|
23
|
+
"command": "npm run beta -- --changed README.md",
|
|
24
|
+
"cwd": "tools",
|
|
25
|
+
"exitCode": 0
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub fn legacy_state(admission_head: &str) -> Value {
|
|
35
|
+
let mut state = base_state(
|
|
36
|
+
admission_head,
|
|
37
|
+
json!({
|
|
38
|
+
"proofResults": [
|
|
39
|
+
proof("alpha", "npm run alpha", "."),
|
|
40
|
+
proof("beta", "npm run beta", ".")
|
|
41
|
+
]
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
state["schema"] = json!("naome.task-state.v1");
|
|
45
|
+
state["version"] = json!(1);
|
|
46
|
+
state
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pub fn large_compact_state(admission_head: &str) -> Value {
|
|
50
|
+
let evidence: Vec<Value> = (0..12)
|
|
51
|
+
.map(|index| json!(format!("src/module_{index}.rs")))
|
|
52
|
+
.collect();
|
|
53
|
+
let proofs: Vec<Value> = (0..8)
|
|
54
|
+
.map(|index| {
|
|
55
|
+
json!({
|
|
56
|
+
"checkId": format!("check-{index}"),
|
|
57
|
+
"exitCode": 0
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
.collect();
|
|
61
|
+
base_state(
|
|
62
|
+
admission_head,
|
|
63
|
+
json!({
|
|
64
|
+
"proofPathSets": {
|
|
65
|
+
"large-change": evidence
|
|
66
|
+
},
|
|
67
|
+
"proofBatches": [
|
|
68
|
+
{
|
|
69
|
+
"checkedAt": T0,
|
|
70
|
+
"command": "cargo test",
|
|
71
|
+
"cwd": ".",
|
|
72
|
+
"evidencePathSet": "large-change",
|
|
73
|
+
"proofs": proofs
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}),
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
pub fn large_expanded_state(admission_head: &str) -> Value {
|
|
81
|
+
let evidence: Vec<Value> = (0..12)
|
|
82
|
+
.map(|index| json!(format!("src/module_{index}.rs")))
|
|
83
|
+
.collect();
|
|
84
|
+
let proofs: Vec<Value> = (0..8)
|
|
85
|
+
.map(|index| {
|
|
86
|
+
json!({
|
|
87
|
+
"checkId": format!("check-{index}"),
|
|
88
|
+
"command": "cargo test",
|
|
89
|
+
"cwd": ".",
|
|
90
|
+
"exitCode": 0,
|
|
91
|
+
"checkedAt": T0,
|
|
92
|
+
"evidence": evidence
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
.collect();
|
|
96
|
+
base_state(
|
|
97
|
+
admission_head,
|
|
98
|
+
json!({
|
|
99
|
+
"proofResults": proofs
|
|
100
|
+
}),
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fn base_state(admission_head: &str, proof_payload: Value) -> Value {
|
|
105
|
+
let mut task = json!({
|
|
106
|
+
"id": "compact-proof",
|
|
107
|
+
"request": "Update README.",
|
|
108
|
+
"userPrompt": {
|
|
109
|
+
"receivedAt": T0,
|
|
110
|
+
"text": "Update README."
|
|
111
|
+
},
|
|
112
|
+
"admission": {
|
|
113
|
+
"command": "node .naome/bin/check-task-state.js --admission",
|
|
114
|
+
"cwd": ".",
|
|
115
|
+
"exitCode": 0,
|
|
116
|
+
"checkedAt": T0,
|
|
117
|
+
"gitHead": admission_head,
|
|
118
|
+
"changedPaths": []
|
|
119
|
+
},
|
|
120
|
+
"allowedPaths": ["README.md"],
|
|
121
|
+
"declaredChangeTypes": ["docs"],
|
|
122
|
+
"requiredCheckIds": ["alpha", "beta"],
|
|
123
|
+
"humanReview": {
|
|
124
|
+
"required": false,
|
|
125
|
+
"approved": false,
|
|
126
|
+
"reason": null
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
task.as_object_mut()
|
|
130
|
+
.unwrap()
|
|
131
|
+
.extend(proof_payload.as_object().unwrap().clone());
|
|
132
|
+
json!({
|
|
133
|
+
"schema": "naome.task-state.v2",
|
|
134
|
+
"version": 2,
|
|
135
|
+
"status": "complete",
|
|
136
|
+
"activeTask": task,
|
|
137
|
+
"blocker": null,
|
|
138
|
+
"updatedAt": T0
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fn proof(check_id: &str, command: &str, cwd: &str) -> Value {
|
|
143
|
+
json!({
|
|
144
|
+
"checkId": check_id,
|
|
145
|
+
"command": command,
|
|
146
|
+
"cwd": cwd,
|
|
147
|
+
"exitCode": 0,
|
|
148
|
+
"checkedAt": T0,
|
|
149
|
+
"evidence": ["README.md"]
|
|
150
|
+
})
|
|
151
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
mod workflow_support;
|
|
2
|
+
|
|
3
|
+
use std::fs;
|
|
4
|
+
|
|
5
|
+
use naome_core::{
|
|
6
|
+
refresh_integrity, summarize_command_output, verification_phase_plan, CommandCheckResult,
|
|
7
|
+
};
|
|
8
|
+
use serde_json::json;
|
|
9
|
+
use workflow_support::{check, phase, WorkflowFixture};
|
|
10
|
+
|
|
11
|
+
#[test]
|
|
12
|
+
fn refresh_integrity_is_idempotent_and_repairs_manifest_hash() {
|
|
13
|
+
let repo = WorkflowFixture::new("refresh-integrity");
|
|
14
|
+
repo.install_machine_owned_harness();
|
|
15
|
+
let wrong = "sha256:0000000000000000000000000000000000000000000000000000000000000000";
|
|
16
|
+
repo.write_manifest_with_integrity(wrong);
|
|
17
|
+
|
|
18
|
+
let first = refresh_integrity(repo.path()).unwrap();
|
|
19
|
+
let after_first = fs::read_to_string(repo.path().join(".naome/manifest.json")).unwrap();
|
|
20
|
+
let second = refresh_integrity(repo.path()).unwrap();
|
|
21
|
+
let after_second = fs::read_to_string(repo.path().join(".naome/manifest.json")).unwrap();
|
|
22
|
+
|
|
23
|
+
assert!(first.updated);
|
|
24
|
+
assert!(!second.updated);
|
|
25
|
+
assert_eq!(after_first, after_second);
|
|
26
|
+
assert!(!after_first.contains(wrong));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#[test]
|
|
30
|
+
fn failed_early_phase_withholds_expensive_recommendations() {
|
|
31
|
+
let repo = WorkflowFixture::new("verification-phases");
|
|
32
|
+
repo.write_verification(json!({
|
|
33
|
+
"schema": "naome.verification.v1",
|
|
34
|
+
"version": 1,
|
|
35
|
+
"status": "ready",
|
|
36
|
+
"lastUpdated": "2026-05-07",
|
|
37
|
+
"checks": [
|
|
38
|
+
check("naome-harness-health", "node .naome/bin/check-harness-health.js", "fast"),
|
|
39
|
+
check("repository-quality-check", "node .naome/bin/naome.js quality check --changed", "fast"),
|
|
40
|
+
check("package-dry-run", "npm run pack:dry-run", "medium")
|
|
41
|
+
],
|
|
42
|
+
"phases": [
|
|
43
|
+
phase("shape-health", 10, ["naome-harness-health"]),
|
|
44
|
+
phase("quality", 20, ["repository-quality-check"]),
|
|
45
|
+
phase("package-release", 50, ["package-dry-run"])
|
|
46
|
+
],
|
|
47
|
+
"changeTypes": [],
|
|
48
|
+
"releaseGates": []
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
let plan = verification_phase_plan(
|
|
52
|
+
repo.path(),
|
|
53
|
+
&[CommandCheckResult {
|
|
54
|
+
check_id: "naome-harness-health".to_string(),
|
|
55
|
+
exit_code: 1,
|
|
56
|
+
}],
|
|
57
|
+
)
|
|
58
|
+
.unwrap();
|
|
59
|
+
|
|
60
|
+
assert_eq!(plan.recommended_check_ids, vec!["naome-harness-health"]);
|
|
61
|
+
assert!(plan
|
|
62
|
+
.withheld_check_ids
|
|
63
|
+
.contains(&"package-dry-run".to_string()));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[test]
|
|
67
|
+
fn long_command_output_is_stably_summarized() {
|
|
68
|
+
let output = (0..80)
|
|
69
|
+
.map(|index| {
|
|
70
|
+
if index == 42 {
|
|
71
|
+
"error: src/main.rs failed to compile".to_string()
|
|
72
|
+
} else {
|
|
73
|
+
format!("line {index}")
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.collect::<Vec<_>>()
|
|
77
|
+
.join("\n");
|
|
78
|
+
|
|
79
|
+
let summary = summarize_command_output("cargo test", ".", 101, &output, 8);
|
|
80
|
+
|
|
81
|
+
assert!(summary.truncated);
|
|
82
|
+
assert_eq!(summary.exit_code, 101);
|
|
83
|
+
assert!(summary.relevant_lines[0].contains("error: src/main.rs"));
|
|
84
|
+
assert!(summary.affected_paths.contains(&"src/main.rs".to_string()));
|
|
85
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
mod workflow_support;
|
|
2
|
+
|
|
3
|
+
use std::collections::HashMap;
|
|
4
|
+
|
|
5
|
+
use naome_core::{
|
|
6
|
+
classify_mutations, safe_rg_args, tracked_process_report, validate_read_boundaries,
|
|
7
|
+
validate_search_command, validate_task_state, ReadActivity, TaskStateMode, TaskStateOptions,
|
|
8
|
+
};
|
|
9
|
+
use serde_json::json;
|
|
10
|
+
use workflow_support::WorkflowFixture;
|
|
11
|
+
|
|
12
|
+
#[test]
|
|
13
|
+
fn read_boundary_violation_is_detected_from_activity() {
|
|
14
|
+
let repo = WorkflowFixture::new("read-boundary");
|
|
15
|
+
repo.write(".naomeignore", ".naome/archive/\n.local-cache/\n");
|
|
16
|
+
|
|
17
|
+
let findings = validate_read_boundaries(
|
|
18
|
+
repo.path(),
|
|
19
|
+
&[ReadActivity {
|
|
20
|
+
command: "rg --hidden panic .".to_string(),
|
|
21
|
+
paths: vec![".naome/archive/old-task.json".to_string()],
|
|
22
|
+
}],
|
|
23
|
+
)
|
|
24
|
+
.unwrap();
|
|
25
|
+
|
|
26
|
+
assert_eq!(findings[0].check_id, "read-boundary");
|
|
27
|
+
assert!(findings[0]
|
|
28
|
+
.paths
|
|
29
|
+
.contains(&".naome/archive/old-task.json".to_string()));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[test]
|
|
33
|
+
fn safe_search_profile_excludes_default_boundaries() {
|
|
34
|
+
let repo = WorkflowFixture::new("safe-search-profile");
|
|
35
|
+
repo.write(".naomeignore", ".naome/archive/\n.local-cache/\n");
|
|
36
|
+
|
|
37
|
+
let args = safe_rg_args(repo.path()).unwrap().join(" ");
|
|
38
|
+
|
|
39
|
+
assert!(args.contains("!.git/**"));
|
|
40
|
+
assert!(args.contains("!.naome/archive/**"));
|
|
41
|
+
assert!(args.contains("!node_modules/**"));
|
|
42
|
+
assert!(args.contains("!.local-cache/**"));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[test]
|
|
46
|
+
fn unsafe_hidden_search_is_workflow_finding() {
|
|
47
|
+
let repo = WorkflowFixture::new("unsafe-search");
|
|
48
|
+
|
|
49
|
+
let findings = validate_search_command(repo.path(), "rg --hidden TODO .").unwrap();
|
|
50
|
+
|
|
51
|
+
assert!(findings
|
|
52
|
+
.iter()
|
|
53
|
+
.any(|finding| finding.check_id == "unsafe-search-command"));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#[test]
|
|
57
|
+
fn scope_drift_is_reported_during_progress_gate() {
|
|
58
|
+
let repo = WorkflowFixture::new("scope-drift");
|
|
59
|
+
repo.init_git();
|
|
60
|
+
repo.write_task_state("implementing", &["src/owned.rs"], &["diff-check"]);
|
|
61
|
+
repo.write("src/outside.rs", "pub fn outside() {}\n");
|
|
62
|
+
|
|
63
|
+
let report = validate_task_state(
|
|
64
|
+
repo.path(),
|
|
65
|
+
TaskStateOptions {
|
|
66
|
+
mode: TaskStateMode::Progress,
|
|
67
|
+
..TaskStateOptions::default()
|
|
68
|
+
},
|
|
69
|
+
)
|
|
70
|
+
.unwrap();
|
|
71
|
+
let joined = report.errors.join("\n");
|
|
72
|
+
|
|
73
|
+
assert!(joined.contains("Changed files outside allowedPaths"));
|
|
74
|
+
assert!(joined.contains("src/outside.rs"));
|
|
75
|
+
assert!(joined.contains("request_scope_change"));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[test]
|
|
79
|
+
fn tracked_running_process_blocks_completion_until_documented() {
|
|
80
|
+
let repo = WorkflowFixture::new("process-tracking");
|
|
81
|
+
repo.write(
|
|
82
|
+
".naome/processes.json",
|
|
83
|
+
&format!(
|
|
84
|
+
"{}\n",
|
|
85
|
+
serde_json::to_string_pretty(&json!({
|
|
86
|
+
"schema": "naome.processes.v1",
|
|
87
|
+
"processes": [{
|
|
88
|
+
"pid": std::process::id(),
|
|
89
|
+
"command": "npm run dev",
|
|
90
|
+
"cwd": ".",
|
|
91
|
+
"startedAt": "2026-05-07T12:00:00.000Z",
|
|
92
|
+
"status": "running",
|
|
93
|
+
"allowAfterCompletion": false
|
|
94
|
+
}]
|
|
95
|
+
}))
|
|
96
|
+
.unwrap()
|
|
97
|
+
),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
let report = tracked_process_report(repo.path()).unwrap();
|
|
101
|
+
|
|
102
|
+
assert_eq!(report.active.len(), 1);
|
|
103
|
+
assert!(report.active[0].command.contains("npm run dev"));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#[test]
|
|
107
|
+
fn mutation_classifier_recognizes_core_classes() {
|
|
108
|
+
let repo = WorkflowFixture::new("mutation-classes");
|
|
109
|
+
|
|
110
|
+
let classes = classify_mutations(
|
|
111
|
+
repo.path(),
|
|
112
|
+
&[
|
|
113
|
+
"src/lib.rs".to_string(),
|
|
114
|
+
".naome/manifest.json".to_string(),
|
|
115
|
+
".naome/archive/repair/AGENTS.md".to_string(),
|
|
116
|
+
"coverage/report.json".to_string(),
|
|
117
|
+
"packages/naome/native/darwin-arm64/naome".to_string(),
|
|
118
|
+
"notes/manual.md".to_string(),
|
|
119
|
+
],
|
|
120
|
+
)
|
|
121
|
+
.unwrap();
|
|
122
|
+
let by_path = classes
|
|
123
|
+
.iter()
|
|
124
|
+
.map(|entry| (entry.path.as_str(), entry.mutation_class.as_str()))
|
|
125
|
+
.collect::<HashMap<_, _>>();
|
|
126
|
+
|
|
127
|
+
assert_eq!(by_path["src/lib.rs"], "source change");
|
|
128
|
+
assert_eq!(by_path[".naome/manifest.json"], "generated refresh");
|
|
129
|
+
assert_eq!(
|
|
130
|
+
by_path[".naome/archive/repair/AGENTS.md"],
|
|
131
|
+
"local-only repair"
|
|
132
|
+
);
|
|
133
|
+
assert_eq!(by_path["coverage/report.json"], "test artifact");
|
|
134
|
+
assert_eq!(
|
|
135
|
+
by_path["packages/naome/native/darwin-arm64/naome"],
|
|
136
|
+
"release artifact"
|
|
137
|
+
);
|
|
138
|
+
assert_eq!(by_path["notes/manual.md"], "user edit");
|
|
139
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
use std::path::{Path, PathBuf};
|
|
3
|
+
use std::process::Command;
|
|
4
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
5
|
+
use std::time::{SystemTime, UNIX_EPOCH};
|
|
6
|
+
|
|
7
|
+
use serde_json::json;
|
|
8
|
+
|
|
9
|
+
static FIXTURE_COUNTER: AtomicU64 = AtomicU64::new(0);
|
|
10
|
+
|
|
11
|
+
pub struct WorkflowFixture {
|
|
12
|
+
root: PathBuf,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
impl WorkflowFixture {
|
|
16
|
+
pub fn new(name: &str) -> Self {
|
|
17
|
+
let nonce = SystemTime::now()
|
|
18
|
+
.duration_since(UNIX_EPOCH)
|
|
19
|
+
.unwrap()
|
|
20
|
+
.as_nanos();
|
|
21
|
+
let root = std::env::temp_dir().join(format!(
|
|
22
|
+
"naome-workflow-{name}-{}-{}-{nonce}",
|
|
23
|
+
std::process::id(),
|
|
24
|
+
FIXTURE_COUNTER.fetch_add(1, Ordering::SeqCst)
|
|
25
|
+
));
|
|
26
|
+
fs::create_dir_all(root.join(".naome")).unwrap();
|
|
27
|
+
fs::create_dir_all(root.join("docs/naome")).unwrap();
|
|
28
|
+
let fixture = Self { root };
|
|
29
|
+
fixture.write(".naomeignore", ".naome/archive/\n");
|
|
30
|
+
fixture.write(
|
|
31
|
+
".naome/init-state.json",
|
|
32
|
+
"{\"initialized\":true,\"intakeStatus\":\"complete\"}\n",
|
|
33
|
+
);
|
|
34
|
+
fixture.write(".naome/upgrade-state.json", "{\"status\":\"complete\"}\n");
|
|
35
|
+
fixture.write_verification(default_verification());
|
|
36
|
+
fixture
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub fn path(&self) -> &Path {
|
|
40
|
+
&self.root
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pub fn init_git(&self) {
|
|
44
|
+
run_git(&self.root, &["init"]);
|
|
45
|
+
run_git(&self.root, &["config", "user.email", "test@example.com"]);
|
|
46
|
+
run_git(&self.root, &["config", "user.name", "Test User"]);
|
|
47
|
+
self.write("README.md", "# Baseline\n");
|
|
48
|
+
run_git(&self.root, &["add", "."]);
|
|
49
|
+
run_git(&self.root, &["commit", "-m", "baseline"]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pub fn install_machine_owned_harness(&self) {
|
|
53
|
+
for path in ["AGENTS.md", ".naome/bin/naome.js", "docs/naome/index.md"] {
|
|
54
|
+
self.write(path, &format!("# {path}\n"));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pub fn write_manifest_with_integrity(&self, integrity: &str) {
|
|
59
|
+
self.write(
|
|
60
|
+
".naome/manifest.json",
|
|
61
|
+
&pretty(json!({
|
|
62
|
+
"name": "naome",
|
|
63
|
+
"harnessVersion": "1.2.0",
|
|
64
|
+
"profile": "standard",
|
|
65
|
+
"installedAt": null,
|
|
66
|
+
"machineOwned": ["AGENTS.md", ".naome/bin/naome.js", "docs/naome/index.md"],
|
|
67
|
+
"projectOwned": [".naome/manifest.json"],
|
|
68
|
+
"integrity": {
|
|
69
|
+
"AGENTS.md": integrity,
|
|
70
|
+
".naome/bin/naome.js": integrity,
|
|
71
|
+
"docs/naome/index.md": integrity
|
|
72
|
+
}
|
|
73
|
+
})),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
pub fn write_task_state(&self, status: &str, allowed_paths: &[&str], checks: &[&str]) {
|
|
78
|
+
let active_task = active_task_state(
|
|
79
|
+
allowed_paths,
|
|
80
|
+
checks,
|
|
81
|
+
git_text(&self.root, &["rev-parse", "HEAD"]),
|
|
82
|
+
);
|
|
83
|
+
self.write(
|
|
84
|
+
".naome/task-state.json",
|
|
85
|
+
&pretty(json!({
|
|
86
|
+
"schema": "naome.task-state.v2",
|
|
87
|
+
"version": 2,
|
|
88
|
+
"status": status,
|
|
89
|
+
"activeTask": active_task,
|
|
90
|
+
"blocker": null,
|
|
91
|
+
"updatedAt": "2026-05-07T12:00:00.000Z"
|
|
92
|
+
})),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
pub fn write_verification(&self, value: serde_json::Value) {
|
|
97
|
+
self.write(".naome/verification.json", &pretty(value));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pub fn write(&self, relative_path: &str, content: &str) {
|
|
101
|
+
let path = self.root.join(relative_path);
|
|
102
|
+
if let Some(parent) = path.parent() {
|
|
103
|
+
fs::create_dir_all(parent).unwrap();
|
|
104
|
+
}
|
|
105
|
+
fs::write(path, content).unwrap();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
impl Drop for WorkflowFixture {
|
|
110
|
+
fn drop(&mut self) {
|
|
111
|
+
let _ = fs::remove_dir_all(&self.root);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
pub fn default_verification() -> serde_json::Value {
|
|
116
|
+
json!({
|
|
117
|
+
"schema": "naome.verification.v1",
|
|
118
|
+
"version": 1,
|
|
119
|
+
"status": "ready",
|
|
120
|
+
"lastUpdated": "2026-05-07",
|
|
121
|
+
"checks": [check("diff-check", "git diff --check", "fast")],
|
|
122
|
+
"changeTypes": [],
|
|
123
|
+
"releaseGates": []
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
pub fn check(id: &str, command: &str, cost: &str) -> serde_json::Value {
|
|
128
|
+
json!({
|
|
129
|
+
"id": id,
|
|
130
|
+
"command": command,
|
|
131
|
+
"cwd": ".",
|
|
132
|
+
"purpose": "Test check.",
|
|
133
|
+
"cost": cost,
|
|
134
|
+
"source": "test",
|
|
135
|
+
"evidence": [],
|
|
136
|
+
"lastVerified": null
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
pub fn phase<const N: usize>(id: &str, order: usize, check_ids: [&str; N]) -> serde_json::Value {
|
|
141
|
+
json!({ "id": id, "order": order, "checkIds": check_ids.to_vec() })
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
fn active_task_state(
|
|
145
|
+
allowed_paths: &[&str],
|
|
146
|
+
checks: &[&str],
|
|
147
|
+
git_head: String,
|
|
148
|
+
) -> serde_json::Value {
|
|
149
|
+
json!({
|
|
150
|
+
"id": "workflow-test",
|
|
151
|
+
"request": "Test workflow gates.",
|
|
152
|
+
"userPrompt": { "receivedAt": "2026-05-07T12:00:00.000Z", "text": "Test workflow gates." },
|
|
153
|
+
"admission": admission_record(git_head),
|
|
154
|
+
"allowedPaths": allowed_paths,
|
|
155
|
+
"declaredChangeTypes": ["source"],
|
|
156
|
+
"requiredCheckIds": checks,
|
|
157
|
+
"humanReview": { "required": false, "approved": false, "reason": null },
|
|
158
|
+
"proofResults": []
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
fn admission_record(git_head: String) -> serde_json::Value {
|
|
163
|
+
json!({
|
|
164
|
+
"command": "node .naome/bin/check-task-state.js --admission",
|
|
165
|
+
"cwd": ".",
|
|
166
|
+
"exitCode": 0,
|
|
167
|
+
"checkedAt": "2026-05-07T12:00:00.000Z",
|
|
168
|
+
"gitHead": git_head,
|
|
169
|
+
"changedPaths": []
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
fn pretty(value: serde_json::Value) -> String {
|
|
174
|
+
format!("{}\n", serde_json::to_string_pretty(&value).unwrap())
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
fn run_git(root: &Path, args: &[&str]) {
|
|
178
|
+
let output = Command::new("git")
|
|
179
|
+
.args(args)
|
|
180
|
+
.current_dir(root)
|
|
181
|
+
.output()
|
|
182
|
+
.unwrap();
|
|
183
|
+
assert!(output.status.success(), "git {} failed", args.join(" "));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
fn git_text(root: &Path, args: &[&str]) -> String {
|
|
187
|
+
let output = Command::new("git")
|
|
188
|
+
.args(args)
|
|
189
|
+
.current_dir(root)
|
|
190
|
+
.output()
|
|
191
|
+
.unwrap();
|
|
192
|
+
assert!(output.status.success());
|
|
193
|
+
String::from_utf8_lossy(&output.stdout).trim().to_string()
|
|
194
|
+
}
|
|
Binary file
|
package/native/linux-x64/naome
CHANGED
|
Binary file
|
package/package.json
CHANGED