interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / scripts / sync-standalone-repos.sh

551 lines · 21051 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17#
18# sync-standalone-repos.sh: Monorepo Crate Synchronization Pipeline
19#
20# Synchronizes crates from aien-sovereign-core to standalone publish repositories on DGX Spark.
21# Note (2026-10-10, #93): every standalone repository on GitHub is archived read-only
22# with a pointer back to its crate here. --check is the drift check against local
23# publish checkouts; sync mode only matters if they are ever unarchived.
24# Adheres strictly to Sovereign Voice: zero em dashes, zero en dashes.
25#
26# Preserved standalone-specific files:
27# action.yml, README.md, LICENSE, Cargo.lock, AGENTS.md, AGENT_CODE_OF_CONDUCT.md,
28# CONSTITUTION.md, CONTRIBUTING.md, SECURITY.md, PHILOSOPHY.md, agent.json, llms.txt,
29# evals.json, workflows.json, schemas/, kb/, failures/, assets/, scripts/, install.sh,
30# Dockerfile, .github/, .git/, .gitignore, .crumb, .crumb.local.
31
32set -euo pipefail
33
34SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
35SOVEREIGN_CORE="$(cd "$SCRIPT_DIR/.." && pwd)"
36# Parent directory holding the <publish_dirname> checkouts. Override for a CI
37# runner or a scratch directory; defaults to the monorepo's parent.
38WORKSPACE="${AIEN_MIRROR_WORKSPACE:-$(cd "$SOVEREIGN_CORE/.." && pwd)}"
39# Git source used for monorepo path dependencies in mirrored manifests.
40MONOREPO_GIT_URL="https://github.com/aien-dev/aien-sovereign-core-mv"
41
42# Source [dependencies] that sync_manifest may APPEND to a mirror manifest that
43# lacks them, per repo (space-separated dep names). Repos not listed get no
44# appended deps. Keep this list explicit: appending a dep changes what the
45# mirror builds, so each entry must be a reviewed decision.
46# spark-harness: aien-proof and blake3 back the verified completion gate (#533).
47# cortex-rs, spark-supervisor, spark-dream, spark-debugger: aien-localhttp
48# replaces reqwest for their local http calls (#553).
49manifest_append_deps() {
50 case "$1" in
51 spark-harness) echo "aien-proof blake3" ;;
52 cortex-rs | spark-supervisor | spark-dream | spark-debugger) echo "aien-localhttp" ;;
53 *) echo "" ;;
54 esac
55}
56
57# Source [dev-dependencies] that sync_manifest may rewrite or APPEND in a
58# mirror manifest, per repo. Same rule as manifest_append_deps: explicit,
59# reviewed entries only.
60# cortex-rs, spark-dream, spark-debugger: their #[cfg(test)] code uses
61# aien_localhttp::test_server, which needs the `test-server` feature (#553).
62manifest_append_dev_deps() {
63 case "$1" in
64 cortex-rs | spark-dream | spark-debugger) echo "aien-localhttp" ;;
65 *) echo "" ;;
66 esac
67}
68
69# Repository mapping: <cli_name>:<crate_subpath>:<publish_dirname>
70REPOS=(
71 "spark-hive:crates/spark-hive:spark-hive-publish"
72 "spark-supervisor:crates/spark-supervisor:spark-supervisor-publish"
73 "spark-dream:crates/spark-dream:spark-dream-publish"
74 "cortex-rs:crates/cortex-rs:cortex-rs-publish"
75 "spark-adapters:crates/spark-adapters:spark-adapters-publish"
76 "spark-crumbs:crates/spark-crumbs:spark-crumbs-publish"
77 "spark-debugger:crates/spark-debugger:spark-debugger-publish"
78 "spark-harness:crates/spark-harness:aien-harness-publish"
79 "spark-inquisitor:crates/spark-inquisitor:spark-inquisitor"
80 "rad-id-sync:crates/rad-id-sync:rad-id-sync-publish"
81)
82
83CHECK_MODE=false
84ALL_REPOS=false
85TARGET_REPO=""
86VERBOSE=false
87RUN_TESTS=false
88
89usage() {
90 cat << 'HELP_EOF'
91Usage: sync-standalone-repos.sh [OPTIONS]
92
93Synchronizes member crates from aien-sovereign-core to standalone publish repositories.
94
95Options:
96 --check Dry run and parity check mode (does not modify files on disk)
97 --all Synchronize or check all standalone repositories
98 --repo <name> Synchronize or check a specific repository by name
99 --verbose, -v Enable verbose logging and diff inspection
100 --test Run cargo test on synced repositories in addition to cargo check
101 --help, -h Show this help message and exit
102
103Preserved standalone files:
104 action.yml, README.md, LICENSE, Cargo.lock, AGENTS.md, AGENT_CODE_OF_CONDUCT.md,
105 CONSTITUTION.md, CONTRIBUTING.md, SECURITY.md, PHILOSOPHY.md, agent.json, llms.txt,
106 evals.json, workflows.json, schemas/, kb/, failures/, assets/, scripts/, install.sh,
107 Dockerfile, .github/, .git/, .gitignore, .crumb, .crumb.local.
108HELP_EOF
109}
110
111# Parse CLI arguments
112while [[ $# -gt 0 ]]; do
113 case "$1" in
114 --check)
115 CHECK_MODE=true
116 shift
117 ;;
118 --all)
119 ALL_REPOS=true
120 shift
121 ;;
122 --repo)
123 if [[ -z "${2:-}" ]]; then
124 echo "ERROR: --repo requires a repository name." >&2
125 exit 1
126 fi
127 TARGET_REPO="$2"
128 shift 2
129 ;;
130 --verbose|-v)
131 VERBOSE=true
132 shift
133 ;;
134 --test)
135 RUN_TESTS=true
136 shift
137 ;;
138 --help|-h)
139 usage
140 exit 0
141 ;;
142 *)
143 echo "ERROR: Unknown option: $1" >&2
144 usage
145 exit 1
146 ;;
147 esac
148done
149
150if [[ "$ALL_REPOS" = false && -z "$TARGET_REPO" ]]; then
151 echo "ERROR: Specify either --all or --repo <name>." >&2
152 echo "Run with --help for detailed usage." >&2
153 exit 1
154fi
155
156check_dirty_worktree() {
157 local target_dir="$1"
158 local repo_name="$2"
159 if [[ -d "$target_dir/.git" ]]; then
160 local git_status
161 git_status=$(git -C "$target_dir" status --porcelain 2>/dev/null || true)
162 if [[ -n "$git_status" ]]; then
163 echo "[WARN] Target worktree for $repo_name is dirty (uncommitted modifications detected):"
164 echo "$git_status"
165 return 1
166 fi
167 fi
168 return 0
169}
170
171# Value of `key = "..."` inside the [package] table of a manifest (first match).
172pkg_field() {
173 awk -v key="$2" '
174 /^[[:space:]]*\[/ { in_pkg = ($0 ~ /^[[:space:]]*\[package\][[:space:]]*$/); next }
175 in_pkg && $0 ~ "^[[:space:]]*" key "[[:space:]]*=[[:space:]]*\"" {
176 s = $0; sub(/^[^"]*"/, "", s); sub(/".*$/, "", s); print s; exit
177 }
178 ' "$1"
179}
180
181# Bring the destination [package] table in line with the source: license from the
182# workspace root (single source of truth), version and edition from the source crate.
183# Also: in-repo path deps become pinned git deps, and deps named by
184# manifest_append_deps for this repo are added when missing (see below).
185# Pure awk, no Python. Exit 0 parity or synced, 2 disparity in check mode, 1 error.
186sync_manifest() {
187 local src_manifest="$1"
188 local dest_manifest="$2"
189 local is_check="$3"
190 local repo_name="$4"
191 local ws_manifest="$SOVEREIGN_CORE/Cargo.toml"
192
193 local license_id
194 license_id=$(awk '
195 /^[[:space:]]*\[/ { in_ws = ($0 ~ /^[[:space:]]*\[workspace\.package\][[:space:]]*$/); next }
196 in_ws && /^[[:space:]]*license[[:space:]]*=[[:space:]]*"/ {
197 s = $0; sub(/^[^"]*"/, "", s); sub(/".*$/, "", s); print s; exit
198 }
199 ' "$ws_manifest")
200 if [[ -z "$license_id" ]]; then
201 echo "[ERROR] No [workspace.package] license in $ws_manifest"
202 return 1
203 fi
204
205 local src_version src_edition
206 src_version=$(pkg_field "$src_manifest" version)
207 src_edition=$(pkg_field "$src_manifest" edition)
208
209 local tmp
210 tmp=$(mktemp)
211 awk -v lic="$license_id" -v ver="$src_version" -v ed="$src_edition" '
212 function flush_license() {
213 if (in_pkg && !license_set) { printf "license = \"%s\"\n", lic; license_set = 1 }
214 }
215 /^[[:space:]]*\[package\][[:space:]]*$/ { in_pkg = 1; print; next }
216 /^[[:space:]]*\[/ { flush_license(); in_pkg = 0 }
217 in_pkg && /^[[:space:]]*license(\.workspace)?[[:space:]]*=/ { printf "license = \"%s\"\n", lic; license_set = 1; next }
218 in_pkg && ver != "" && /^[[:space:]]*version[[:space:]]*=/ { printf "version = \"%s\"\n", ver; next }
219 in_pkg && ed != "" && /^[[:space:]]*edition[[:space:]]*=/ { printf "edition = \"%s\"\n", ed; next }
220 { print }
221 END { flush_license() }
222 ' "$dest_manifest" > "$tmp"
223
224 # [dependencies]: a source dep of the form `name = { path = "../<crate>" ... }`
225 # cannot build outside the monorepo, and Cargo refuses `path` and `git` on one
226 # dependency ("Only one of `git` or `path` is allowed", cargo 1.98.1). So it is
227 # rewritten to a git dep on this monorepo pinned to `rev = <monorepo HEAD at
228 # sync time>` and replaces the mirror's entry of the same name. The pin lives
229 # in the manifest itself: the aien-harness mirror ships no Cargo.lock, so a
230 # floating branch would build whatever main is at build time. Consequences:
231 # sync from a commit that is pushed to the monorepo (cargo fetches it), and
232 # `--check` reports disparity for a mirror with path deps after every
233 # monorepo commit until it is re-synced. Only deps named by
234 # manifest_append_deps are appended when missing; every other mirror line,
235 # and every mirror with no path deps and no list entry, is left byte-identical.
236 local mono_rev append_deps
237 mono_rev=$(git -C "$SOVEREIGN_CORE" rev-parse HEAD) || {
238 echo "[ERROR] Cannot resolve monorepo HEAD in $SOVEREIGN_CORE"
239 return 1
240 }
241 append_deps=$(manifest_append_deps "$repo_name")
242 local tmp_deps
243 tmp_deps=$(mktemp)
244 awk -v url="$MONOREPO_GIT_URL" -v rev="$mono_rev" -v allow="$append_deps" '
245 function key_of(line, k) { k = line; sub(/[[:space:]]*=.*/, "", k); gsub(/^[[:space:]]+/, "", k); return k }
246 function emit_missing( i) { for (i = 1; i <= n; i++) if (!(keys[i] in seen)) print lines[i]; emitted = 1 }
247 function missing_count( i, c) { c = 0; for (i = 1; i <= n; i++) if (!(keys[i] in seen)) c++; return c }
248 BEGIN { na = split(allow, al, " "); for (i = 1; i <= na; i++) allowed[al[i]] = 1 }
249 FNR == NR {
250 if ($0 ~ /^[[:space:]]*\[/) { in_src = ($0 ~ /^[[:space:]]*\[dependencies\][[:space:]]*$/); next }
251 if (in_src && $0 ~ /^[[:space:]]*[A-Za-z0-9_-]+[[:space:]]*=/) {
252 line = $0
253 if (line ~ /path[[:space:]]*=[[:space:]]*"\.\.\//) {
254 gsub(/path[[:space:]]*=[[:space:]]*"\.\.\/[^"]*"/, "git = \"" url "\", rev = \"" rev "\"", line)
255 rewritten[key_of(line)] = line
256 }
257 if (key_of(line) in allowed) { n++; keys[n] = key_of(line); lines[n] = line }
258 }
259 next
260 }
261 /^[[:space:]]*\[/ {
262 if (in_dst && !emitted) emit_missing()
263 in_dst = ($0 ~ /^[[:space:]]*\[dependencies\][[:space:]]*$/)
264 if (in_dst) has_dst = 1
265 print; next
266 }
267 in_dst && /^[[:space:]]*[A-Za-z0-9_-]+[[:space:]]*=/ {
268 k = key_of($0); seen[k] = 1
269 if (k in rewritten) { print rewritten[k]; next }
270 }
271 { print }
272 END {
273 if (in_dst && !emitted) emit_missing()
274 else if (!has_dst && missing_count() > 0) { print ""; print "[dependencies]"; emit_missing() }
275 }
276 ' "$src_manifest" "$tmp" > "$tmp_deps"
277 mv "$tmp_deps" "$tmp"
278
279 # [dev-dependencies]: only keys named by manifest_append_dev_deps are touched.
280 # Each is rewritten from its source line (path to the pinned git dep) and
281 # replaces or is appended to the mirror's entry; mirrors with no list entry
282 # stay byte-identical.
283 local append_dev_deps
284 append_dev_deps=$(manifest_append_dev_deps "$repo_name")
285 if [[ -n "$append_dev_deps" ]]; then
286 tmp_deps=$(mktemp)
287 awk -v url="$MONOREPO_GIT_URL" -v rev="$mono_rev" -v allow="$append_dev_deps" '
288 function key_of(line, k) { k = line; sub(/[[:space:]]*=.*/, "", k); gsub(/^[[:space:]]+/, "", k); return k }
289 function is_dev(line) { return line ~ /^[[:space:]]*\[dev-dependencies\][[:space:]]*$/ }
290 function emit_missing( i) { for (i = 1; i <= n; i++) if (!(keys[i] in seen)) print lines[i]; emitted = 1 }
291 BEGIN { na = split(allow, al, " "); for (i = 1; i <= na; i++) allowed[al[i]] = 1 }
292 FNR == NR {
293 if ($0 ~ /^[[:space:]]*\[/) { in_src = is_dev($0); next }
294 if (in_src && $0 ~ /^[[:space:]]*[A-Za-z0-9_-]+[[:space:]]*=/ && key_of($0) in allowed) {
295 line = $0
296 gsub(/path[[:space:]]*=[[:space:]]*"\.\.\/[^"]*"/, "git = \"" url "\", rev = \"" rev "\"", line)
297 n++; keys[n] = key_of(line); lines[n] = line; src_line[keys[n]] = line
298 }
299 next
300 }
301 /^[[:space:]]*\[/ {
302 if (in_dst && !emitted) emit_missing()
303 in_dst = is_dev($0)
304 if (in_dst) has_dst = 1
305 print; next
306 }
307 in_dst && /^[[:space:]]*[A-Za-z0-9_-]+[[:space:]]*=/ {
308 k = key_of($0)
309 if (k in src_line) { seen[k] = 1; print src_line[k]; next }
310 }
311 { print }
312 END {
313 if (in_dst && !emitted) emit_missing()
314 else if (!has_dst && n > 0) { print ""; print "[dev-dependencies]"; emit_missing() }
315 }
316 ' "$src_manifest" "$tmp" > "$tmp_deps"
317 mv "$tmp_deps" "$tmp"
318 fi
319
320 if cmp -s "$tmp" "$dest_manifest"; then
321 rm -f "$tmp"
322 echo "[PARITY OK] Manifest $dest_manifest in parity (license = $license_id)"
323 return 0
324 fi
325 if [[ "$is_check" == "true" ]]; then
326 rm -f "$tmp"
327 echo "[DISPARITY] $dest_manifest requires manifest update (license $license_id, version/edition or dependencies)"
328 return 2
329 fi
330 mv "$tmp" "$dest_manifest"
331 echo "[SYNCED] Manifest updated: $dest_manifest (license = $license_id)"
332 return 0
333}
334
335check_unslop_invariants() {
336 local target_dir="$1"
337 local violations=0
338 while IFS= read -r -d '' file; do
339 if grep -q -P '[\x{2014}\x{2013}]' "$file" 2>/dev/null; then
340 echo "[UNSLOP VIOLATION] Prohibited dashes detected in: $file"
341 violations=$((violations + 1))
342 fi
343 done < <(find "$target_dir" -type f \( -name "*.rs" -o -name "*.md" -o -name "*.toml" \) -not -path "*/.git/*" -not -path "*/target/*" -print0)
344 return $violations
345}
346
347process_repo() {
348 local entry="$1"
349 IFS=':' read -r cli_name crate_subpath publish_dirname <<< "$entry"
350
351 local src_dir="$SOVEREIGN_CORE/$crate_subpath"
352 if [[ ! -d "$src_dir" && "$crate_subpath" =~ ^basecamp/ ]]; then
353 src_dir="$WORKSPACE/$crate_subpath"
354 fi
355
356 local dest_dir="$WORKSPACE/$publish_dirname"
357
358 echo "============================================================"
359 echo "Target: $publish_dirname (Source: $crate_subpath)"
360 echo "============================================================"
361
362 if [[ ! -d "$dest_dir" ]]; then
363 echo "ERROR: Target publish directory does not exist: $dest_dir" >&2
364 return 1
365 fi
366
367 if [[ ! -d "$src_dir" ]]; then
368 echo "ERROR: Source directory does not exist: $src_dir" >&2
369 return 1
370 fi
371
372 local repo_has_disparity=0
373
374 # Step 1: Check dirty target worktree
375 check_dirty_worktree "$dest_dir" "$publish_dirname" || true
376
377 # Step 2: Clean stray metadata files from source before sync
378 if [[ "$CHECK_MODE" = false ]]; then
379 find "$src_dir/src" -name "*.metadata.json" -delete 2>/dev/null || true
380 fi
381
382 # Step 3: Source directory synchronization and parity check
383 if [[ "$CHECK_MODE" = true ]]; then
384 local src_diff
385 src_diff=$(diff -ru --exclude='*.metadata.json' --exclude='.git*' "$src_dir/src" "$dest_dir/src" 2>&1 || true)
386 if [[ -n "$src_diff" ]]; then
387 echo "[DISPARITY] src/ tree difference detected for $publish_dirname"
388 if [[ "$VERBOSE" = true ]]; then
389 echo "$src_diff"
390 fi
391 repo_has_disparity=1
392 else
393 echo "[PARITY OK] src/ tree in parity for $publish_dirname"
394 fi
395
396 # Check tests directory if present in source
397 if [[ -d "$src_dir/tests" && -d "$dest_dir/tests" ]]; then
398 local tests_diff
399 tests_diff=$(diff -ru --exclude='.git*' "$src_dir/tests" "$dest_dir/tests" 2>&1 || true)
400 if [[ -n "$tests_diff" ]]; then
401 echo "[DISPARITY] tests/ tree difference detected for $publish_dirname"
402 if [[ "$VERBOSE" = true ]]; then
403 echo "$tests_diff"
404 fi
405 repo_has_disparity=1
406 else
407 echo "[PARITY OK] tests/ tree in parity for $publish_dirname"
408 fi
409 fi
410
411 # Check schemas directory for spark-harness
412 if [[ -d "$src_dir/schemas" && -d "$dest_dir/schemas" ]]; then
413 local schemas_diff
414 schemas_diff=$(diff -ru --exclude='.git*' "$src_dir/schemas" "$dest_dir/schemas" 2>&1 || true)
415 if [[ -n "$schemas_diff" ]]; then
416 echo "[DISPARITY] schemas/ tree difference detected for $publish_dirname"
417 if [[ "$VERBOSE" = true ]]; then
418 echo "$schemas_diff"
419 fi
420 repo_has_disparity=1
421 else
422 echo "[PARITY OK] schemas/ tree in parity for $publish_dirname"
423 fi
424 fi
425 else
426 echo "[SYNC] Synchronizing src/ from $src_dir/src to $dest_dir/src..."
427 rsync -a --delete --exclude='*.metadata.json' --exclude='.git*' "$src_dir/src/" "$dest_dir/src/"
428
429 if [[ -d "$src_dir/tests" && -d "$dest_dir/tests" ]]; then
430 echo "[SYNC] Synchronizing tests/ from $src_dir/tests to $dest_dir/tests..."
431 rsync -a --delete --exclude='.git*' "$src_dir/tests/" "$dest_dir/tests/"
432 fi
433
434 if [[ -d "$src_dir/schemas" && -d "$dest_dir/schemas" ]]; then
435 echo "[SYNC] Synchronizing schemas/ from $src_dir/schemas to $dest_dir/schemas..."
436 rsync -a --delete --exclude='.git*' "$src_dir/schemas/" "$dest_dir/schemas/"
437 fi
438
439 if [[ -f "$src_dir/evals.json" && -f "$dest_dir/evals.json" ]]; then
440 cp "$src_dir/evals.json" "$dest_dir/evals.json"
441 fi
442
443 if [[ -f "$src_dir/workflows.json" && -f "$dest_dir/workflows.json" ]]; then
444 cp "$src_dir/workflows.json" "$dest_dir/workflows.json"
445 fi
446
447 diff -ru --exclude='*.metadata.json' --exclude='.git*' "$src_dir/src" "$dest_dir/src"
448 echo "[PARITY VERIFIED] src/ tree parity verified with diff -ru"
449 fi
450
451 # Step 4: Selective manifest synchronization
452 if [[ -f "$src_dir/Cargo.toml" && -f "$dest_dir/Cargo.toml" ]]; then
453 local manifest_code=0
454 if sync_manifest "$src_dir/Cargo.toml" "$dest_dir/Cargo.toml" "$CHECK_MODE" "$cli_name"; then
455 manifest_code=0
456 else
457 manifest_code=$?
458 fi
459 if [[ $manifest_code -eq 2 ]]; then
460 repo_has_disparity=1
461 elif [[ $manifest_code -ne 0 ]]; then
462 echo "ERROR: Failed to process manifest for $publish_dirname" >&2
463 return 1
464 fi
465 fi
466
467 # Step 5: Unslop Invariants Scan
468 if ! check_unslop_invariants "$dest_dir"; then
469 echo "[WARN] Unslop violations found in $publish_dirname"
470 if [[ "$CHECK_MODE" = true ]]; then
471 repo_has_disparity=1
472 fi
473 fi
474
475 # Step 6: Code Formatting
476 if [[ "$CHECK_MODE" = false ]]; then
477 echo "[CARGO FMT] Formatting code in $dest_dir..."
478 cargo fmt --manifest-path "$dest_dir/Cargo.toml" --quiet 2>/dev/null || cargo fmt --manifest-path "$dest_dir/Cargo.toml"
479 fi
480
481 # Step 7: Compilation and Test Validation (in sync mode)
482 if [[ "$CHECK_MODE" = false ]]; then
483 echo "[CARGO CHECK] Verifying compilation in $dest_dir..."
484 cargo check --manifest-path "$dest_dir/Cargo.toml" --quiet
485 echo "[CARGO CHECK PASSED] $publish_dirname compiles cleanly."
486
487 if [[ "$RUN_TESTS" = true ]]; then
488 echo "[CARGO TEST] Running test suite in $dest_dir..."
489 cargo test --manifest-path "$dest_dir/Cargo.toml" --quiet
490 echo "[CARGO TEST PASSED] $publish_dirname passed all tests."
491 fi
492 fi
493
494 return $repo_has_disparity
495}
496
497# Main execution loop
498TOTAL_FAILED=0
499PROCESSED_COUNT=0
500
501for entry in "${REPOS[@]}"; do
502 IFS=':' read -r cli_name crate_subpath publish_dirname <<< "$entry"
503
504 if [[ "$ALL_REPOS" = false ]]; then
505 clean_target="${TARGET_REPO%-publish}"
506 clean_cli="${cli_name%-publish}"
507 clean_pub="${publish_dirname%-publish}"
508 if [[ "$TARGET_REPO" != "$cli_name" && "$TARGET_REPO" != "$publish_dirname" && "$clean_target" != "$clean_cli" && "$clean_target" != "$clean_pub" ]]; then
509 continue
510 fi
511 fi
512
513 PROCESSED_COUNT=$((PROCESSED_COUNT + 1))
514 if process_repo "$entry"; then
515 repo_rc=0
516 else
517 repo_rc=$?
518 fi
519 if [[ $repo_rc -ne 0 ]]; then
520 TOTAL_FAILED=$((TOTAL_FAILED + 1))
521 fi
522done
523
524if [[ $PROCESSED_COUNT -eq 0 ]]; then
525 echo "ERROR: Repository '$TARGET_REPO' not recognized." >&2
526 echo "Available repositories:" >&2
527 for entry in "${REPOS[@]}"; do
528 IFS=':' read -r cli_name _ publish_dirname <<< "$entry"
529 echo " - $cli_name (target: $publish_dirname)" >&2
530 done
531 exit 1
532fi
533
534echo "============================================================"
535if [[ "$CHECK_MODE" = true ]]; then
536 if [[ $TOTAL_FAILED -eq 0 ]]; then
537 echo "[STATUS: ALL IN PARITY] All $PROCESSED_COUNT repositories match source state and workspace license."
538 exit 0
539 else
540 echo "[STATUS: DISPARITY DETECTED] $TOTAL_FAILED of $PROCESSED_COUNT repositories exhibit drift or disparities."
541 exit 1
542 fi
543else
544 if [[ $TOTAL_FAILED -eq 0 ]]; then
545 echo "[STATUS: SYNC SUCCESS] Successfully synchronized $PROCESSED_COUNT repositories."
546 exit 0
547 else
548 echo "[STATUS: SYNC FAILED] $TOTAL_FAILED of $PROCESSED_COUNT repositories failed synchronization."
549 exit 1
550 fi
551fi