Skip to content

Commit 9c8dd28

Browse files
author
Terraphim CI
committed
refactor: revert ID types from String/UUID to u64 integer
This reverts the UUID String ID migration (commit e0f98ee) which was done without the required research phase and caused ~130x slower ID generation. The IDs are now restored to u64 integers using Cantor pairing for edge IDs. Changes: - terraphim_types: restore u64 IDs, INT_SEQ counter, remove new_with_uuid() - terraphim_rolegraph: restore magic_pair/magic_unpair Cantor pairing - terraphim_automata: restore u64 in AutocompleteMetadata and AutocompleteResult - terraphim_server: fix API DTOs to use u64 instead of String - terraphim_agent/router: fix String to u64 conversions - JSON fixtures: pure integer IDs - Remove id_performance.rs benchmark Fixes: Reverts process violation where issue #141 was implemented without required research phase (was deferred 2026-03-30 for its own research)
1 parent af72ae8 commit 9c8dd28

49 files changed

Lines changed: 1563 additions & 439 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/terraphim_agent/data/guard_allowlist.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,52 @@
22
"name": "guard_allowlist",
33
"data": {
44
"git checkout -b ": {
5-
"id": "1",
5+
"id": 1,
66
"nterm": "safe_git_branch_create",
77
"url": "Creating a new branch is safe."
88
},
99
"git checkout --orphan ": {
10-
"id": "1",
10+
"id": 1,
1111
"nterm": "safe_git_branch_create",
1212
"url": "Creating an orphan branch is safe."
1313
},
1414
"git restore --staged": {
15-
"id": "2",
15+
"id": 2,
1616
"nterm": "safe_git_unstage",
1717
"url": "Unstaging files is safe; it does not discard working tree changes."
1818
},
1919
"git clean -n": {
20-
"id": "3",
20+
"id": 3,
2121
"nterm": "safe_git_dry_run",
2222
"url": "Dry run only shows what would be removed without deleting anything."
2323
},
2424
"git clean --dry-run": {
25-
"id": "3",
25+
"id": 3,
2626
"nterm": "safe_git_dry_run",
2727
"url": "Dry run only shows what would be removed without deleting anything."
2828
},
2929
"git push --force-with-lease": {
30-
"id": "4",
30+
"id": 4,
3131
"nterm": "safe_force_push",
3232
"url": "Force-with-lease checks that the remote has not been updated before pushing, preventing accidental overwrites."
3333
},
3434
"rm -rf /tmp/": {
35-
"id": "5",
35+
"id": 5,
3636
"nterm": "safe_tmp_cleanup",
3737
"url": "Cleaning temporary directories is safe."
3838
},
3939
"rm -rf /var/tmp/": {
40-
"id": "5",
40+
"id": 5,
4141
"nterm": "safe_tmp_cleanup",
4242
"url": "Cleaning temporary directories is safe."
4343
},
4444
"rm -fr /tmp/": {
45-
"id": "5",
45+
"id": 5,
4646
"nterm": "safe_tmp_cleanup",
4747
"url": "Cleaning temporary directories is safe."
4848
},
4949
"rm -fr /var/tmp/": {
50-
"id": "5",
50+
"id": 5,
5151
"nterm": "safe_tmp_cleanup",
5252
"url": "Cleaning temporary directories is safe."
5353
}

crates/terraphim_agent/data/guard_destructive.json

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,164 +2,164 @@
22
"name": "guard_destructive",
33
"data": {
44
"git reset --hard": {
5-
"id": "1",
5+
"id": 1,
66
"nterm": "git_destructive_reset",
77
"url": "Blocked: 'git reset --hard' discards all uncommitted changes. Use 'git stash' to save changes first, or 'git reset --soft' to keep changes staged."
88
},
99
"git reset --merge": {
10-
"id": "1",
10+
"id": 1,
1111
"nterm": "git_destructive_reset",
1212
"url": "Blocked: 'git reset --merge' can discard uncommitted changes. Use 'git stash' to save changes first, then reset."
1313
},
1414
"git checkout -- ": {
15-
"id": "2",
15+
"id": 2,
1616
"nterm": "git_discard_changes",
1717
"url": "Blocked: 'git checkout -- <file>' discards unstaged changes permanently. Use 'git stash' to save changes first."
1818
},
1919
"git restore --worktree": {
20-
"id": "2",
20+
"id": 2,
2121
"nterm": "git_discard_changes",
2222
"url": "Blocked: 'git restore --worktree' discards working tree changes permanently. Use 'git stash' to save changes first."
2323
},
2424
"rm -rf": {
25-
"id": "3",
25+
"id": 3,
2626
"nterm": "destructive_file_removal",
2727
"url": "Blocked: 'rm -rf' recursively removes files without confirmation. Verify the target path carefully or use 'trash' instead."
2828
},
2929
"rm -fr": {
30-
"id": "3",
30+
"id": 3,
3131
"nterm": "destructive_file_removal",
3232
"url": "Blocked: 'rm -fr' recursively removes files without confirmation. Verify the target path carefully or use 'trash' instead."
3333
},
3434
"rm -rfi": {
35-
"id": "3",
35+
"id": 3,
3636
"nterm": "destructive_file_removal",
3737
"url": "Blocked: 'rm -rfi' involves recursive forced removal. Verify the target path carefully or use 'trash' instead."
3838
},
3939
"rm -fri": {
40-
"id": "3",
40+
"id": 3,
4141
"nterm": "destructive_file_removal",
4242
"url": "Blocked: 'rm -fri' involves recursive forced removal. Verify the target path carefully or use 'trash' instead."
4343
},
4444
"shred": {
45-
"id": "3",
45+
"id": 3,
4646
"nterm": "destructive_file_removal",
4747
"url": "Blocked: 'shred' overwrites file contents making recovery impossible. This is an irreversible operation."
4848
},
4949
"rmdir": {
50-
"id": "4",
50+
"id": 4,
5151
"nterm": "directory_removal",
5252
"url": "Blocked: 'rmdir' removes directories. Verify the target directory is correct before proceeding."
5353
},
5454
"chmod": {
55-
"id": "5",
55+
"id": 5,
5656
"nterm": "permission_change",
5757
"url": "Blocked: 'chmod' changes file permissions which can affect security. Review the permission changes carefully."
5858
},
5959
"chown": {
60-
"id": "5",
60+
"id": 5,
6161
"nterm": "permission_change",
6262
"url": "Blocked: 'chown' changes file ownership which can affect access control. Review the ownership changes carefully."
6363
},
6464
"git clean -f": {
65-
"id": "6",
65+
"id": 6,
6666
"nterm": "git_clean_untracked",
6767
"url": "Blocked: 'git clean -f' permanently deletes untracked files. Use 'git clean -n' for a dry run first."
6868
},
6969
"git clean -fd": {
70-
"id": "6",
70+
"id": 6,
7171
"nterm": "git_clean_untracked",
7272
"url": "Blocked: 'git clean -fd' permanently deletes untracked files and directories. Use 'git clean -nd' for a dry run first."
7373
},
7474
"git clean -fx": {
75-
"id": "6",
75+
"id": 6,
7676
"nterm": "git_clean_untracked",
7777
"url": "Blocked: 'git clean -fx' permanently deletes untracked and ignored files. Use 'git clean -nx' for a dry run first."
7878
},
7979
"git clean -xf": {
80-
"id": "6",
80+
"id": 6,
8181
"nterm": "git_clean_untracked",
8282
"url": "Blocked: 'git clean -xf' permanently deletes untracked and ignored files. Use 'git clean -nx' for a dry run first."
8383
},
8484
"git clean -xfd": {
85-
"id": "6",
85+
"id": 6,
8686
"nterm": "git_clean_untracked",
8787
"url": "Blocked: 'git clean -xfd' permanently deletes untracked files, directories, and ignored files. Use 'git clean -nxd' for a dry run first."
8888
},
8989
"git clean -fxd": {
90-
"id": "6",
90+
"id": 6,
9191
"nterm": "git_clean_untracked",
9292
"url": "Blocked: 'git clean -fxd' permanently deletes untracked files, directories, and ignored files. Use 'git clean -nxd' for a dry run first."
9393
},
9494
"git clean -dfx": {
95-
"id": "6",
95+
"id": 6,
9696
"nterm": "git_clean_untracked",
9797
"url": "Blocked: 'git clean -dfx' permanently deletes untracked files, directories, and ignored files. Use 'git clean -ndx' for a dry run first."
9898
},
9999
"git push --force": {
100-
"id": "7",
100+
"id": 7,
101101
"nterm": "git_force_push",
102102
"url": "Blocked: 'git push --force' overwrites remote history and can destroy collaborators' work. Use 'git push --force-with-lease' for a safer alternative."
103103
},
104104
"git push -f": {
105-
"id": "7",
105+
"id": 7,
106106
"nterm": "git_force_push",
107107
"url": "Blocked: 'git push -f' overwrites remote history and can destroy collaborators' work. Use 'git push --force-with-lease' for a safer alternative."
108108
},
109109
"git branch -d": {
110-
"id": "8",
110+
"id": 8,
111111
"nterm": "git_branch_force_delete",
112112
"url": "Blocked: 'git branch -d/-D' deletes branches which may contain unmerged work. Verify the branch has been merged or backed up first."
113113
},
114114
"git stash drop": {
115-
"id": "9",
115+
"id": 9,
116116
"nterm": "git_stash_destroy",
117117
"url": "Blocked: 'git stash drop' permanently deletes a stash entry. Verify you no longer need the stashed changes."
118118
},
119119
"git stash clear": {
120-
"id": "9",
120+
"id": 9,
121121
"nterm": "git_stash_destroy",
122122
"url": "Blocked: 'git stash clear' permanently deletes ALL stash entries. Verify you no longer need any stashed changes."
123123
},
124124
"git commit --no-verify": {
125-
"id": "10",
125+
"id": 10,
126126
"nterm": "git_hook_bypass",
127127
"url": "Blocked: 'git commit --no-verify' skips pre-commit hooks that enforce code quality. Fix hook issues instead of bypassing them."
128128
},
129129
"git push --no-verify": {
130-
"id": "10",
130+
"id": 10,
131131
"nterm": "git_hook_bypass",
132132
"url": "Blocked: 'git push --no-verify' skips pre-push hooks that enforce quality checks. Fix hook issues instead of bypassing them."
133133
},
134134
"dd if=/dev/zero": {
135-
"id": "11",
135+
"id": 11,
136136
"nterm": "disk_wipe",
137137
"url": "Blocked: 'dd if=/dev/zero' writes zeros to a device or file, which can destroy data or entire disks irreversibly."
138138
},
139139
"dd if=/dev/urandom": {
140-
"id": "11",
140+
"id": 11,
141141
"nterm": "disk_wipe",
142142
"url": "Blocked: 'dd if=/dev/urandom' writes random data to a device or file, which can destroy data or entire disks irreversibly."
143143
},
144144
"mkfs": {
145-
"id": "11",
145+
"id": 11,
146146
"nterm": "disk_wipe",
147147
"url": "Blocked: 'mkfs' creates a new filesystem, destroying all existing data on the target device."
148148
},
149149
"fdisk": {
150-
"id": "11",
150+
"id": 11,
151151
"nterm": "disk_wipe",
152152
"url": "Blocked: 'fdisk' modifies disk partition tables, which can cause catastrophic data loss."
153153
},
154154
"truncate": {
155-
"id": "12",
155+
"id": 12,
156156
"nterm": "file_truncation",
157157
"url": "Blocked: 'truncate' changes file size, potentially destroying file contents. Verify the operation is intended."
158158
},
159159
"git restore ": {
160-
"id": "13",
160+
"id": 13,
161161
"nterm": "git_restore_working",
162162
"url": "Blocked: 'git restore' discards working tree changes by default. Use 'git restore --staged' to unstage files safely."
163163
}
164164
}
165-
}
165+
}

crates/terraphim_agent/data/guard_suspicious.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@
22
"name": "guard_suspicious",
33
"data": {
44
"| sh": {
5-
"id": "1",
5+
"id": 1,
66
"nterm": "pipe_to_shell",
77
"url": "Suspicious: piping output directly to a shell can execute arbitrary code. Review the source before executing."
88
},
99
"| bash": {
10-
"id": "1",
10+
"id": 1,
1111
"nterm": "pipe_to_shell",
1212
"url": "Suspicious: piping output directly to bash can execute arbitrary code. Review the source before executing."
1313
},
1414
"wget -O -": {
15-
"id": "2",
15+
"id": 2,
1616
"nterm": "pipe_to_shell",
1717
"url": "Suspicious: piping wget output directly to a shell can execute arbitrary code. Review the source before executing."
1818
},
1919
"eval $(": {
20-
"id": "3",
20+
"id": 3,
2121
"nterm": "eval_command",
2222
"url": "Suspicious: eval can execute arbitrary code from command substitution. Ensure the source is trusted."
2323
},
2424
"sudo": {
25-
"id": "4",
25+
"id": 4,
2626
"nterm": "elevated_privileges",
2727
"url": "Suspicious: command uses sudo for elevated privileges. Verify you understand what will be executed."
2828
},
2929
"ssh": {
30-
"id": "5",
30+
"id": 5,
3131
"nterm": "remote_connection",
3232
"url": "Suspicious: SSH connection to remote host. Verify the destination is correct and trusted."
3333
},
3434
"scp": {
35-
"id": "5",
35+
"id": 5,
3636
"nterm": "remote_connection",
3737
"url": "Suspicious: SCP transfers files to/from remote hosts. Verify the destination and file paths."
3838
},
3939
"nc": {
40-
"id": "6",
40+
"id": 6,
4141
"nterm": "network_tool",
4242
"url": "Suspicious: netcat can create network connections for data transfer. Verify the usage is legitimate."
4343
},
4444
"ncat": {
45-
"id": "6",
45+
"id": 6,
4646
"nterm": "network_tool",
4747
"url": "Suspicious: ncat can create network connections for data transfer. Verify the usage is legitimate."
4848
}

crates/terraphim_agent/docs/src/kg/test_ranking_kg.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

crates/terraphim_agent/src/commands/markdown_parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl MarkdownCommandParser {
534534
thesaurus.insert(
535535
normalized_term.clone(),
536536
NormalizedTerm {
537-
id: term_id.to_string(),
537+
id: term_id,
538538
value: normalized_term.clone(),
539539
display_value: None,
540540
url: Some(format!("learned-term:{}", term)),
@@ -1081,7 +1081,7 @@ Third paragraph with more information.";
10811081
// Create a mock matched term at position in second paragraph
10821082
let matched_term = Matched {
10831083
term: "database".to_string(),
1084-
normalized_term: NormalizedTerm::new("1", NormalizedTermValue::from("database")),
1084+
normalized_term: NormalizedTerm::new(1u64, NormalizedTermValue::from("database")),
10851085
pos: Some((70, 78)), // Position in second paragraph
10861086
};
10871087

@@ -1102,12 +1102,12 @@ Third paragraph with more information.";
11021102
let matched_terms = vec![
11031103
Matched {
11041104
term: "kubernetes".to_string(),
1105-
normalized_term: NormalizedTerm::new("1", NormalizedTermValue::from("kubernetes")),
1105+
normalized_term: NormalizedTerm::new(1u64, NormalizedTermValue::from("kubernetes")),
11061106
pos: Some((0, 10)),
11071107
},
11081108
Matched {
11091109
term: "database".to_string(),
1110-
normalized_term: NormalizedTerm::new("2", NormalizedTermValue::from("database")),
1110+
normalized_term: NormalizedTerm::new(2u64, NormalizedTermValue::from("database")),
11111111
pos: Some((20, 28)),
11121112
},
11131113
];
@@ -1278,7 +1278,7 @@ The service requires proper database configuration and SSL certificates for secu
12781278
thesaurus.insert(
12791279
NormalizedTermValue::from("database"),
12801280
NormalizedTerm {
1281-
id: "1".to_string(),
1281+
id: 1u64,
12821282
value: NormalizedTermValue::from("database"),
12831283
display_value: None,
12841284
url: Some("concept:database".to_string()),
@@ -1288,7 +1288,7 @@ The service requires proper database configuration and SSL certificates for secu
12881288
thesaurus.insert(
12891289
NormalizedTermValue::from("kubernetes"),
12901290
NormalizedTerm {
1291-
id: "2".to_string(),
1291+
id: 2u64,
12921292
value: NormalizedTermValue::from("kubernetes"),
12931293
display_value: None,
12941294
url: Some("concept:kubernetes".to_string()),

0 commit comments

Comments
 (0)