Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94d92a256d | ||
|
|
09b0694e63 | ||
|
|
9bbd0493a8 | ||
|
|
1dbb5db178 | ||
|
|
0773956bf3 | ||
|
|
de5b257e95 | ||
|
|
77f8544cd2 | ||
|
|
f2dae8e0f7 | ||
|
|
107968568e | ||
|
|
b9ad46090d | ||
|
|
1fab9e421b | ||
|
|
ae51d0d3a9 | ||
|
|
5488629d32 | ||
|
|
0a42095e4c | ||
|
|
5d347a0947 | ||
|
|
e35708995a | ||
|
|
264587c65c | ||
|
|
f6d98eeb88 | ||
|
|
38395f3bc2 | ||
|
|
0f3c796193 | ||
|
|
f6e53efefb |
@@ -0,0 +1,46 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: fix-agent-instructions-permission-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Repair GitOps Action runtime write permissions for agent instruction directories.
|
||||
|
||||
## Scope
|
||||
|
||||
Only:
|
||||
|
||||
- agent-instructions/
|
||||
- agent-instructions/codex/
|
||||
- agent-instructions/openclaw/
|
||||
- agent-instructions/hermes/
|
||||
- agent-instructions/windows_codex_app/
|
||||
- agent-instructions/custom_gpt_review/
|
||||
|
||||
## Execution Steps
|
||||
|
||||
1. Identify GitOps action runtime user.
|
||||
2. Inspect ownership and permissions.
|
||||
3. Apply minimum required ownership changes.
|
||||
4. Validate write access with temporary probes.
|
||||
5. Remove probes.
|
||||
|
||||
## Constraints
|
||||
|
||||
- No chmod 777.
|
||||
- No workspace-wide ownership changes.
|
||||
- No secrets.
|
||||
- No unrelated file commits.
|
||||
- No force push.
|
||||
|
||||
## Return Format
|
||||
|
||||
Status:
|
||||
Branch:
|
||||
Commit:
|
||||
Rev:
|
||||
Sync Status:
|
||||
Permission Result:
|
||||
Issues:
|
||||
@@ -0,0 +1,64 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: fix-gitops-managed-path-governance-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Prevent recurring GitOps permission drift by managing all writable repository paths through one governance policy.
|
||||
|
||||
## Managed Paths
|
||||
|
||||
- config/
|
||||
- reports/
|
||||
- proposals/
|
||||
- approvals/
|
||||
- versions/
|
||||
- agent-instructions/
|
||||
- runtime/
|
||||
- patches/
|
||||
|
||||
## Required Model
|
||||
|
||||
Ownership:
|
||||
|
||||
root:gitops
|
||||
|
||||
Runtime users:
|
||||
|
||||
- aiman
|
||||
- aios
|
||||
|
||||
Requirements:
|
||||
|
||||
- setgid directories
|
||||
- shared group write access
|
||||
- inherited group ownership
|
||||
- permission drift detection
|
||||
|
||||
## Validation
|
||||
|
||||
Check:
|
||||
|
||||
- shell runtime user
|
||||
- commit action runtime user
|
||||
- directory ownership
|
||||
- group membership
|
||||
- write probes
|
||||
|
||||
## Constraints
|
||||
|
||||
- No chmod 777.
|
||||
- No unsafe workspace-wide ownership changes.
|
||||
- No secrets.
|
||||
- No production changes.
|
||||
|
||||
## Return Format
|
||||
|
||||
Status:
|
||||
Runtime Users:
|
||||
Managed Paths:
|
||||
Ownership Model:
|
||||
Validation:
|
||||
Remaining Issues:
|
||||
@@ -0,0 +1,70 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: fix-gitops-workspace-permission-governance-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Permanently prevent repeated GitOps workspace permission failures across AIOS development and release workflows.
|
||||
|
||||
## Problem
|
||||
|
||||
Multiple directories have experienced inconsistent ownership between human/runtime users and GitOps action users:
|
||||
|
||||
- reports/
|
||||
- proposals/
|
||||
- approvals/
|
||||
- versions/
|
||||
- agent-instructions/
|
||||
- runtime/
|
||||
|
||||
## Execution Requirements
|
||||
|
||||
1. Identify the actual GitOps action runtime user.
|
||||
2. Identify all Git-managed writable workflow directories.
|
||||
3. Apply a consistent ownership model only to required workflow directories.
|
||||
4. Ensure new files inherit compatible permissions.
|
||||
5. Verify write access with temporary probes.
|
||||
6. Remove all probes.
|
||||
|
||||
## Required Directories
|
||||
|
||||
- reports/
|
||||
- proposals/
|
||||
- approvals/
|
||||
- versions/
|
||||
- agent-instructions/
|
||||
- runtime/
|
||||
|
||||
## Constraints
|
||||
|
||||
- No chmod 777.
|
||||
- No workspace-wide ownership changes.
|
||||
- No secrets.
|
||||
- No unrelated commits.
|
||||
- No force push.
|
||||
- Do not change production state.
|
||||
|
||||
## Permanent Solution Requirements
|
||||
|
||||
Prefer:
|
||||
|
||||
- shared group ownership,
|
||||
- setgid directory behavior where appropriate,
|
||||
- documented runtime user ownership,
|
||||
- consistent permission policy.
|
||||
|
||||
Avoid repeated manual directory fixes.
|
||||
|
||||
## Validation
|
||||
|
||||
Return:
|
||||
|
||||
Status:
|
||||
Runtime User:
|
||||
Ownership Model:
|
||||
Changed Directories:
|
||||
Permission Result:
|
||||
Probe Result:
|
||||
Remaining Issues:
|
||||
@@ -0,0 +1,69 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: type-hints-auto-fix-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Automatically add missing Python type hints identified during code quality validation.
|
||||
|
||||
## Scope
|
||||
|
||||
Target:
|
||||
|
||||
adapters/gitops/aios_gitops_model_api.py
|
||||
|
||||
## Required Fixes
|
||||
|
||||
Add parameter and return type annotations for:
|
||||
|
||||
- db()
|
||||
- rows(sql, args=())
|
||||
- one(sql, args=())
|
||||
- exec_sql(sql, args=())
|
||||
- audit(actor, action, target='', payload=None)
|
||||
- init_db()
|
||||
- seed_base_models()
|
||||
- git_cmd(args, check=False)
|
||||
- parse_body(handler)
|
||||
- api_spec()
|
||||
|
||||
## Suggested Types
|
||||
|
||||
- database connections: sqlite3.Connection
|
||||
- sql input: str
|
||||
- argument collections: Sequence[Any] or tuple
|
||||
- rows: list[dict]
|
||||
- one: dict | None
|
||||
- audit/init/seed: None return
|
||||
- git args: list[str]
|
||||
- api spec: dict
|
||||
|
||||
## Constraints
|
||||
|
||||
- Only modify type annotations.
|
||||
- Do not change runtime behavior.
|
||||
- Do not add dependencies unless required.
|
||||
- No secrets.
|
||||
- No force push.
|
||||
- GitOps workflow required.
|
||||
|
||||
## Validation
|
||||
|
||||
Run:
|
||||
|
||||
python3 -m compileall -q adapters/gitops/aios_gitops_model_api.py
|
||||
|
||||
Run relevant tests.
|
||||
|
||||
## Return Format
|
||||
|
||||
Status:
|
||||
Branch:
|
||||
Commit:
|
||||
Rev:
|
||||
Sync Status:
|
||||
Changed Files:
|
||||
Tests:
|
||||
Issues:
|
||||
@@ -0,0 +1,66 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: v1r1c5-cgpt-actions-confirmation-governance-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Complete CGPT Actions consequential write confirmation governance.
|
||||
|
||||
## Context
|
||||
|
||||
Completed:
|
||||
|
||||
- OpenAPI write operations marked x-openai-isConsequential: true.
|
||||
- api_spec risk classification implemented.
|
||||
- Confirmation interception added to branch/file/commit/patch/rollback.
|
||||
|
||||
## Required Changes
|
||||
|
||||
Complete confirmation protection for:
|
||||
|
||||
1. model()
|
||||
|
||||
Before model registration:
|
||||
- require confirm field.
|
||||
- return 428 confirm_required when missing.
|
||||
|
||||
2. model_priority()
|
||||
|
||||
Before priority changes:
|
||||
- require confirm field.
|
||||
- return 428 confirm_required when missing.
|
||||
|
||||
3. tag()
|
||||
|
||||
Complete confirmation logic:
|
||||
- require tag:create permission.
|
||||
- require confirm field.
|
||||
- block without explicit confirmation.
|
||||
|
||||
## Constraints
|
||||
|
||||
- Preserve existing API behavior.
|
||||
- Do not weaken consequential action protection.
|
||||
- No secrets.
|
||||
- No force push.
|
||||
- GitOps workflow only.
|
||||
|
||||
## Validation
|
||||
|
||||
Test:
|
||||
- missing confirm returns 428.
|
||||
- confirm=true allows authorized flow.
|
||||
- unauthorized scope remains blocked.
|
||||
|
||||
Return:
|
||||
|
||||
Status:
|
||||
Branch:
|
||||
Commit:
|
||||
Rev:
|
||||
Sync Status:
|
||||
Changed Files:
|
||||
Tests:
|
||||
Issues:
|
||||
@@ -0,0 +1,44 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: verify-commit-action-runtime-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Diagnose GitOps commit action runtime permission differences that prevent file writes while shell runtime permissions are correct.
|
||||
|
||||
## Checks
|
||||
|
||||
1. Identify commit action runtime user.
|
||||
2. Identify commit action workspace mount.
|
||||
3. Compare with shell runtime user.
|
||||
4. Check reports/proposals/agent-instructions/runtime write capability.
|
||||
5. Identify permission difference.
|
||||
|
||||
## Required Outcome
|
||||
|
||||
If mismatch exists:
|
||||
|
||||
- Align action runtime with gitops shared ownership model.
|
||||
- Preserve root:gitops ownership.
|
||||
- Preserve setgid behavior.
|
||||
- Avoid unsafe permission expansion.
|
||||
|
||||
## Constraints
|
||||
|
||||
- No chmod 777.
|
||||
- No workspace-wide unsafe ownership changes.
|
||||
- No secrets.
|
||||
- No force push.
|
||||
- No production actions.
|
||||
|
||||
## Return Format
|
||||
|
||||
Status:
|
||||
Commit Action User:
|
||||
Shell Runtime User:
|
||||
Workspace Mount:
|
||||
Permission Difference:
|
||||
Fix Required:
|
||||
Issues:
|
||||
@@ -0,0 +1,33 @@
|
||||
# Codex Execution Instruction
|
||||
|
||||
Instruction ID: verify-gitops-action-runtime-user-v1
|
||||
Version: v1
|
||||
Target Agent: codex
|
||||
|
||||
## Objective
|
||||
|
||||
Verify the actual GitOps Action runtime user and workspace permission inheritance.
|
||||
|
||||
## Checks
|
||||
|
||||
1. Identify runtime user.
|
||||
2. Identify groups.
|
||||
3. Confirm Gitea runtime user.
|
||||
4. Confirm workspace ownership model.
|
||||
5. Confirm setgid workflow directories.
|
||||
|
||||
## Expected Model
|
||||
|
||||
- Shared group ownership.
|
||||
- GitOps runtime user belongs to shared group.
|
||||
- No chmod 777.
|
||||
- No workspace-wide unsafe ownership changes.
|
||||
|
||||
## Return Format
|
||||
|
||||
Status:
|
||||
Runtime User:
|
||||
Gitea Runs As:
|
||||
Workspace Owner:
|
||||
Ownership Model:
|
||||
Remaining Issues:
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"type": "branch",
|
||||
"branch": "patch/V1R2C1-autonomous-orchestrator-foundation",
|
||||
"base": "main",
|
||||
"created_by": "gitops-write-bot",
|
||||
"created_at": "2026-07-07T04:24:24Z",
|
||||
"direct_main_push": false,
|
||||
"owner_approval_required": true
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"version": "V1R2C1",
|
||||
"status": "proposal",
|
||||
"source": "V1R1C5",
|
||||
"objective": "Upgrade AIOS from multi-agent execution workflow to autonomous orchestrator architecture",
|
||||
"architecture": {
|
||||
"orchestrator": "state-machine-driven autonomous coordinator",
|
||||
"planner": "GPT worker planning and reasoning layer",
|
||||
"reviewer": "Custom GPT advisory review layer",
|
||||
"executors": ["OpenClaw", "Hermes"],
|
||||
"recovery": "Windows Codex App recovery and privileged assistance"
|
||||
},
|
||||
"modules": [
|
||||
"orchestrator_state_machine",
|
||||
"run_store_and_evidence",
|
||||
"policy_gate",
|
||||
"planner_client",
|
||||
"reviewer_client",
|
||||
"executor_dispatcher",
|
||||
"result_collector",
|
||||
"notification_worker",
|
||||
"rollback_manager"
|
||||
],
|
||||
"autonomy_boundary": {
|
||||
"automatic": [
|
||||
"analysis",
|
||||
"planning",
|
||||
"patch_creation",
|
||||
"testing",
|
||||
"report_generation"
|
||||
],
|
||||
"owner_required": [
|
||||
"main_merge",
|
||||
"release_tag",
|
||||
"production_publish",
|
||||
"secret_change",
|
||||
"destructive_operation"
|
||||
]
|
||||
},
|
||||
"migration_target": "V1R2C1"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
"""V1R2C1 orchestrator evidence writer."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from time import time
|
||||
from typing import Any, Dict, List
|
||||
import uuid
|
||||
|
||||
|
||||
@dataclass
|
||||
class EvidenceRecord:
|
||||
evidence_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
||||
category: str = "general"
|
||||
data: Dict[str, Any] = field(default_factory=dict)
|
||||
created_at: float = field(default_factory=time)
|
||||
|
||||
|
||||
class EvidenceWriter:
|
||||
def __init__(self):
|
||||
self.records: List[EvidenceRecord] = []
|
||||
|
||||
def write(self, category: str, data: Dict[str, Any]):
|
||||
record = EvidenceRecord(category=category, data=data)
|
||||
self.records.append(record)
|
||||
return record
|
||||
|
||||
def query(self, category: str = None):
|
||||
if category:
|
||||
return [r for r in self.records if r.category == category]
|
||||
return self.records
|
||||
|
||||
def export_audit(self):
|
||||
return [
|
||||
{
|
||||
"evidence_id": r.evidence_id,
|
||||
"category": r.category,
|
||||
"data": r.data,
|
||||
"created_at": r.created_at,
|
||||
}
|
||||
for r in self.records
|
||||
]
|
||||
@@ -0,0 +1,55 @@
|
||||
"""V1R2C1 executor dispatcher."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class ExecutionRequest:
|
||||
agent: str
|
||||
task: str
|
||||
context: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ExecutionResult:
|
||||
agent: str
|
||||
status: str
|
||||
output: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
class ExecutorDispatcher:
|
||||
"""Dispatch execution requests to registered agent types.
|
||||
|
||||
Actual external agent communication is handled by integration layers.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.executors = {
|
||||
"openclaw": "server_execution",
|
||||
"hermes": "architecture_review",
|
||||
"windows_codex_app": "recovery_assistance",
|
||||
}
|
||||
self.history: List[ExecutionResult] = []
|
||||
|
||||
def dispatch(self, request: ExecutionRequest):
|
||||
if request.agent not in self.executors:
|
||||
result = ExecutionResult(
|
||||
agent=request.agent,
|
||||
status="unsupported",
|
||||
output={"error": "unknown executor"},
|
||||
)
|
||||
else:
|
||||
result = ExecutionResult(
|
||||
agent=request.agent,
|
||||
status="queued",
|
||||
output={
|
||||
"executor_type": self.executors[request.agent],
|
||||
"task": request.task,
|
||||
},
|
||||
)
|
||||
self.history.append(result)
|
||||
return result
|
||||
|
||||
def list_history(self):
|
||||
return self.history
|
||||
@@ -0,0 +1,59 @@
|
||||
"""V1R2C1 autonomous orchestrator integration tests."""
|
||||
|
||||
from .state_machine import StateMachine, RunState
|
||||
from .run_store import RunStore
|
||||
from .evidence_writer import EvidenceWriter
|
||||
from .policy_gate import PolicyGate, ActionLevel
|
||||
from .planner_client import PlannerClient
|
||||
from .reviewer_client import ReviewerClient
|
||||
from .executor_dispatcher import ExecutorDispatcher, ExecutionRequest
|
||||
from .result_collector import ResultCollector
|
||||
from .notification_worker import NotificationWorker
|
||||
from .rollback_manager import RollbackManager
|
||||
|
||||
|
||||
def run_tests():
|
||||
results = {}
|
||||
|
||||
state = StateMachine()
|
||||
state.transition(RunState.PLANNING)
|
||||
results["state_machine"] = state.current() == RunState.PLANNING
|
||||
|
||||
store = RunStore()
|
||||
run = store.create({"task": "v1r2c1"})
|
||||
store.update_state(run.run_id, "executing")
|
||||
results["run_store"] = store.get(run.run_id).state == "executing"
|
||||
|
||||
evidence = EvidenceWriter()
|
||||
evidence.write("test", {"ok": True})
|
||||
results["evidence"] = len(evidence.query("test")) == 1
|
||||
|
||||
policy = PolicyGate()
|
||||
results["policy_auto"] = policy.evaluate("testing") == ActionLevel.AUTOMATIC
|
||||
results["policy_owner"] = policy.evaluate("release_tag") == ActionLevel.OWNER_APPROVAL
|
||||
|
||||
planner = PlannerClient()
|
||||
results["planner"] = len(planner.create_plan("optimize" ).steps) > 0
|
||||
|
||||
reviewer = ReviewerClient()
|
||||
results["reviewer"] = reviewer.review("hermes", {"proposal": "test"}).decision == "conditional"
|
||||
|
||||
dispatcher = ExecutorDispatcher()
|
||||
results["dispatcher"] = dispatcher.dispatch(ExecutionRequest("openclaw", "test")).status == "queued"
|
||||
|
||||
collector = ResultCollector()
|
||||
collector.collect("openclaw", "success")
|
||||
results["collector"] = len(collector.success()) == 1
|
||||
|
||||
notifier = NotificationWorker()
|
||||
results["notification"] = notifier.notify("approval", "high")["status"] == "queued"
|
||||
|
||||
rollback = RollbackManager()
|
||||
rollback.create_request("V1R2C1", "V1R1C5", "test")
|
||||
results["rollback"] = rollback.requires_approval()
|
||||
|
||||
return results
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(run_tests())
|
||||
@@ -0,0 +1,40 @@
|
||||
"""V1R2C1 orchestrator notification worker."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from time import time
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class Notification:
|
||||
event: str
|
||||
priority: str
|
||||
payload: Dict[str, Any] = field(default_factory=dict)
|
||||
created_at: float = field(default_factory=time)
|
||||
|
||||
|
||||
class NotificationWorker:
|
||||
"""Owner and agent notification routing abstraction."""
|
||||
|
||||
def __init__(self):
|
||||
self.queue: List[Notification] = []
|
||||
self.channels = {
|
||||
"primary": "configured_owner_channel",
|
||||
"fallback": "configured_backup_channel",
|
||||
}
|
||||
|
||||
def notify(self, event: str, priority: str, payload: Dict[str, Any] | None = None):
|
||||
notification = Notification(
|
||||
event=event,
|
||||
priority=priority,
|
||||
payload=payload or {},
|
||||
)
|
||||
self.queue.append(notification)
|
||||
return {
|
||||
"status": "queued",
|
||||
"primary_channel": self.channels["primary"],
|
||||
"fallback_enabled": True,
|
||||
}
|
||||
|
||||
def pending(self):
|
||||
return self.queue
|
||||
@@ -0,0 +1,40 @@
|
||||
"""V1R2C1 autonomous orchestrator core controller."""
|
||||
|
||||
from .state_machine import StateMachine, RunState
|
||||
from .run_store import RunStore
|
||||
from .evidence_writer import EvidenceWriter
|
||||
from .policy_gate import PolicyGate
|
||||
|
||||
|
||||
class AutonomousOrchestrator:
|
||||
def __init__(self):
|
||||
self.run_store = RunStore()
|
||||
self.evidence = EvidenceWriter()
|
||||
self.policy = PolicyGate()
|
||||
self.state_machine = StateMachine()
|
||||
|
||||
def create_run(self, context=None):
|
||||
run = self.run_store.create(context)
|
||||
self.evidence.write("run_created", {"run_id": run.run_id})
|
||||
return run
|
||||
|
||||
def execute_stage(self, run_id, stage, action=None):
|
||||
run = self.run_store.get(run_id)
|
||||
if not run:
|
||||
return {"status": "not_found"}
|
||||
|
||||
if action and not self.policy.can_execute(action):
|
||||
self.evidence.write("policy_block", {"run_id": run_id, "action": action})
|
||||
return {"status": "approval_required", "action": action}
|
||||
|
||||
self.state_machine.transition(RunState.EXECUTING)
|
||||
self.run_store.update_state(run_id, stage)
|
||||
self.evidence.write("stage_execution", {"run_id": run_id, "stage": stage})
|
||||
|
||||
return {"status": "executed", "stage": stage}
|
||||
|
||||
def complete(self, run_id):
|
||||
self.state_machine.transition(RunState.COMPLETED)
|
||||
self.run_store.update_state(run_id, "completed")
|
||||
self.evidence.write("completed", {"run_id": run_id})
|
||||
return {"status": "completed", "run_id": run_id}
|
||||
@@ -0,0 +1,38 @@
|
||||
"""V1R2C1 planner client abstraction."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class Plan:
|
||||
objective: str
|
||||
steps: List[str] = field(default_factory=list)
|
||||
metadata: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
class PlannerClient:
|
||||
"""Planner interface for GPT planning workers.
|
||||
|
||||
This module defines orchestration boundaries and does not store credentials.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.plans = []
|
||||
|
||||
def create_plan(self, objective: str, context: Dict[str, Any] | None = None):
|
||||
plan = Plan(
|
||||
objective=objective,
|
||||
steps=[
|
||||
"analyze_context",
|
||||
"generate_options",
|
||||
"select_execution_path",
|
||||
"prepare_validation"
|
||||
],
|
||||
metadata=context or {},
|
||||
)
|
||||
self.plans.append(plan)
|
||||
return plan
|
||||
|
||||
def history(self):
|
||||
return self.plans
|
||||
@@ -0,0 +1,40 @@
|
||||
"""V1R2C1 autonomous orchestrator policy gate."""
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ActionLevel(str, Enum):
|
||||
AUTOMATIC = "automatic"
|
||||
OWNER_APPROVAL = "owner_approval"
|
||||
|
||||
|
||||
class PolicyGate:
|
||||
def __init__(self):
|
||||
self.owner_required = {
|
||||
"main_merge",
|
||||
"release_tag",
|
||||
"production_publish",
|
||||
"secret_change",
|
||||
"destructive_operation",
|
||||
}
|
||||
|
||||
self.automatic_allowed = {
|
||||
"analysis",
|
||||
"planning",
|
||||
"patch_creation",
|
||||
"testing",
|
||||
"report_generation",
|
||||
}
|
||||
|
||||
def evaluate(self, action: str):
|
||||
if action in self.owner_required:
|
||||
return ActionLevel.OWNER_APPROVAL
|
||||
if action in self.automatic_allowed:
|
||||
return ActionLevel.AUTOMATIC
|
||||
return ActionLevel.OWNER_APPROVAL
|
||||
|
||||
def can_execute(self, action: str, approved: bool = False):
|
||||
level = self.evaluate(action)
|
||||
if level == ActionLevel.AUTOMATIC:
|
||||
return True
|
||||
return approved
|
||||
@@ -0,0 +1,38 @@
|
||||
"""V1R2C1 orchestrator result collector."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List
|
||||
from time import time
|
||||
|
||||
|
||||
@dataclass
|
||||
class ExecutionResultRecord:
|
||||
agent: str
|
||||
status: str
|
||||
output: Dict[str, Any] = field(default_factory=dict)
|
||||
created_at: float = field(default_factory=time)
|
||||
|
||||
|
||||
class ResultCollector:
|
||||
"""Collect execution results and expose orchestration state."""
|
||||
|
||||
def __init__(self):
|
||||
self.results: List[ExecutionResultRecord] = []
|
||||
|
||||
def collect(self, agent: str, status: str, output: Dict[str, Any] | None = None):
|
||||
result = ExecutionResultRecord(
|
||||
agent=agent,
|
||||
status=status,
|
||||
output=output or {},
|
||||
)
|
||||
self.results.append(result)
|
||||
return result
|
||||
|
||||
def latest(self):
|
||||
return self.results[-1] if self.results else None
|
||||
|
||||
def success(self):
|
||||
return [r for r in self.results if r.status in {"success", "completed"}]
|
||||
|
||||
def failures(self):
|
||||
return [r for r in self.results if r.status in {"failed", "error"}]
|
||||
@@ -0,0 +1,38 @@
|
||||
"""V1R2C1 reviewer client abstraction."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
@dataclass
|
||||
class ReviewResult:
|
||||
reviewer: str
|
||||
decision: str
|
||||
issues: List[str] = field(default_factory=list)
|
||||
recommendations: List[str] = field(default_factory=list)
|
||||
metadata: Dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
|
||||
class ReviewerClient:
|
||||
"""Review interface for Custom GPT advisory and Hermes architecture review."""
|
||||
|
||||
def __init__(self):
|
||||
self.reviews = []
|
||||
|
||||
def review(self, reviewer: str, proposal: Dict[str, Any]):
|
||||
result = ReviewResult(
|
||||
reviewer=reviewer,
|
||||
decision="conditional",
|
||||
issues=[],
|
||||
recommendations=[
|
||||
"validate implementation",
|
||||
"check policy constraints",
|
||||
"record evidence"
|
||||
],
|
||||
metadata=proposal,
|
||||
)
|
||||
self.reviews.append(result)
|
||||
return result
|
||||
|
||||
def history(self):
|
||||
return self.reviews
|
||||
@@ -0,0 +1,35 @@
|
||||
"""V1R2C1 orchestrator rollback manager."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from time import time
|
||||
from typing import List
|
||||
|
||||
|
||||
@dataclass
|
||||
class RollbackRequest:
|
||||
source_version: str
|
||||
target_version: str
|
||||
reason: str
|
||||
created_at: float = field(default_factory=time)
|
||||
|
||||
|
||||
class RollbackManager:
|
||||
"""Manage safe rollback planning without automatic destructive actions."""
|
||||
|
||||
def __init__(self):
|
||||
self.requests: List[RollbackRequest] = []
|
||||
|
||||
def create_request(self, source_version: str, target_version: str, reason: str):
|
||||
request = RollbackRequest(
|
||||
source_version=source_version,
|
||||
target_version=target_version,
|
||||
reason=reason,
|
||||
)
|
||||
self.requests.append(request)
|
||||
return request
|
||||
|
||||
def history(self):
|
||||
return self.requests
|
||||
|
||||
def requires_approval(self):
|
||||
return True
|
||||
@@ -0,0 +1,32 @@
|
||||
"""V1R2C1 orchestrator run store."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from time import time
|
||||
from typing import Any, Dict
|
||||
import uuid
|
||||
|
||||
|
||||
@dataclass
|
||||
class RunRecord:
|
||||
run_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
||||
state: str = "created"
|
||||
context: Dict[str, Any] = field(default_factory=dict)
|
||||
events: list = field(default_factory=list)
|
||||
created_at: float = field(default_factory=time)
|
||||
|
||||
|
||||
class RunStore:
|
||||
def __init__(self):
|
||||
self.runs = {}
|
||||
|
||||
def create(self, context=None):
|
||||
run = RunRecord(context=context or {})
|
||||
self.runs[run.run_id] = run
|
||||
return run
|
||||
|
||||
def update_state(self, run_id, state):
|
||||
self.runs[run_id].state = state
|
||||
self.runs[run_id].events.append({"state": state, "time": time()})
|
||||
|
||||
def get(self, run_id):
|
||||
return self.runs.get(run_id)
|
||||
@@ -0,0 +1,25 @@
|
||||
"""V1R2C1 autonomous orchestrator state machine."""
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class RunState(str, Enum):
|
||||
CREATED = "created"
|
||||
PLANNING = "planning"
|
||||
EXECUTING = "executing"
|
||||
VALIDATING = "validating"
|
||||
COMPLETED = "completed"
|
||||
FAILED = "failed"
|
||||
PAUSED = "paused"
|
||||
|
||||
|
||||
class StateMachine:
|
||||
def __init__(self):
|
||||
self.state = RunState.CREATED
|
||||
|
||||
def transition(self, new_state: RunState):
|
||||
self.state = new_state
|
||||
return self.state
|
||||
|
||||
def current(self):
|
||||
return self.state
|
||||
Reference in New Issue
Block a user