@lamentis/naome 1.1.2 → 1.2.1
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-node.js +2 -1579
- package/bin/naome.js +68 -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 +37 -0
- package/crates/naome-cli/src/install_bridge.rs +83 -0
- package/crates/naome-cli/src/main.rs +60 -341
- package/crates/naome-cli/src/prompt_commands.rs +68 -0
- package/crates/naome-cli/src/quality_commands.rs +229 -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/decision/checks.rs +64 -0
- package/crates/naome-core/src/decision/idle.rs +67 -0
- package/crates/naome-core/src/decision/json.rs +36 -0
- package/crates/naome-core/src/decision/states.rs +165 -0
- package/crates/naome-core/src/decision.rs +131 -353
- 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 +5 -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 +15 -0
- package/crates/naome-core/src/paths.rs +3 -1
- package/crates/naome-core/src/quality/adapter_support.rs +89 -0
- package/crates/naome-core/src/quality/adapters.rs +131 -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 +84 -0
- package/crates/naome-core/src/quality/config.rs +102 -0
- package/crates/naome-core/src/quality/config_support.rs +24 -0
- package/crates/naome-core/src/quality/mod.rs +108 -0
- package/crates/naome-core/src/quality/scanner/repo_paths.rs +103 -0
- package/crates/naome-core/src/quality/scanner.rs +379 -0
- package/crates/naome-core/src/quality/structure/adapters.rs +84 -0
- package/crates/naome-core/src/quality/structure/checks/basic.rs +153 -0
- package/crates/naome-core/src/quality/structure/checks/directory.rs +144 -0
- package/crates/naome-core/src/quality/structure/checks/pairing.rs +63 -0
- package/crates/naome-core/src/quality/structure/checks.rs +124 -0
- package/crates/naome-core/src/quality/structure/classify/roles.rs +188 -0
- package/crates/naome-core/src/quality/structure/classify.rs +94 -0
- package/crates/naome-core/src/quality/structure/config.rs +89 -0
- package/crates/naome-core/src/quality/structure/defaults.rs +107 -0
- package/crates/naome-core/src/quality/structure/mod.rs +77 -0
- package/crates/naome-core/src/quality/structure/model.rs +124 -0
- package/crates/naome-core/src/quality/types.rs +292 -0
- package/crates/naome-core/src/route/builtin_checks.rs +155 -0
- package/crates/naome-core/src/route/builtin_context.rs +73 -0
- package/crates/naome-core/src/route/builtin_integrity.rs +49 -0
- package/crates/naome-core/src/route/builtin_require.rs +40 -0
- package/crates/naome-core/src/route/context.rs +180 -0
- package/crates/naome-core/src/route/execution.rs +96 -0
- package/crates/naome-core/src/route/execution_baselines.rs +146 -0
- package/crates/naome-core/src/route/execution_support.rs +57 -0
- package/crates/naome-core/src/route/execution_tasks.rs +71 -0
- package/crates/naome-core/src/route/git_ops.rs +72 -0
- package/crates/naome-core/src/route/quality_gate.rs +73 -0
- package/crates/naome-core/src/route/quality_gate_config.rs +126 -0
- package/crates/naome-core/src/route/quality_gate_snapshot.rs +69 -0
- package/crates/naome-core/src/route/worktree.rs +75 -0
- package/crates/naome-core/src/route/worktree_files.rs +32 -0
- package/crates/naome-core/src/route/worktree_plan.rs +131 -0
- package/crates/naome-core/src/route.rs +44 -1155
- 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 +177 -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/decision.rs +24 -118
- package/crates/naome-core/tests/harness_health.rs +5 -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 +319 -0
- package/crates/naome-core/tests/quality_structure.rs +116 -0
- package/crates/naome-core/tests/quality_structure_adapters.rs +98 -0
- package/crates/naome-core/tests/quality_structure_policy.rs +125 -0
- package/crates/naome-core/tests/quality_structure_support/mod.rs +249 -0
- package/crates/naome-core/tests/repo_support/mod.rs +16 -0
- package/crates/naome-core/tests/repo_support/repo.rs +113 -0
- package/crates/naome-core/tests/repo_support/repo_factories.rs +99 -0
- package/crates/naome-core/tests/repo_support/repo_helpers.rs +123 -0
- package/crates/naome-core/tests/repo_support/routes.rs +81 -0
- package/crates/naome-core/tests/repo_support/verification.rs +168 -0
- package/crates/naome-core/tests/repo_support/verification_values.rs +135 -0
- package/crates/naome-core/tests/route.rs +1 -1476
- package/crates/naome-core/tests/route_baseline.rs +86 -0
- package/crates/naome-core/tests/route_completion.rs +141 -0
- package/crates/naome-core/tests/route_harness_refresh.rs +135 -0
- package/crates/naome-core/tests/route_user_diff.rs +198 -0
- package/crates/naome-core/tests/route_worktree.rs +54 -0
- package/crates/naome-core/tests/task_state.rs +60 -429
- 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/task_state_support/mod.rs +163 -0
- package/crates/naome-core/tests/task_state_support/states.rs +84 -0
- package/crates/naome-core/tests/verification.rs +4 -45
- package/crates/naome-core/tests/verification_contract.rs +22 -78
- 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/installer/agents.js +90 -0
- package/installer/context.js +67 -0
- package/installer/filesystem.js +166 -0
- package/installer/flows.js +84 -0
- package/installer/git-boundary.js +170 -0
- package/installer/git-hook-content.js +36 -0
- package/installer/git-hooks.js +134 -0
- package/installer/git-local.js +2 -0
- package/installer/git-shared.js +35 -0
- package/installer/harness-file-ops.js +140 -0
- package/installer/harness-files.js +56 -0
- package/installer/harness-verification.js +123 -0
- package/installer/install-plan.js +66 -0
- package/installer/main.js +25 -0
- package/installer/manifest-state.js +167 -0
- package/installer/native-build.js +24 -0
- package/installer/native-format.js +6 -0
- package/installer/native.js +162 -0
- package/installer/output.js +131 -0
- package/installer/version.js +32 -0
- package/native/darwin-arm64/naome +0 -0
- package/native/linux-x64/naome +0 -0
- package/package.json +3 -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 +51 -76
- package/templates/naome-root/.naome/manifest.json +22 -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/repository-structure.json +90 -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 +38 -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 +5 -3
- package/templates/naome-root/docs/naome/repository-quality.md +46 -0
- package/templates/naome-root/docs/naome/repository-structure.md +51 -0
- package/templates/naome-root/docs/naome/testing.md +13 -0
- package/crates/naome-core/src/task_state.rs +0 -2210
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#![allow(dead_code)]
|
|
2
|
+
|
|
3
|
+
use std::fs;
|
|
4
|
+
use std::path::PathBuf;
|
|
5
|
+
use std::process::{Command, Output};
|
|
6
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
7
|
+
use std::time::{SystemTime, UNIX_EPOCH};
|
|
8
|
+
|
|
9
|
+
use naome_core::{evaluate_intent, EvaluationOptions, IntentDecision};
|
|
10
|
+
use serde_json::{json, Value};
|
|
11
|
+
|
|
12
|
+
static REPO_COUNTER: AtomicU64 = AtomicU64::new(0);
|
|
13
|
+
|
|
14
|
+
pub fn env(prompt: &str, workflow: &str, task: &str, risk: &str) -> String {
|
|
15
|
+
format!(
|
|
16
|
+
"```naome-intent-v2\n{{\"schema\":\"naome.intent.v2\",\"workflowAction\":\"{workflow}\",\"taskIntent\":\"{task}\",\"risk\":\"{risk}\"}}\n```\n\n{prompt}"
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pub fn idle() -> Value {
|
|
21
|
+
json!({ "status": "idle", "activeTask": null })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pub fn completed_state(head: &str, valid: bool) -> Value {
|
|
25
|
+
let proof = if valid {
|
|
26
|
+
r#"[{"checkId":"diff-check","command":"git diff --check","cwd":".","exitCode":0,"checkedAt":"2026-05-06T00:00:00.000Z","evidence":["README.md"]}]"#
|
|
27
|
+
} else {
|
|
28
|
+
"[]"
|
|
29
|
+
};
|
|
30
|
+
serde_json::from_str(&format!(r#"{{"schema":"naome.task-state.v1","version":1,"status":"complete","activeTask":{{"id":"readme-task","request":"Change README.","userPrompt":{{"receivedAt":"2026-05-06T00:00:00.000Z","text":"Change README."}},"admission":{{"command":"node .naome/bin/check-task-state.js --admission","cwd":".","exitCode":0,"checkedAt":"2026-05-06T00:00:00.000Z","gitHead":"{head}","changedPaths":[]}},"allowedPaths":["README.md"],"declaredChangeTypes":["product-docs"],"requiredCheckIds":["diff-check"],"proofResults":{proof},"revisions":[],"humanReview":{{"required":false,"approved":false,"reason":null}}}},"blocker":null,"updatedAt":"2026-05-06T00:00:00.000Z"}}"#)).unwrap()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pub struct Repo {
|
|
34
|
+
root: PathBuf,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
impl Repo {
|
|
38
|
+
pub fn clean(name: &str, state: Value) -> Self {
|
|
39
|
+
let repo = Self::new(name);
|
|
40
|
+
repo.git(["init"]);
|
|
41
|
+
repo.git(["config", "user.email", "naome@example.com"]);
|
|
42
|
+
repo.git(["config", "user.name", "NAOME Test"]);
|
|
43
|
+
repo.write("README.md", "# Baseline\n");
|
|
44
|
+
repo.write_base(state);
|
|
45
|
+
repo.git(["add", "."]);
|
|
46
|
+
repo.git(["commit", "-m", "baseline"]);
|
|
47
|
+
repo
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
pub fn completed(name: &str, valid: bool) -> Self {
|
|
51
|
+
let repo = Self::clean(name, idle());
|
|
52
|
+
let head = repo.git_stdout(["rev-parse", "HEAD"]);
|
|
53
|
+
repo.write_base(completed_state(&head, valid));
|
|
54
|
+
repo.git(["add", ".naome/task-state.json"]);
|
|
55
|
+
repo.git(["commit", "-m", "task state"]);
|
|
56
|
+
repo.write("README.md", "# Changed\n");
|
|
57
|
+
repo
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
pub fn intent(&self, prompt: &str) -> IntentDecision {
|
|
61
|
+
evaluate_intent(&self.root, prompt, EvaluationOptions::offline()).unwrap()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
pub fn write(&self, path: &str, content: &str) {
|
|
65
|
+
let path = self.root.join(path);
|
|
66
|
+
if let Some(parent) = path.parent() {
|
|
67
|
+
fs::create_dir_all(parent).unwrap();
|
|
68
|
+
}
|
|
69
|
+
fs::write(path, content).unwrap();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fn new(name: &str) -> Self {
|
|
73
|
+
let nonce = SystemTime::now()
|
|
74
|
+
.duration_since(UNIX_EPOCH)
|
|
75
|
+
.unwrap()
|
|
76
|
+
.as_nanos();
|
|
77
|
+
let root = std::env::temp_dir().join(format!(
|
|
78
|
+
"naome-intent-{name}-{}-{}-{nonce}",
|
|
79
|
+
std::process::id(),
|
|
80
|
+
REPO_COUNTER.fetch_add(1, Ordering::SeqCst)
|
|
81
|
+
));
|
|
82
|
+
fs::create_dir_all(root.join(".naome")).unwrap();
|
|
83
|
+
Self { root }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fn write_base(&self, state: Value) {
|
|
87
|
+
self.write_json(
|
|
88
|
+
"init-state.json",
|
|
89
|
+
json!({ "initialized": true, "intakeStatus": "complete" }),
|
|
90
|
+
);
|
|
91
|
+
self.write_json("upgrade-state.json", json!({ "status": "complete" }));
|
|
92
|
+
self.write_json("verification.json", verification());
|
|
93
|
+
self.write_json("task-state.json", state);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fn write_json(&self, name: &str, value: Value) {
|
|
97
|
+
self.write(
|
|
98
|
+
&format!(".naome/{name}"),
|
|
99
|
+
&format!("{}\n", serde_json::to_string_pretty(&value).unwrap()),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fn git<const N: usize>(&self, args: [&str; N]) {
|
|
104
|
+
let output = self.git_output(args);
|
|
105
|
+
assert!(
|
|
106
|
+
output.status.success(),
|
|
107
|
+
"git failed: {}",
|
|
108
|
+
String::from_utf8_lossy(&output.stderr)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fn git_stdout<const N: usize>(&self, args: [&str; N]) -> String {
|
|
113
|
+
let output = self.git_output(args);
|
|
114
|
+
assert!(output.status.success());
|
|
115
|
+
String::from_utf8(output.stdout).unwrap().trim().to_owned()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn git_output<const N: usize>(&self, args: [&str; N]) -> Output {
|
|
119
|
+
let mut command = Command::new("git");
|
|
120
|
+
command.current_dir(&self.root).args(args);
|
|
121
|
+
command.output().unwrap()
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
impl Drop for Repo {
|
|
126
|
+
fn drop(&mut self) {
|
|
127
|
+
let _ = fs::remove_dir_all(&self.root);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fn verification() -> Value {
|
|
132
|
+
serde_json::from_str(r#"{"schema":"naome.verification.v1","version":1,"status":"ready","checks":[{"id":"diff-check","command":"git diff --check","cwd":".","purpose":"Reject whitespace errors.","cost":"fast","source":"test","evidence":["README.md"],"lastVerified":null}],"changeTypes":[],"releaseGates":[]}"#).unwrap()
|
|
133
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
mod intent_support;
|
|
2
|
+
|
|
3
|
+
use intent_support::{env, idle, Repo};
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn feature_descriptions_with_workflow_terms_route_as_new_tasks() {
|
|
7
|
+
let repo = Repo::clean("intent-v2-feature-terms", idle());
|
|
8
|
+
for prompt in [
|
|
9
|
+
"Add a context budget dashboard to the product.",
|
|
10
|
+
"Build a commit gate simulator feature for docs.",
|
|
11
|
+
"Implement a review findings feature for pull request analysis.",
|
|
12
|
+
"Create a baseline flow visualization in the UI.",
|
|
13
|
+
] {
|
|
14
|
+
let intent = repo.intent(prompt);
|
|
15
|
+
assert_eq!(intent.prompt_intent, "new_task", "{prompt}");
|
|
16
|
+
assert_eq!(intent.policy_action, "create_new_task", "{prompt}");
|
|
17
|
+
assert!(!intent.evidence.requests_commit, "{prompt}");
|
|
18
|
+
assert!(!intent.evidence.requests_review, "{prompt}");
|
|
19
|
+
assert!(!intent.evidence.has_risky_terms, "{prompt}");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
fn enveloped_workflow_requests_keep_their_intent() {
|
|
25
|
+
let repo = Repo::clean("intent-v2-direct-workflow", idle());
|
|
26
|
+
let commit = repo.intent(&env(
|
|
27
|
+
"please commit the current task",
|
|
28
|
+
"commit_request",
|
|
29
|
+
"none",
|
|
30
|
+
"none",
|
|
31
|
+
));
|
|
32
|
+
assert_eq!(commit.prompt_intent, "commit_request");
|
|
33
|
+
assert!(commit.evidence.requests_commit);
|
|
34
|
+
|
|
35
|
+
let review = repo.intent(&env(
|
|
36
|
+
"review the current diff",
|
|
37
|
+
"review_request",
|
|
38
|
+
"none",
|
|
39
|
+
"none",
|
|
40
|
+
));
|
|
41
|
+
assert_eq!(review.prompt_intent, "review_request");
|
|
42
|
+
assert!(review.evidence.requests_review);
|
|
43
|
+
|
|
44
|
+
let status = repo.intent(&env("show status", "status_question", "none", "none"));
|
|
45
|
+
assert_eq!(status.prompt_intent, "status_question");
|
|
46
|
+
assert_eq!(status.policy_action, "answer_status_only");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#[test]
|
|
50
|
+
fn envelope_is_canonical_over_legacy_prompt_words() {
|
|
51
|
+
let repo = Repo::clean("intent-v2-envelope-canonical", idle());
|
|
52
|
+
let intent = repo.intent(&env(
|
|
53
|
+
"please commit the current task",
|
|
54
|
+
"none",
|
|
55
|
+
"new_task",
|
|
56
|
+
"none",
|
|
57
|
+
));
|
|
58
|
+
assert_eq!(intent.prompt_intent, "new_task");
|
|
59
|
+
assert!(!intent.evidence.requests_commit);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[test]
|
|
63
|
+
fn token_boundaries_and_code_segments_avoid_false_workflow_actions() {
|
|
64
|
+
let repo = Repo::clean("intent-v2-segments", idle());
|
|
65
|
+
let async_intent = repo.intent("Add async sync-state naming examples to the documentation.");
|
|
66
|
+
assert_eq!(async_intent.prompt_intent, "new_task");
|
|
67
|
+
assert!(!async_intent.evidence.requests_repair);
|
|
68
|
+
|
|
69
|
+
let code_intent =
|
|
70
|
+
repo.intent("Add docs with examples like `naome commit` and ```sh\ngit push\n```.");
|
|
71
|
+
assert_eq!(code_intent.prompt_intent, "new_task");
|
|
72
|
+
assert!(!code_intent.evidence.requests_commit);
|
|
73
|
+
assert!(!code_intent.evidence.has_risky_terms);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[test]
|
|
77
|
+
fn explicit_credential_context_still_routes_as_unsafe() {
|
|
78
|
+
let repo = Repo::clean("intent-v2-risk", idle());
|
|
79
|
+
let intent = repo.intent(&env(
|
|
80
|
+
"Commit the current token and API key so the deployment can use the secret.",
|
|
81
|
+
"commit_request",
|
|
82
|
+
"none",
|
|
83
|
+
"credential_context",
|
|
84
|
+
));
|
|
85
|
+
assert_eq!(intent.prompt_intent, "unsafe");
|
|
86
|
+
assert!(intent.evidence.has_risky_terms);
|
|
87
|
+
assert!(intent
|
|
88
|
+
.risk_codes
|
|
89
|
+
.contains(&"prompt_contains_risky_terms".to_string()));
|
|
90
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
|
|
3
|
+
use naome_core::{
|
|
4
|
+
check_repository_quality, init_repository_quality, plan_quality_cleanup, route_quality_cleanup,
|
|
5
|
+
seed_builtin_verification_checks, QualityMode,
|
|
6
|
+
};
|
|
7
|
+
use serde_json::Value;
|
|
8
|
+
|
|
9
|
+
mod quality_structure_support;
|
|
10
|
+
|
|
11
|
+
use quality_structure_support::StructureFixture as QualityFixture;
|
|
12
|
+
|
|
13
|
+
#[test]
|
|
14
|
+
fn changed_check_blocks_touched_legacy_file_until_it_conforms() {
|
|
15
|
+
let repo = QualityFixture::new("quality-touched-legacy");
|
|
16
|
+
repo.write_quality_limits(5, 40, 4);
|
|
17
|
+
repo.write(
|
|
18
|
+
"src/large.js",
|
|
19
|
+
"export function legacy() {\n one();\n two();\n three();\n four();\n}\n",
|
|
20
|
+
);
|
|
21
|
+
repo.commit_all("legacy baseline");
|
|
22
|
+
|
|
23
|
+
repo.write(
|
|
24
|
+
"src/large.js",
|
|
25
|
+
"export function legacy() {\n one();\n two();\n three();\n four();\n five();\n}\n",
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
29
|
+
|
|
30
|
+
assert!(!report.ok);
|
|
31
|
+
assert!(report
|
|
32
|
+
.violations
|
|
33
|
+
.iter()
|
|
34
|
+
.any(|violation| violation.path == "src/large.js" && violation.check_id == "file-length"));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[test]
|
|
38
|
+
fn whole_repo_debt_is_visible_without_blocking_clean_changed_check() {
|
|
39
|
+
let repo = QualityFixture::new("quality-clean-legacy-report");
|
|
40
|
+
repo.write_quality_limits(5, 40, 4);
|
|
41
|
+
repo.write(
|
|
42
|
+
"src/large.js",
|
|
43
|
+
"export function legacy() {\n one();\n two();\n three();\n four();\n}\n",
|
|
44
|
+
);
|
|
45
|
+
repo.commit_all("legacy baseline");
|
|
46
|
+
|
|
47
|
+
let changed = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
48
|
+
let full = check_repository_quality(repo.path(), QualityMode::Report).unwrap();
|
|
49
|
+
|
|
50
|
+
assert!(changed.ok);
|
|
51
|
+
assert!(changed.violations.is_empty());
|
|
52
|
+
assert!(!full.ok);
|
|
53
|
+
assert!(full
|
|
54
|
+
.violations
|
|
55
|
+
.iter()
|
|
56
|
+
.any(|violation| violation.path == "src/large.js" && violation.check_id == "file-length"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#[test]
|
|
60
|
+
fn changed_check_blocks_new_duplicate_blocks_against_existing_code() {
|
|
61
|
+
let repo = QualityFixture::new("quality-duplicate-block");
|
|
62
|
+
repo.write_quality_limits(200, 40, 4);
|
|
63
|
+
repo.write(
|
|
64
|
+
"src/existing.js",
|
|
65
|
+
"export function existing() {\n const alpha = input.alpha;\n const beta = input.beta;\n const total = alpha + beta;\n return total;\n}\n",
|
|
66
|
+
);
|
|
67
|
+
repo.commit_all("existing helper");
|
|
68
|
+
|
|
69
|
+
repo.write(
|
|
70
|
+
"src/copied.js",
|
|
71
|
+
"export function copied() {\n const alpha = input.alpha;\n const beta = input.beta;\n const total = alpha + beta;\n return total;\n}\n",
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
75
|
+
|
|
76
|
+
assert!(!report.ok);
|
|
77
|
+
assert!(report.violations.iter().any(|violation| {
|
|
78
|
+
violation.path == "src/copied.js"
|
|
79
|
+
&& violation.check_id == "duplicate-blocks"
|
|
80
|
+
&& violation
|
|
81
|
+
.related_paths
|
|
82
|
+
.contains(&"src/existing.js".to_string())
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[test]
|
|
87
|
+
fn duplicate_blocks_report_one_finding_per_overlapping_region() {
|
|
88
|
+
let repo = QualityFixture::new("quality-duplicate-region");
|
|
89
|
+
repo.write_quality_limits(200, 80, 4);
|
|
90
|
+
repo.write(
|
|
91
|
+
"src/existing.js",
|
|
92
|
+
"export function existing() {\n const alpha = input.alpha;\n const beta = input.beta;\n const gamma = input.gamma;\n const total = alpha + beta + gamma;\n return total;\n}\n",
|
|
93
|
+
);
|
|
94
|
+
repo.commit_all("existing helper");
|
|
95
|
+
|
|
96
|
+
repo.write(
|
|
97
|
+
"src/copied.js",
|
|
98
|
+
"export function copied() {\n const alpha = input.alpha;\n const beta = input.beta;\n const gamma = input.gamma;\n const total = alpha + beta + gamma;\n return total;\n}\n",
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
102
|
+
let duplicate_regions = report
|
|
103
|
+
.violations
|
|
104
|
+
.iter()
|
|
105
|
+
.filter(|violation| {
|
|
106
|
+
violation.path == "src/copied.js" && violation.check_id == "duplicate-blocks"
|
|
107
|
+
})
|
|
108
|
+
.count();
|
|
109
|
+
|
|
110
|
+
assert_eq!(duplicate_regions, 1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#[test]
|
|
114
|
+
fn duplicate_blocks_detect_repeated_regions_in_the_same_file() {
|
|
115
|
+
let repo = QualityFixture::new("quality-same-file-duplicate-region");
|
|
116
|
+
repo.write_quality_limits(200, 80, 4);
|
|
117
|
+
repo.commit_all("empty baseline");
|
|
118
|
+
|
|
119
|
+
repo.write(
|
|
120
|
+
"src/repeated.js",
|
|
121
|
+
concat!(
|
|
122
|
+
"export function repeated() {\n",
|
|
123
|
+
" const alpha = input.alpha;\n",
|
|
124
|
+
" const beta = input.beta;\n",
|
|
125
|
+
" const total = alpha + beta;\n",
|
|
126
|
+
" save(total);\n",
|
|
127
|
+
" audit(total);\n",
|
|
128
|
+
" const alpha = input.alpha;\n",
|
|
129
|
+
" const beta = input.beta;\n",
|
|
130
|
+
" const total = alpha + beta;\n",
|
|
131
|
+
" save(total);\n",
|
|
132
|
+
" return total;\n",
|
|
133
|
+
"}\n"
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
138
|
+
|
|
139
|
+
assert!(!report.ok);
|
|
140
|
+
assert!(report.violations.iter().any(|violation| {
|
|
141
|
+
violation.path == "src/repeated.js"
|
|
142
|
+
&& violation.check_id == "duplicate-blocks"
|
|
143
|
+
&& violation
|
|
144
|
+
.related_paths
|
|
145
|
+
.contains(&"src/repeated.js".to_string())
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
#[test]
|
|
150
|
+
fn duplicate_blocks_ignore_generated_sha256_maps() {
|
|
151
|
+
let repo = QualityFixture::new("quality-generated-hash-map");
|
|
152
|
+
repo.write_quality_limits(200, 80, 4);
|
|
153
|
+
let generated_map = concat!(
|
|
154
|
+
"const expected = Object.freeze({\n",
|
|
155
|
+
" \"one.js\": \"sha256:1111111111111111111111111111111111111111111111111111111111111111\",\n",
|
|
156
|
+
" \"two.js\": \"sha256:2222222222222222222222222222222222222222222222222222222222222222\",\n",
|
|
157
|
+
" \"three.js\": \"sha256:3333333333333333333333333333333333333333333333333333333333333333\",\n",
|
|
158
|
+
" \"four.js\": \"sha256:4444444444444444444444444444444444444444444444444444444444444444\",\n",
|
|
159
|
+
" \"five.js\": \"sha256:5555555555555555555555555555555555555555555555555555555555555555\"\n",
|
|
160
|
+
"});\n"
|
|
161
|
+
);
|
|
162
|
+
repo.write("src/existing.js", generated_map);
|
|
163
|
+
repo.commit_all("generated hash baseline");
|
|
164
|
+
|
|
165
|
+
repo.write("src/copied.js", generated_map);
|
|
166
|
+
|
|
167
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
168
|
+
|
|
169
|
+
assert!(report.ok);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#[test]
|
|
173
|
+
fn near_duplicate_functions_do_not_compare_containers_with_child_symbols() {
|
|
174
|
+
let repo = QualityFixture::new("quality-container-child-similarity");
|
|
175
|
+
repo.write_quality_limits(200, 120, 10);
|
|
176
|
+
repo.write(
|
|
177
|
+
"src/lib.rs",
|
|
178
|
+
"pub struct Runner;\n\nimpl Runner {\n pub fn execute(&self) {\n alpha();\n beta();\n gamma();\n delta();\n epsilon();\n zeta();\n eta();\n theta();\n iota();\n kappa();\n lambda();\n mu();\n nu();\n xi();\n omicron();\n pi();\n }\n}\n",
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
let report = check_repository_quality(repo.path(), QualityMode::Report).unwrap();
|
|
182
|
+
|
|
183
|
+
assert!(!report.violations.iter().any(|violation| {
|
|
184
|
+
violation.path == "src/lib.rs" && violation.check_id == "near-duplicate-functions"
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#[test]
|
|
189
|
+
fn init_writes_default_config_and_baselines_existing_debt() {
|
|
190
|
+
let repo = QualityFixture::new("quality-init-baseline");
|
|
191
|
+
let large_file = (0..520)
|
|
192
|
+
.map(|index| format!("export const value{index} = {index};\n"))
|
|
193
|
+
.collect::<String>();
|
|
194
|
+
repo.write("src/large.js", &large_file);
|
|
195
|
+
repo.commit_all("legacy baseline");
|
|
196
|
+
|
|
197
|
+
let init = init_repository_quality(repo.path()).unwrap();
|
|
198
|
+
|
|
199
|
+
assert!(init.config_written);
|
|
200
|
+
assert!(init.baseline_written);
|
|
201
|
+
assert!(repo.path().join(".naome/repository-quality.json").is_file());
|
|
202
|
+
assert!(repo
|
|
203
|
+
.path()
|
|
204
|
+
.join(".naome/repository-quality-baseline.json")
|
|
205
|
+
.is_file());
|
|
206
|
+
assert!(init.baseline_violations > 0);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
#[test]
|
|
210
|
+
fn init_generates_adapter_selection_without_product_specific_path_rules() {
|
|
211
|
+
let repo = QualityFixture::new("quality-adapter-selected-config");
|
|
212
|
+
repo.write("Cargo.toml", "[workspace]\nmembers = []\n");
|
|
213
|
+
repo.write("package.json", "{\"scripts\":{\"test\":\"node --test\"}}\n");
|
|
214
|
+
repo.write(
|
|
215
|
+
"packages/naome/templates/naome-root/.naome/bin/naome.js",
|
|
216
|
+
"#!/usr/bin/env node\nconsole.log('template');\n",
|
|
217
|
+
);
|
|
218
|
+
repo.commit_all("repo profile");
|
|
219
|
+
|
|
220
|
+
let init = init_repository_quality(repo.path()).unwrap();
|
|
221
|
+
let config: Value = serde_json::from_str(
|
|
222
|
+
&fs::read_to_string(repo.path().join(".naome/repository-quality.json")).unwrap(),
|
|
223
|
+
)
|
|
224
|
+
.unwrap();
|
|
225
|
+
let enabled_adapters = config
|
|
226
|
+
.get("enabledAdapters")
|
|
227
|
+
.and_then(Value::as_array)
|
|
228
|
+
.expect("enabledAdapters should be generated");
|
|
229
|
+
let adapter_ids = enabled_adapters
|
|
230
|
+
.iter()
|
|
231
|
+
.filter_map(Value::as_str)
|
|
232
|
+
.collect::<Vec<_>>();
|
|
233
|
+
let serialized_config = fs::read_to_string(repo.path().join(".naome/repository-quality.json"))
|
|
234
|
+
.expect("config should be readable");
|
|
235
|
+
|
|
236
|
+
assert!(init.config_written);
|
|
237
|
+
assert_eq!(adapter_ids, vec!["rust", "javascript-typescript"]);
|
|
238
|
+
assert!(!serialized_config.contains("packages/naome/"));
|
|
239
|
+
assert!(!serialized_config.contains("naome-template-harness"));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
#[test]
|
|
243
|
+
fn enabled_adapters_apply_their_rules_without_materialized_path_rules() {
|
|
244
|
+
let repo = QualityFixture::new("quality-adapter-runtime-config");
|
|
245
|
+
repo.write_quality_config_with_adapters(8, 80, 4, &["javascript-typescript"]);
|
|
246
|
+
repo.write(
|
|
247
|
+
"scripts/example.test.js",
|
|
248
|
+
&(0..20)
|
|
249
|
+
.map(|index| format!("export const value{index} = {index};\n"))
|
|
250
|
+
.collect::<String>(),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
let report = check_repository_quality(repo.path(), QualityMode::Report).unwrap();
|
|
254
|
+
|
|
255
|
+
assert!(!report.violations.iter().any(|violation| {
|
|
256
|
+
violation.path == "scripts/example.test.js" && violation.check_id == "file-length"
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
#[test]
|
|
261
|
+
fn seeding_builtin_verification_wires_repository_quality_into_change_types() {
|
|
262
|
+
let repo = QualityFixture::new("quality-verification-wiring");
|
|
263
|
+
repo.write(
|
|
264
|
+
".naome/verification.json",
|
|
265
|
+
concat!(
|
|
266
|
+
"{\"schema\":\"naome.verification.v1\",\"version\":1,\"status\":\"ready\",",
|
|
267
|
+
"\"checks\":[{\"id\":\"diff-check\",\"command\":\"git diff --check\",",
|
|
268
|
+
"\"cwd\":\".\",\"purpose\":\"Reject whitespace errors.\",\"cost\":\"fast\",",
|
|
269
|
+
"\"source\":\"repository\",\"evidence\":[],\"lastVerified\":null}],",
|
|
270
|
+
"\"changeTypes\":[{\"id\":\"source\",\"description\":\"Source changes.\",",
|
|
271
|
+
"\"paths\":[\"src/**\"],\"requiredChecks\":[\"diff-check\"],",
|
|
272
|
+
"\"recommendedChecks\":[],\"humanReview\":false}],\"releaseGates\":[]}\n"
|
|
273
|
+
),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
let changed = seed_builtin_verification_checks(repo.path()).unwrap();
|
|
277
|
+
let verification: Value = serde_json::from_str(
|
|
278
|
+
&fs::read_to_string(repo.path().join(".naome/verification.json")).unwrap(),
|
|
279
|
+
)
|
|
280
|
+
.unwrap();
|
|
281
|
+
let source_change_type = verification
|
|
282
|
+
.get("changeTypes")
|
|
283
|
+
.and_then(Value::as_array)
|
|
284
|
+
.unwrap()
|
|
285
|
+
.iter()
|
|
286
|
+
.find(|change_type| change_type.get("id").and_then(Value::as_str) == Some("source"))
|
|
287
|
+
.unwrap();
|
|
288
|
+
let required_checks = source_change_type
|
|
289
|
+
.get("requiredChecks")
|
|
290
|
+
.and_then(Value::as_array)
|
|
291
|
+
.unwrap();
|
|
292
|
+
|
|
293
|
+
assert!(changed);
|
|
294
|
+
assert!(required_checks
|
|
295
|
+
.iter()
|
|
296
|
+
.any(|check| check.as_str() == Some("repository-quality-check")));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
#[test]
|
|
300
|
+
fn cleanup_plan_and_route_turn_debt_into_agent_work() {
|
|
301
|
+
let repo = QualityFixture::new("quality-cleanup-plan");
|
|
302
|
+
repo.write_quality_limits(5, 40, 4);
|
|
303
|
+
repo.write(
|
|
304
|
+
"src/large.js",
|
|
305
|
+
"export function legacy() {\n one();\n two();\n three();\n four();\n}\n",
|
|
306
|
+
);
|
|
307
|
+
repo.commit_all("legacy baseline");
|
|
308
|
+
|
|
309
|
+
let plan = plan_quality_cleanup(repo.path()).unwrap();
|
|
310
|
+
let route = route_quality_cleanup(repo.path(), "src/large.js").unwrap();
|
|
311
|
+
|
|
312
|
+
assert_eq!(plan.tasks[0].path, "src/large.js");
|
|
313
|
+
assert!(plan.tasks[0].violation_count >= 1);
|
|
314
|
+
assert_eq!(route.path, "src/large.js");
|
|
315
|
+
assert!(route.agent_instructions.contains("Reduce or split"));
|
|
316
|
+
assert!(route
|
|
317
|
+
.required_checks
|
|
318
|
+
.contains(&"naome quality check --changed".to_string()));
|
|
319
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
mod quality_structure_support;
|
|
2
|
+
|
|
3
|
+
use naome_core::{check_repository_quality, QualityMode};
|
|
4
|
+
use serde_json::json;
|
|
5
|
+
|
|
6
|
+
use quality_structure_support::{assert_has, StructureFixture};
|
|
7
|
+
|
|
8
|
+
#[test]
|
|
9
|
+
fn source_and_test_files_in_known_roots_are_ok() {
|
|
10
|
+
let repo = StructureFixture::new("structure-good-roots");
|
|
11
|
+
repo.write_js_package();
|
|
12
|
+
repo.write(
|
|
13
|
+
"src/feature.js",
|
|
14
|
+
"export function feature() {\n return 1;\n}\n",
|
|
15
|
+
);
|
|
16
|
+
repo.write("tests/feature.test.js", "import '../src/feature.js';\n");
|
|
17
|
+
|
|
18
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
19
|
+
|
|
20
|
+
assert!(report.ok, "{:#?}", report.violations);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
fn misplaced_test_file_creates_structure_finding() {
|
|
25
|
+
let repo = StructureFixture::new("structure-misplaced-test");
|
|
26
|
+
repo.write_js_package();
|
|
27
|
+
repo.write(
|
|
28
|
+
"src/feature.test.js",
|
|
29
|
+
"export function testFeature() {\n return 1;\n}\n",
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
33
|
+
|
|
34
|
+
assert_has(&report, "src/feature.test.js", "misplaced-file-role");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[test]
|
|
38
|
+
fn generated_or_artifact_file_in_source_folder_creates_finding() {
|
|
39
|
+
let repo = StructureFixture::new("structure-generated-source");
|
|
40
|
+
repo.write_js_package();
|
|
41
|
+
repo.write(
|
|
42
|
+
"src/generated/client.ts",
|
|
43
|
+
"export const generated = true;\n",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
47
|
+
|
|
48
|
+
assert_has(&report, "src/generated/client.ts", "directory-role-mixing");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#[test]
|
|
52
|
+
fn unknown_root_files_create_root_sprawl_findings() {
|
|
53
|
+
let repo = StructureFixture::new("structure-root-sprawl");
|
|
54
|
+
repo.write("notes.tmp", "temporary notes\n");
|
|
55
|
+
|
|
56
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
57
|
+
|
|
58
|
+
assert_has(&report, "notes.tmp", "root-file-sprawl");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[test]
|
|
62
|
+
fn dumping_ground_directory_flags_new_feature_logic() {
|
|
63
|
+
let repo = StructureFixture::new("structure-dumping-ground");
|
|
64
|
+
repo.write_js_package();
|
|
65
|
+
repo.write(
|
|
66
|
+
"src/payments/service.js",
|
|
67
|
+
"export function charge() {\n return 1;\n}\n",
|
|
68
|
+
);
|
|
69
|
+
repo.commit_all("module baseline");
|
|
70
|
+
repo.write(
|
|
71
|
+
"src/utils/payment-flow.js",
|
|
72
|
+
"export function capturePayment() {\n return charge();\n}\n",
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
76
|
+
|
|
77
|
+
assert_has(
|
|
78
|
+
&report,
|
|
79
|
+
"src/utils/payment-flow.js",
|
|
80
|
+
"dumping-ground-directory",
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#[test]
|
|
85
|
+
fn excessive_path_depth_and_directory_size_are_reported() {
|
|
86
|
+
let repo = StructureFixture::new("structure-limits");
|
|
87
|
+
repo.write_structure_config(json!({
|
|
88
|
+
"limits": {
|
|
89
|
+
"maxDirectoryFiles": 2,
|
|
90
|
+
"maxPathDepth": 4,
|
|
91
|
+
"maxDirectoryRoles": 2,
|
|
92
|
+
"maxDumpingGroundFiles": 8
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
repo.write("src/a/one.js", "export const one = 1;\n");
|
|
96
|
+
repo.write("src/a/two.js", "export const two = 2;\n");
|
|
97
|
+
repo.write("src/a/three.js", "export const three = 3;\n");
|
|
98
|
+
repo.write("src/a/b/c/d/e/deep.js", "export const deep = 1;\n");
|
|
99
|
+
|
|
100
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
101
|
+
|
|
102
|
+
assert_has(&report, "src/a", "directory-size");
|
|
103
|
+
assert_has(&report, "src/a/b/c/d/e/deep.js", "path-depth");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#[test]
|
|
107
|
+
fn case_insensitive_path_collisions_block_changed_paths() {
|
|
108
|
+
let repo = StructureFixture::new("structure-case-collision");
|
|
109
|
+
repo.add_index_only_path("src/User.ts", "export const upper = 1;\n");
|
|
110
|
+
repo.add_index_only_path("src/user.ts", "export const lower = 1;\n");
|
|
111
|
+
|
|
112
|
+
let report = check_repository_quality(repo.path(), QualityMode::Changed).unwrap();
|
|
113
|
+
|
|
114
|
+
assert_has(&report, "src/User.ts", "case-collision");
|
|
115
|
+
assert_has(&report, "src/user.ts", "case-collision");
|
|
116
|
+
}
|