repo-nexus 0.9.13 → 0.9.15
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/package.json +1 -1
- package/plugins/claude/plugin.yaml +1 -1
- package/plugins/codex/plugin.yaml +1 -1
- package/plugins/copilot/plugin.yaml +1 -1
- package/plugins/cursor/plugin.yaml +1 -1
- package/plugins/gemini/plugin.yaml +1 -1
- package/plugins/karpathy-llm/lib/btree_helpers.sh +89 -29
- package/plugins/karpathy-llm/lib/lint_helpers.sh +51 -10
- package/plugins/karpathy-llm/lib/source_helpers.sh +1 -1
- package/plugins/karpathy-llm/plugin.yaml +1 -1
- package/plugins/karpathy-llm/tests/test_plugin.sh +99 -0
- package/plugins/windsurf/plugin.yaml +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-nexus",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15",
|
|
4
4
|
"description": "Lightweight, zero-dependency Virtual Meta Repository (meta repo) and Nexus Repository (nexus repo) manager for multi-repo workspaces and shared AI context (no git submodules)",
|
|
5
5
|
"bin": {
|
|
6
6
|
"repo-nexus": "rnex",
|
|
@@ -145,6 +145,7 @@ EOF
|
|
|
145
145
|
# @sideEffects: Writes $RNEX_WIKI_INDEX_FILE atomically.
|
|
146
146
|
# -----------------------------------------------------------------------------
|
|
147
147
|
compile_root_index_router() {
|
|
148
|
+
ensure_baseline_flat_shards
|
|
148
149
|
_idx_tmp="${RNEX_WIKI_INDEX_FILE}.tmp.$$"
|
|
149
150
|
cat <<'EOF' > "$_idx_tmp"
|
|
150
151
|
# Wiki Index
|
|
@@ -425,6 +426,7 @@ EOF
|
|
|
425
426
|
resolve_target_btree_shard_file() {
|
|
426
427
|
_s_id="$1"
|
|
427
428
|
_doc_title="$2"
|
|
429
|
+
_doc_path="${3:-}"
|
|
428
430
|
_base_file="${RNEX_WIKI_ROOT}/${_s_id}.md"
|
|
429
431
|
|
|
430
432
|
# Find existing shard candidate files for this shard ID
|
|
@@ -451,13 +453,47 @@ resolve_target_btree_shard_file() {
|
|
|
451
453
|
fi
|
|
452
454
|
fi
|
|
453
455
|
|
|
456
|
+
_base_exists=0
|
|
457
|
+
[ -f "$_base_file" ] && _base_exists=1
|
|
458
|
+
|
|
454
459
|
# Sub-shards exist; route title to the most appropriate sub-shard via awk
|
|
455
460
|
printf '%s\n' "$_cand_files" | LC_ALL=C awk \
|
|
456
461
|
-v sid="$_s_id" \
|
|
457
462
|
-v title="$_doc_title" \
|
|
458
|
-
-v
|
|
463
|
+
-v path="$_doc_path" \
|
|
464
|
+
-v def_file="$_base_file" \
|
|
465
|
+
-v base_exists="$_base_exists" '
|
|
466
|
+
function clean_alpha_key(str, res, i, c, d) {
|
|
467
|
+
res = ""
|
|
468
|
+
for (i = 1; i <= length(str); i++) {
|
|
469
|
+
c = substr(str, i, 1)
|
|
470
|
+
if (c >= "a" && c <= "z") {
|
|
471
|
+
res = res c
|
|
472
|
+
} else if (c >= "A" && c <= "Z") {
|
|
473
|
+
res = res tolower(c)
|
|
474
|
+
} else if (c >= "0" && c <= "9") {
|
|
475
|
+
d = c + 0
|
|
476
|
+
if (d == 0) res = res "zero"
|
|
477
|
+
else if (d == 1) res = res "one"
|
|
478
|
+
else if (d == 2) res = res "two"
|
|
479
|
+
else if (d == 3) res = res "three"
|
|
480
|
+
else if (d == 4) res = res "four"
|
|
481
|
+
else if (d == 5) res = res "five"
|
|
482
|
+
else if (d == 6) res = res "six"
|
|
483
|
+
else if (d == 7) res = res "seven"
|
|
484
|
+
else if (d == 8) res = res "eight"
|
|
485
|
+
else if (d == 9) res = res "nine"
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return res
|
|
489
|
+
}
|
|
459
490
|
BEGIN {
|
|
460
|
-
|
|
491
|
+
kt = clean_alpha_key(title)
|
|
492
|
+
kp = clean_alpha_key(path)
|
|
493
|
+
if (kt != "") t = kt kp
|
|
494
|
+
else if (kp != "") t = kp
|
|
495
|
+
else t = "untitled"
|
|
496
|
+
|
|
461
497
|
prefix = sid "-"
|
|
462
498
|
first_child = ""
|
|
463
499
|
last_child = ""
|
|
@@ -512,8 +548,14 @@ resolve_target_btree_shard_file() {
|
|
|
512
548
|
print first_child
|
|
513
549
|
} else if (t > "z" && last_child != "") {
|
|
514
550
|
print last_child
|
|
515
|
-
} else {
|
|
551
|
+
} else if (base_exists == 1 || first_child == "") {
|
|
516
552
|
print def_file
|
|
553
|
+
} else {
|
|
554
|
+
if (first_child != "") {
|
|
555
|
+
print first_child
|
|
556
|
+
} else {
|
|
557
|
+
print def_file
|
|
558
|
+
}
|
|
517
559
|
}
|
|
518
560
|
}
|
|
519
561
|
'
|
|
@@ -665,7 +707,7 @@ split_oversized_btree_shards() {
|
|
|
665
707
|
sub(/\].*$/, "", m)
|
|
666
708
|
return m
|
|
667
709
|
} else if (match(line, /^- \*\*[^*]+\*\*/)) {
|
|
668
|
-
m = substr(line,
|
|
710
|
+
m = substr(line, 5)
|
|
669
711
|
sub(/\*\*.*$/, "", m)
|
|
670
712
|
return m
|
|
671
713
|
}
|
|
@@ -681,13 +723,27 @@ split_oversized_btree_shards() {
|
|
|
681
723
|
}
|
|
682
724
|
return ""
|
|
683
725
|
}
|
|
684
|
-
function clean_alpha_key(str, res, i, c) {
|
|
726
|
+
function clean_alpha_key(str, res, i, c, d) {
|
|
685
727
|
res = ""
|
|
686
728
|
for (i = 1; i <= length(str); i++) {
|
|
687
729
|
c = substr(str, i, 1)
|
|
688
|
-
if (c >= "a" && c <= "z")
|
|
689
|
-
|
|
690
|
-
else if (c
|
|
730
|
+
if (c >= "a" && c <= "z") {
|
|
731
|
+
res = res c
|
|
732
|
+
} else if (c >= "A" && c <= "Z") {
|
|
733
|
+
res = res tolower(c)
|
|
734
|
+
} else if (c >= "0" && c <= "9") {
|
|
735
|
+
d = c + 0
|
|
736
|
+
if (d == 0) res = res "zero"
|
|
737
|
+
else if (d == 1) res = res "one"
|
|
738
|
+
else if (d == 2) res = res "two"
|
|
739
|
+
else if (d == 3) res = res "three"
|
|
740
|
+
else if (d == 4) res = res "four"
|
|
741
|
+
else if (d == 5) res = res "five"
|
|
742
|
+
else if (d == 6) res = res "six"
|
|
743
|
+
else if (d == 7) res = res "seven"
|
|
744
|
+
else if (d == 8) res = res "eight"
|
|
745
|
+
else if (d == 9) res = res "nine"
|
|
746
|
+
}
|
|
691
747
|
}
|
|
692
748
|
return res
|
|
693
749
|
}
|
|
@@ -701,27 +757,19 @@ split_oversized_btree_shards() {
|
|
|
701
757
|
t = tolower(get_title($0))
|
|
702
758
|
p = tolower(get_path($0))
|
|
703
759
|
titles[lines_count] = (t != "") ? t : "untitled"
|
|
704
|
-
paths[lines_count] = (p != "") ? p : ("item
|
|
760
|
+
paths[lines_count] = (p != "") ? p : ("item" lines_count)
|
|
705
761
|
}
|
|
706
762
|
END {
|
|
707
763
|
if (lines_count == 0) exit 0
|
|
708
764
|
|
|
709
|
-
#
|
|
710
|
-
all_titles_same = 1
|
|
711
|
-
for (i = 2; i <= lines_count; i++) {
|
|
712
|
-
if (titles[i] != titles[1]) {
|
|
713
|
-
all_titles_same = 0
|
|
714
|
-
break
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
# Build sorting keys: use title if they differ; use title + "-" + path if all titles are identical
|
|
765
|
+
# Build sorting keys: title + unique path
|
|
719
766
|
for (i = 1; i <= lines_count; i++) {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
767
|
+
kt = clean_alpha_key(titles[i])
|
|
768
|
+
kp = clean_alpha_key(paths[i])
|
|
769
|
+
if (kt != "") {
|
|
770
|
+
keys[i] = kt kp
|
|
723
771
|
} else {
|
|
724
|
-
keys[i] = clean_alpha_key(
|
|
772
|
+
keys[i] = (kp != "") ? kp : ("entry" clean_alpha_key(i))
|
|
725
773
|
}
|
|
726
774
|
}
|
|
727
775
|
|
|
@@ -834,12 +882,17 @@ split_oversized_btree_shards() {
|
|
|
834
882
|
}
|
|
835
883
|
}
|
|
836
884
|
|
|
837
|
-
# Pure alphabetical fallback:
|
|
885
|
+
# Pure alphabetical fallback: find first character position where the two halves differ
|
|
838
886
|
half_idx = int((lines_count + 1) / 2)
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
887
|
+
diff_pos = 1
|
|
888
|
+
while (substr(keys[half_idx], diff_pos, 1) == substr(keys[half_idx + 1], diff_pos, 1) && diff_pos < length(keys[half_idx])) {
|
|
889
|
+
diff_pos++
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
k1_start = substr(keys[1], 1, diff_pos)
|
|
893
|
+
k1_end = substr(keys[half_idx], 1, diff_pos)
|
|
894
|
+
k2_start = substr(keys[half_idx + 1], 1, diff_pos)
|
|
895
|
+
k2_end = substr(keys[lines_count], 1, diff_pos)
|
|
843
896
|
|
|
844
897
|
sfx1 = (k1_start == k1_end) ? k1_start : (k1_start "-" k1_end)
|
|
845
898
|
sfx2 = (k2_start == k2_end) ? k2_start : (k2_start "-" k2_end)
|
|
@@ -863,6 +916,12 @@ split_oversized_btree_shards() {
|
|
|
863
916
|
_c1_id="${_child_names%%|*}"
|
|
864
917
|
_c2_id="${_child_names#*|}"
|
|
865
918
|
|
|
919
|
+
# Safety guard: reject self-split or identical child names
|
|
920
|
+
if [ -z "$_c1_id" ] || [ -z "$_c2_id" ] || [ "$_c1_id" = "$_c2_id" ] || [ "$_c1_id" = "$_s_id" ] || [ "$_c2_id" = "$_s_id" ]; then
|
|
921
|
+
rm -f "$_part1_tmp" "$_part2_tmp"
|
|
922
|
+
continue
|
|
923
|
+
fi
|
|
924
|
+
|
|
866
925
|
_wrote_any=0
|
|
867
926
|
|
|
868
927
|
# Write Child 1 if part1 has entries
|
|
@@ -946,6 +1005,7 @@ ingest_missing_sources_into_btree() {
|
|
|
946
1005
|
_missing_file="$1"
|
|
947
1006
|
_arg_label="$2"
|
|
948
1007
|
mkdir -p "$RNEX_WIKI_ROOT"
|
|
1008
|
+
ensure_baseline_flat_shards
|
|
949
1009
|
|
|
950
1010
|
# If zero missing sources, inspect existing shards for any needed splits before declaring up-to-date
|
|
951
1011
|
if [ ! -s "$_missing_file" ] && [ -f "$RNEX_WIKI_INDEX_FILE" ]; then
|
|
@@ -993,7 +1053,7 @@ ingest_missing_sources_into_btree() {
|
|
|
993
1053
|
_entry_line="- **[${_title}](${_rel_link})** (\`${_rel_path}\`) — ${_summary}"
|
|
994
1054
|
|
|
995
1055
|
# Route dynamically to existing leaf sub-shard or base shard
|
|
996
|
-
_target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title")"
|
|
1056
|
+
_target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title" "$_rel_path")"
|
|
997
1057
|
|
|
998
1058
|
_shard_existed=0
|
|
999
1059
|
[ -f "$_target_shard_file" ] && _shard_existed=1
|
|
@@ -98,7 +98,7 @@ lint_existing_wiki_directory() {
|
|
|
98
98
|
while IFS= read -r _line || [ -n "$_line" ]; do
|
|
99
99
|
case "$_line" in
|
|
100
100
|
'- **'*'(`'*'`)'*)
|
|
101
|
-
_doc_rel="$(printf '%s\n' "$_line" | sed -n 's/^-
|
|
101
|
+
_doc_rel="$(printf '%s\n' "$_line" | sed -n 's/^- \*\*[^*]*\*\* (`\([^`]*\)`).*/\1/p')"
|
|
102
102
|
if [ -n "$_doc_rel" ] && [ ! -f "${RNEX_WORKSPACE_ROOT}/${_doc_rel}" ]; then
|
|
103
103
|
_shard_pruned=1
|
|
104
104
|
_fixes_count=$((_fixes_count + 1))
|
|
@@ -120,14 +120,16 @@ lint_existing_wiki_directory() {
|
|
|
120
120
|
append_wiki_log_entry "lint" "updated: \`${_doc_rel}\` in \`${_base_md}\` (auto-healed entry link depth)"
|
|
121
121
|
fi
|
|
122
122
|
|
|
123
|
-
# 4a-2. Auto-heal links inside catalog entry summary
|
|
123
|
+
# 4a-2. Auto-heal links inside catalog entry summary against canonical source
|
|
124
124
|
case "$_line" in
|
|
125
125
|
*']('*')'*)
|
|
126
126
|
_prefix="${_line%% — *}"
|
|
127
127
|
_sum_part="${_line#* — }"
|
|
128
128
|
if [ "$_prefix" != "$_line" ] && [ -n "$_sum_part" ]; then
|
|
129
|
+
_meta="$(extract_markdown_title_and_summary "${RNEX_WORKSPACE_ROOT}/${_doc_rel}" "$(basename "$_doc_rel")")"
|
|
130
|
+
_raw_summary="${_meta#*|}"
|
|
129
131
|
_healed_sum="$(rewrite_markdown_links_in_summary \
|
|
130
|
-
"$
|
|
132
|
+
"$_raw_summary" \
|
|
131
133
|
"$_doc_rel" \
|
|
132
134
|
"$RNEX_WORKSPACE_ROOT" \
|
|
133
135
|
"${RNEX_WIKI_UP_PREFIX:-../../}" \
|
|
@@ -188,7 +190,7 @@ lint_existing_wiki_directory() {
|
|
|
188
190
|
if [ -s "$_raw_entries" ]; then
|
|
189
191
|
while IFS= read -r _entry_line <&6; do
|
|
190
192
|
[ -n "$_entry_line" ] || continue
|
|
191
|
-
_rel_path="$(printf '%s' "$_entry_line" | sed -n 's
|
|
193
|
+
_rel_path="$(printf '%s' "$_entry_line" | sed -n 's/^- \*\*[^*]*\*\* (`\([^`]*\)`).*/\1/p')"
|
|
192
194
|
_title="$(printf '%s' "$_entry_line" | sed -n 's/^- \*\*\[\([^]]*\)\].*/\1/p')"
|
|
193
195
|
[ -n "$_title" ] || _title="$(printf '%s' "$_entry_line" | sed -n 's/^- \*\*\([^*]*\)\*\*.*/\1/p')"
|
|
194
196
|
[ -n "$_title" ] || _title="untitled"
|
|
@@ -209,7 +211,7 @@ lint_existing_wiki_directory() {
|
|
|
209
211
|
fi
|
|
210
212
|
fi
|
|
211
213
|
|
|
212
|
-
_target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title")"
|
|
214
|
+
_target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title" "$_rel_path")"
|
|
213
215
|
_target_shard_id="$(basename "$_target_shard_file" .md)"
|
|
214
216
|
|
|
215
217
|
_t_entries="${_target_shard_file}.entries.$$"
|
|
@@ -268,22 +270,61 @@ lint_existing_wiki_directory() {
|
|
|
268
270
|
-v k="${#_sp}" \
|
|
269
271
|
-v val_file="$_valid_entries" \
|
|
270
272
|
-v mis_file="$_misplaced_entries" '
|
|
273
|
+
function clean_alpha_key(str, res, i, c, d) {
|
|
274
|
+
res = ""
|
|
275
|
+
for (i = 1; i <= length(str); i++) {
|
|
276
|
+
c = substr(str, i, 1)
|
|
277
|
+
if (c >= "a" && c <= "z") {
|
|
278
|
+
res = res c
|
|
279
|
+
} else if (c >= "A" && c <= "Z") {
|
|
280
|
+
res = res tolower(c)
|
|
281
|
+
} else if (c >= "0" && c <= "9") {
|
|
282
|
+
d = c + 0
|
|
283
|
+
if (d == 0) res = res "zero"
|
|
284
|
+
else if (d == 1) res = res "one"
|
|
285
|
+
else if (d == 2) res = res "two"
|
|
286
|
+
else if (d == 3) res = res "three"
|
|
287
|
+
else if (d == 4) res = res "four"
|
|
288
|
+
else if (d == 5) res = res "five"
|
|
289
|
+
else if (d == 6) res = res "six"
|
|
290
|
+
else if (d == 7) res = res "seven"
|
|
291
|
+
else if (d == 8) res = res "eight"
|
|
292
|
+
else if (d == 9) res = res "nine"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return res
|
|
296
|
+
}
|
|
271
297
|
function get_title(line, m) {
|
|
272
298
|
if (match(line, /^- \*\*\[[^]]+\]/)) {
|
|
273
299
|
m = substr(line, 6)
|
|
274
300
|
sub(/\].*$/, "", m)
|
|
275
301
|
return m
|
|
276
302
|
} else if (match(line, /^- \*\*[^*]+\*\*/)) {
|
|
277
|
-
m = substr(line,
|
|
303
|
+
m = substr(line, 5)
|
|
278
304
|
sub(/\*\*.*$/, "", m)
|
|
279
305
|
return m
|
|
280
306
|
}
|
|
281
307
|
return ""
|
|
282
308
|
}
|
|
309
|
+
function get_path(line, m) {
|
|
310
|
+
if (match(line, /\(`[^`]+`\)/)) {
|
|
311
|
+
m = substr(line, RSTART + 2, RLENGTH - 4)
|
|
312
|
+
return m
|
|
313
|
+
} else if (match(line, /\]\([^)]+\)/)) {
|
|
314
|
+
m = substr(line, RSTART + 2, RLENGTH - 3)
|
|
315
|
+
return m
|
|
316
|
+
}
|
|
317
|
+
return ""
|
|
318
|
+
}
|
|
283
319
|
/^- \*\*/ {
|
|
284
|
-
|
|
320
|
+
kt = clean_alpha_key(get_title($0))
|
|
321
|
+
kp = clean_alpha_key(get_path($0))
|
|
322
|
+
if (kt != "") t = kt kp
|
|
323
|
+
else if (kp != "") t = kp
|
|
324
|
+
else t = "untitled"
|
|
325
|
+
|
|
285
326
|
pfx = substr(t, 1, k)
|
|
286
|
-
if ((sp == "a" && pfx < sp) || (pfx >= sp && pfx <= ep)) {
|
|
327
|
+
if ((sp == "a" && pfx < sp) || (pfx >= sp && (ep == "z" || pfx <= ep))) {
|
|
287
328
|
print $0 >> val_file
|
|
288
329
|
} else {
|
|
289
330
|
print $0 >> mis_file
|
|
@@ -309,7 +350,7 @@ lint_existing_wiki_directory() {
|
|
|
309
350
|
|
|
310
351
|
while IFS= read -r _m_line <&7; do
|
|
311
352
|
[ -n "$_m_line" ] || continue
|
|
312
|
-
_rel_path="$(printf '%s' "$_m_line" | sed -n 's
|
|
353
|
+
_rel_path="$(printf '%s' "$_m_line" | sed -n 's/^- \*\*[^*]*\*\* (`\([^`]*\)`).*/\1/p')"
|
|
313
354
|
_title="$(printf '%s' "$_m_line" | sed -n 's/^- \*\*\[\([^]]*\)\].*/\1/p')"
|
|
314
355
|
[ -n "$_title" ] || _title="$(printf '%s' "$_m_line" | sed -n 's/^- \*\*\([^*]*\)\*\*.*/\1/p')"
|
|
315
356
|
[ -n "$_title" ] || _title="untitled"
|
|
@@ -330,7 +371,7 @@ lint_existing_wiki_directory() {
|
|
|
330
371
|
fi
|
|
331
372
|
fi
|
|
332
373
|
|
|
333
|
-
_target_shard_file="$(resolve_target_btree_shard_file "$_t_shard_id" "$_title")"
|
|
374
|
+
_target_shard_file="$(resolve_target_btree_shard_file "$_t_shard_id" "$_title" "$_rel_path")"
|
|
334
375
|
_target_shard_id="$(basename "$_target_shard_file" .md)"
|
|
335
376
|
|
|
336
377
|
_t_entries="${_target_shard_file}.entries.$$"
|
|
@@ -199,7 +199,7 @@ extract_already_indexed_paths() {
|
|
|
199
199
|
# Matches both formats:
|
|
200
200
|
# 1. - **[Title](../../path)** (`path`) — summary
|
|
201
201
|
# 2. - **slug** (`path`) — summary
|
|
202
|
-
LC_ALL=C sed -n 's/^-
|
|
202
|
+
LC_ALL=C sed -n 's/^- \*\*[^*]*\*\* (`\([^`]*\)`).*/\1/p' "$_shard_file" >> "$_out_idx"
|
|
203
203
|
done
|
|
204
204
|
|
|
205
205
|
atomic_sort_unique_file "$_out_idx" || true
|
|
@@ -1509,6 +1509,105 @@ done
|
|
|
1509
1509
|
}
|
|
1510
1510
|
pass
|
|
1511
1511
|
|
|
1512
|
+
# --------------------------------------------------------------------------
|
|
1513
|
+
# Test 29: Idempotency across repeated ingest -> lint -> ingest -> lint cycles
|
|
1514
|
+
# --------------------------------------------------------------------------
|
|
1515
|
+
run_test "Karpathy-llm: strict idempotency across repeated ingest/lint cycles (zero ping-pong repairs)"
|
|
1516
|
+
TEST_IDEM_WS="$TEST_TMP/karpathy-idem-ws"
|
|
1517
|
+
mkdir -p "$TEST_IDEM_WS"
|
|
1518
|
+
setup_plugin_test_workspace karpathy-llm "$TEST_IDEM_WS"
|
|
1519
|
+
cd "$TEST_IDEM_WS"
|
|
1520
|
+
|
|
1521
|
+
"$TEST_IDEM_WS/rnex" init -y --karpathy "$TEST_IDEM_WS" >/dev/null
|
|
1522
|
+
mkdir -p "$TEST_IDEM_WS/wiki"
|
|
1523
|
+
mkdir -p "$TEST_IDEM_WS/repos/test-repo/packages"
|
|
1524
|
+
|
|
1525
|
+
_k=1
|
|
1526
|
+
while [ "$_k" -le 175 ]; do
|
|
1527
|
+
mkdir -p "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k"
|
|
1528
|
+
if [ "$_k" -eq 1 ]; then
|
|
1529
|
+
printf '# Package %s\nSee [setup](setup.md) and (`run_cmd`) for details.\n' "$_k" > "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k/README.md"
|
|
1530
|
+
printf '# Setup for Package 1\nSetup instructions.\n' > "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k/setup.md"
|
|
1531
|
+
elif [ "$_k" -eq 2 ]; then
|
|
1532
|
+
printf '# Package %s\nRefer to [sibling](../pkg-1/README.md) for info.\n' "$_k" > "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k/README.md"
|
|
1533
|
+
elif [ "$_k" -eq 3 ]; then
|
|
1534
|
+
printf '# Package %s\nUse (`config.json`) for options.\n' "$_k" > "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k/README.md"
|
|
1535
|
+
else
|
|
1536
|
+
printf '# Package %s\nDocumentation for package %s.\n' "$_k" "$_k" > "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k/README.md"
|
|
1537
|
+
fi
|
|
1538
|
+
_k=$((_k + 1))
|
|
1539
|
+
done
|
|
1540
|
+
|
|
1541
|
+
cat <<'EOF_IDEM_CFG' > "$TEST_IDEM_WS/rnex.yaml"
|
|
1542
|
+
version: 1.0.0
|
|
1543
|
+
plugins:
|
|
1544
|
+
karpathy-llm:
|
|
1545
|
+
wiki_dir: wiki
|
|
1546
|
+
btree_shard_max_entries: 100
|
|
1547
|
+
sources: [repos/test-repo/packages]
|
|
1548
|
+
repos:
|
|
1549
|
+
test-repo:
|
|
1550
|
+
path: repos/test-repo
|
|
1551
|
+
EOF_IDEM_CFG
|
|
1552
|
+
|
|
1553
|
+
# Cycle 1: First Ingest
|
|
1554
|
+
_out_ingest1="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm ingest)"
|
|
1555
|
+
echo "$_out_ingest1" | grep -q "Ingested 176 missing source(s)" || {
|
|
1556
|
+
fail "First ingest failed to ingest 176 sources: $_out_ingest1"; exit 1;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
# Invariant: All shards must have <= 100 entries and zero numeric shards
|
|
1560
|
+
for _shard in "$TEST_IDEM_WS/wiki"/*.md; do
|
|
1561
|
+
[ -f "$_shard" ] || continue
|
|
1562
|
+
case "$(basename "$_shard")" in
|
|
1563
|
+
index.md|log.md) continue ;;
|
|
1564
|
+
esac
|
|
1565
|
+
_cnt="$(LC_ALL=C grep -c '^- \*\*' "$_shard" 2>/dev/null || true)"
|
|
1566
|
+
[ "$_cnt" -le 100 ] || { fail "Shard $(basename "$_shard") has $_cnt records (> 100)"; exit 1; }
|
|
1567
|
+
done
|
|
1568
|
+
_num_shards="$(find "$TEST_IDEM_WS/wiki" -name '*-[0-9]*.md' | grep -v 'log.md' || true)"
|
|
1569
|
+
[ -z "$_num_shards" ] || { fail "Numeric shards found: $_num_shards"; exit 1; }
|
|
1570
|
+
|
|
1571
|
+
# Cycle 2: First Lint (must be 100% clean with ZERO repairs)
|
|
1572
|
+
_out_lint1="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm lint)"
|
|
1573
|
+
echo "$_out_lint1" | grep -q "all existing docs and references in wiki are valid" || {
|
|
1574
|
+
fail "First lint reported repairs instead of clean validation: $_out_lint1"; exit 1;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
# Capture log checksum after first lint
|
|
1578
|
+
_log_sum1="$(cksum < "$TEST_IDEM_WS/wiki/log.md")"
|
|
1579
|
+
|
|
1580
|
+
# Cycle 3: Second Ingest (must be completely up to date with zero changes)
|
|
1581
|
+
_out_ingest2="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm ingest)"
|
|
1582
|
+
echo "$_out_ingest2" | grep -q "Wiki is up to date" || {
|
|
1583
|
+
fail "Second ingest re-ingested sources instead of reporting up to date: $_out_ingest2"; exit 1;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
# Cycle 4: Second Lint (must be 100% clean with ZERO repairs)
|
|
1587
|
+
_out_lint2="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm lint)"
|
|
1588
|
+
echo "$_out_lint2" | grep -q "all existing docs and references in wiki are valid" || {
|
|
1589
|
+
fail "Second lint reported repairs on unchanged wiki: $_out_lint2"; exit 1;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
# Cycle 5: Third Ingest (must remain completely up to date with zero changes)
|
|
1593
|
+
_out_ingest3="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm ingest)"
|
|
1594
|
+
echo "$_out_ingest3" | grep -q "Wiki is up to date" || {
|
|
1595
|
+
fail "Third ingest re-ingested sources instead of reporting up to date: $_out_ingest3"; exit 1;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
# Cycle 6: Third Lint (must remain 100% clean with ZERO repairs)
|
|
1599
|
+
_out_lint3="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm lint)"
|
|
1600
|
+
echo "$_out_lint3" | grep -q "all existing docs and references in wiki are valid" || {
|
|
1601
|
+
fail "Third lint reported repairs on unchanged wiki: $_out_lint3"; exit 1;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
# Verify audit log was not mutated in cycles 2, 3, 4, 5, or 6
|
|
1605
|
+
_log_sum2="$(cksum < "$TEST_IDEM_WS/wiki/log.md")"
|
|
1606
|
+
[ "$_log_sum1" = "$_log_sum2" ] || {
|
|
1607
|
+
fail "Operational log mutated during idempotent read-only cycles"; exit 1;
|
|
1608
|
+
}
|
|
1609
|
+
pass
|
|
1610
|
+
|
|
1512
1611
|
if [ "${_STANDALONE_RUN:-0}" -eq 1 ]; then
|
|
1513
1612
|
report_results
|
|
1514
1613
|
fi
|