80 func =
"_cmd_regenerate"
81 location = discover_registry_location(registry_path=args.registry)
82 workspace = Path(location.workspace_root)
83 source_dir = Path(args.source)
if args.source
else workspace /
"oc_chat" /
"roadmap" /
"source"
87 else workspace /
".option_c" /
"orchestration" /
"registry_authored.sqlite"
89 db_path.parent.mkdir(parents=
True, exist_ok=
True)
91 db_path = db_path.with_name(
"regen_dryrun.sqlite")
95 lock_path = workspace /
".option_c" /
"orchestration" /
"regenerate.lock"
97 source_dir, db_path, backend=args.backend, scope=args.scope,
98 lock_path=lock_path, force=args.force,
100 _dbg(
"OC_CHAT.MAIN", func, f
"regenerate ok={result.ok}", 3)
102 print(json.dumps(result.envelope, indent=2, sort_keys=
True))
105 f
"regenerate ok ({result.records} records, "
106 f
"logical_state_hash={result.logical_state_hash})"
109 print(f
"regenerate failed [{result.envelope.get('code')}]: {result.envelope.get('message')}")
110 return 0
if result.ok
else exit_code_for(result.error)