64 lines
2.0 KiB
Python
Executable File
64 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Seed exactly one orchestration event when the project has no durable state."""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(REPO_ROOT))
|
|
|
|
from services.aios_orchestrator_gateway.config import Config
|
|
from services.aios_orchestrator_gateway.models import Event
|
|
from services.aios_orchestrator_gateway.securefs import atomic_write_bytes_shared
|
|
from services.aios_orchestrator_gateway.store import Store
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--config", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
|
|
config = Config.from_file(args.config)
|
|
store = Store(config.database_path)
|
|
if store.project_state(config.project_key) is not None:
|
|
print("ORCHESTRATION_BOOTSTRAP=NOOP reason=STATE_EXISTS")
|
|
return 0
|
|
|
|
event = Event.from_dict(
|
|
{
|
|
"schema_version": 1,
|
|
"project_key": config.project_key,
|
|
"contract_commit": config.contract_commit,
|
|
"event_id": "bootstrap-" + config.contract_commit[:24],
|
|
"source_agent": "system",
|
|
"event_type": "orchestration_bootstrap",
|
|
"work_unit_id": "ORCHESTRATION-BOOTSTRAP",
|
|
"status": "READY",
|
|
"state_version": 0,
|
|
"implementation_commit": None,
|
|
"result_commit": None,
|
|
"blocker": None,
|
|
"evidence_refs": [],
|
|
"payload": {
|
|
"reason": "initial_gateway_install",
|
|
"polling_enabled": True,
|
|
"openclaw_sync_required": True,
|
|
},
|
|
}
|
|
)
|
|
path = config.event_inbox_dir / "pending" / f"{event.event_id}.json"
|
|
atomic_write_bytes_shared(
|
|
path,
|
|
(event.canonical_json() + "\n").encode(),
|
|
mode=0o640,
|
|
group_writable_directory=True,
|
|
)
|
|
print(f"ORCHESTRATION_BOOTSTRAP=PASS event_id={event.event_id}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|