init: company-haness 설계
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CLI wrapper for the Org OS minimum-sufficient role planner."""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import yaml
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, HERE)
|
||||
from orgos.planning.role_selector import resolve_family, select_minimum_sufficient_roles # noqa: E402
|
||||
|
||||
|
||||
def _arg(args, name, default=None):
|
||||
return args[args.index(name) + 1] if name in args and args.index(name) + 1 < len(args) else default
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
sys.stderr.write("usage: role_selector.py plan --profile workload.yaml | resolve-family --family FAM-ID [--signals a,b] [--tier T]\n")
|
||||
return 2
|
||||
if args[0] == "resolve-family":
|
||||
family = _arg(args, "--family")
|
||||
signals = [item.strip() for item in str(_arg(args, "--signals", "")).split(",") if item.strip()]
|
||||
result = resolve_family(family, signals, _arg(args, "--tier", "standard")) if family else None
|
||||
elif args[0] == "plan":
|
||||
path = _arg(args, "--profile")
|
||||
if path:
|
||||
profile = yaml.safe_load(open(path, encoding="utf-8")) or {}
|
||||
else:
|
||||
profile = yaml.safe_load(sys.stdin.read()) or {}
|
||||
result = select_minimum_sufficient_roles(profile)
|
||||
else:
|
||||
result = None
|
||||
if not result:
|
||||
sys.stderr.write("role selection failed: unknown family/profile or no concrete coverage\n")
|
||||
return 2
|
||||
print(yaml.safe_dump(result, sort_keys=False, allow_unicode=True).rstrip())
|
||||
plan = result.get("selection-plan") or result.get("selection-plan", {})
|
||||
return 0 if not plan or plan.get("status") != "blocked" else 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user