trading-system-docs/tolaria/c4b-search-service/rebuild.py
Red Queen 5e4191578a fix(tolaria): C5D search-source pipeline — build+verify source from current Tolaria before rebuild
- SearchSourceBuilder: deterministischer Vault->Source-Snapshot (read-only),
  atomar (temp->validate->fsync->replace), Secret-Scan fail-closed
- verify_integrity: exakte object_id/path Set-Equality (stale Source kann
  nie APPLIED), Canary implizit ueber erwartetes Objekt-Set
- apply_commit: Source-Build+Verification vor Rebuild; VERIFYING_SEARCH-Resume
  (kein Doppel-Rebuild) — C5E-Replay-Crash-Fall abgedeckt
- Fix: source_object_count ist keine 0-Fehlerbedingung (echter Defekt)
- SearchSourceBuildError + RC_SEARCH_SOURCE_BUILD_FAILURE (Human Gate)
- c4b: source_path env-konfigurierbar, indexed_object_ids/paths Read-Back
- Testsuite: 17 neue Tests (Test-Plan A-O + Realistic C4-Integration)
2026-08-26 12:12:45 +00:00

41 lines
1.4 KiB
Python

"""
TOLARIA SEARCH SERVICE — Rebuild CLI (C4B)
================================================================
Baut den Keyword/Metadata-Index aus dem Forgejo-SoT-Source-JSON neu (DERIVED,
vollständig wegwerfbar + rebuildbar). Kein pgvector, keine Vector-Extension.
"""
import json
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
from search_api import TolariaSearch
INDEX_JSON = os.path.join(os.path.dirname(__file__), "data", "search_index.json")
def main():
import argparse
p = argparse.ArgumentParser(description="TOLARIA SEARCH rebuild")
p.add_argument("--source", default=os.path.join(os.path.dirname(__file__), "index_source.json"))
p.add_argument("--head", default=None)
p.add_argument("--no-secret-filter", action="store_true")
args = p.parse_args()
engine = TolariaSearch(index_path=INDEX_JSON)
res = engine.rebuild_from_source(args.source, head=args.head,
secret_filter=not args.no_secret_filter)
print(json.dumps({
"status": "rebuilt",
"indexed": res["indexed"],
"blocked": res["blocked"],
"index_path": INDEX_JSON,
"supported_modes": ["exact", "keyword", "metadata"],
"source_head": engine.source_head,
"indexed_object_ids": engine.indexed_object_ids,
"indexed_paths": engine.indexed_paths,
}, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()