/forge — Execution Primitive (Parameterized)
When /forge <task description> is invoked, the agent routes execution to the appropriate executor. This is NOT the seal — it is the action after /init and before /propose-seal.
Agent detection: Use $AGENT_RUNTIME env var or context to determine which variant applies. Values: hermes, openclaw, opencode.
Output format
FORGE ROUTED
────────────────────────────────────
Task: <task description>
Executor: <see Agent-Specific Bindings>
Authority: T1 (auto-mutate)
Risk: REVERSIBLE
────────────────────────────────────
Routing:
<see Agent-Specific Bindings>
────────────────────────────────────
Pre-check:
F1 AMANAH ✅ reversible path exists
F4 CLARITY ✅ ΔS measured before/after
F11 AUDIT ✅ (commit + receipt trail)
F13 SOVEREIGN ⚠️ (no F13 ack needed for T1)
────────────────────────────────────
→ Executing in background...
→ Receipt will be appended to session
→ /forge-status to check progress
DITEMPA BUKAN DIBERI 🔥
Agent-Specific Bindings
Hermes (AGENT_RUNTIME=hermes)
| Field |
Value |
| Executor options |
OpenCode-Zen (delegate_task), A-FORGE (forge_execute), Hermes (self-execute) |
| Code-gen routing |
delegate_task → opencode binary |
| Audit/verify routing |
Hermes self-execute with read-only tools |
| PDF generation |
Hermes self-execute via report generation |
| Actor label in receipt |
hermes-<executor> |
OpenClaw (AGENT_RUNTIME=openclaw)
| Field |
Value |
| Executor options |
OpenCode-Zen (spawn subagent), A-FORGE (forge_execute), OpenClaw (self-execute) |
| Code-gen routing |
spawn_opencode_subagent in temp worktree (/tmp/openclaw-worktree) |
| Audit/verify routing |
OpenClaw self-execute with verify tools |
| PDF generation |
OpenClaw self-execute via report generation |
| Actor label in receipt |
openclaw-<executor> |
OpenCode (AGENT_RUNTIME=opencode)
| Field |
Value |
| Executor |
OpenCode (self) — coding agent, always self-execute |
| Warga |
FI-001 PRIMARY |
| Extra gates |
LSP gate check (mandatory before commit) |
| Extra gates |
Test results must pass |
| Authority chain |
OpenCode-Zen → delegate_task from Hermes/OpenClaw → A-FORGE → git push → deploy guard |
| Actor label in receipt |
opencode-zen |
| Digital Ops Policy |
digital/code/AI/infra = MUBAH (auto-execute) per 2026-06-30 directive |
Task classification
| Task type |
Executor |
Pattern |
| Code generation / refactor |
OpenCode-Zen |
delegate_task (Hermes) / spawn subagent (OpenClaw) / self (OpenCode) |
| Code review |
Calling agent |
self-execute with read-only tools |
| Infra / deploy / restart |
A-FORGE |
call_aforge_execute (requires lease) |
| Audit / verification |
Calling agent |
self-execute with verify tools |
| F1-F13 constitutional |
888-HOLD |
route to propose-seal, not forge |
| PDF generation |
Calling agent |
self-execute via report generation |
T0-T3 Tier Classification (OpenCode primary, applies to all)
| Tier |
Examples |
Behavior |
| T0 |
Read, grep, git log, port check |
Auto-do, no announcement |
| T1 |
Edit, build, test, lint, format, commit, push, restart own session |
Auto-do, F2 evidence in commit body |
| T2 |
Multi-file refactor, new dependency, deploy after green tests |
Announce 10s window, then proceed |
| T3 |
rm -rf, DROP TABLE, force-push to main, paid API > $10/mo, F1-F13 changes |
888_HOLD — request sovereign ack |
Implementation
def forge_handler(task: str, agent_runtime: str):
"""Parameterized /forge handler"""
# 1. /init guard
envelope = read_federation_session()
if not envelope.get("session_id"):
return "ERROR: /init first. No session bound."
# 2. Classify tier
tier = classify_tier(task)
if tier == "T3":
return "🛑 888_HOLD — use /propose-seal for irreversible work"
# 3. Measure ΔS_before
entropy_before = measure_session_entropy()
# 4. Route to executor
executor = classify_task_executor(task, agent_runtime)
if agent_runtime == "opencode":
# OpenCode self-executes coding tasks
result = execute_coding_task(task)
# LSP gate check (mandatory before commit)
if not lsp_gate_passed(result):
return "🛑 LSP GATE FAILED — fix errors before commit"
elif agent_runtime == "openclaw":
if executor == "opencode":
result = spawn_opencode_subagent(
task=task,
worktree="/tmp/openclaw-worktree",
toolsets=["code", "terminal"],
timeout=300
)
elif executor == "aforge":
result = call_aforge_execute(task=task, lease_type="T1")
else:
result = self_execute(task)
elif agent_runtime == "hermes":
if executor == "opencode":
result = delegate_task(task=task, toolsets=["code", "terminal"], timeout=300)
elif executor == "aforge":
result = call_aforge_execute(task=task, lease_type="T1")
else:
result = self_execute(task)
# 5. Measure ΔS_after
entropy_after = measure_session_entropy()
delta_s = entropy_after - entropy_before
# 6. Build receipt
receipt = {
"ts": now_iso(),
"event": "FORGE_EXECUTED",
"actor": f"{agent_runtime}-{executor}",
"session": envelope["session_id"],
"task": task,
"result_summary": summarize(result),
"delta_s": delta_s,
"evidence_hash": sha256_of_result(result),
}
# 7. Return with receipt
return render_forge_result(receipt)
Doctrine
/forge = the action layer between /init and /propose-seal
/forge is NOT the seal — seal is /propose-seal → 888-APEX
/forge is the "go execute" that happens AFTER /init establishes identity
- F1 reversibility is the hard gate — if ΔS > 0, HALT and HOLD
- F11 audit — every /forge appends a receipt to the session
- F13 sovereignty — T3 requires Arif's ack, no exceptions
ZEN
/init = WHO AM I?
/forge = GO DO IT
/propose-seal = RECORD IT PERMANENTLY
Together:
/init → /forge → /propose-seal
The forge cycle:
identity → action → evidence → verdict → permanent record
Without /init: /forge has no actor context
Without /forge: /propose-seal has nothing to seal
Without /propose-seal: /forge result is temporary
Error states
| Condition |
Response |
| No /init called |
ERROR: /init first. No session bound. |
| Task classified T3 |
🛑 888_HOLD — use /propose-seal for irreversible work |
| LSP gate failed (OpenCode) |
🛑 LSP GATE FAILED — fix errors before commit |
| Test failures (OpenCode) |
🛑 TESTS FAILED — fix or HOLD before commit |
| ΔS > 0 after execution |
🛑 F1 VIOLATION — ΔS positive. Rollback initiated. |
| A-FORGE unreachable |
⚠️ A-FORGE offline. Self-executing within agent authority. |
| OpenCode busy (max 3 concurrent) |
⏳ Queue full. /forge queued — priority = NORMAL |
| Commit blocked (deploy guard) |
⛔ deploy guard — local HEAD ahead of origin. Push first. |
1---2name: substrate-forge3description: Substrate Forge4license: MIT5---67# /forge — Execution Primitive (Parameterized)89When `/forge <task description>` is invoked, the agent routes execution to the appropriate executor. This is NOT the seal — it is the action after /init and before /propose-seal.1011**Agent detection:** Use `$AGENT_RUNTIME` env var or context to determine which variant applies. Values: `hermes`, `openclaw`, `opencode`.1213## Output format1415```16FORGE ROUTED17────────────────────────────────────18Task: <task description>19Executor: <see Agent-Specific Bindings>20Authority: T1 (auto-mutate)21Risk: REVERSIBLE22────────────────────────────────────23Routing:24 <see Agent-Specific Bindings>25────────────────────────────────────26Pre-check:27 F1 AMANAH ✅ reversible path exists28 F4 CLARITY ✅ ΔS measured before/after29 F11 AUDIT ✅ (commit + receipt trail)30 F13 SOVEREIGN ⚠️ (no F13 ack needed for T1)31────────────────────────────────────32→ Executing in background...33→ Receipt will be appended to session34→ /forge-status to check progress3536DITEMPA BUKAN DIBERI 🔥37```3839## Agent-Specific Bindings4041### Hermes (`AGENT_RUNTIME=hermes`)4243| Field | Value |44|-------|-------|45| Executor options | OpenCode-Zen (delegate_task), A-FORGE (forge_execute), Hermes (self-execute) |46| Code-gen routing | `delegate_task` → opencode binary |47| Audit/verify routing | Hermes self-execute with read-only tools |48| PDF generation | Hermes self-execute via report generation |49| Actor label in receipt | `hermes-<executor>` |5051### OpenClaw (`AGENT_RUNTIME=openclaw`)5253| Field | Value |54|-------|-------|55| Executor options | OpenCode-Zen (spawn subagent), A-FORGE (forge_execute), OpenClaw (self-execute) |56| Code-gen routing | `spawn_opencode_subagent` in temp worktree (`/tmp/openclaw-worktree`) |57| Audit/verify routing | OpenClaw self-execute with verify tools |58| PDF generation | OpenClaw self-execute via report generation |59| Actor label in receipt | `openclaw-<executor>` |6061### OpenCode (`AGENT_RUNTIME=opencode`)6263| Field | Value |64|-------|-------|65| Executor | OpenCode (self) — coding agent, always self-execute |66| Warga | FI-001 PRIMARY |67| Extra gates | LSP gate check (mandatory before commit) |68| Extra gates | Test results must pass |69| Authority chain | OpenCode-Zen → delegate_task from Hermes/OpenClaw → A-FORGE → git push → deploy guard |70| Actor label in receipt | `opencode-zen` |71| Digital Ops Policy | digital/code/AI/infra = MUBAH (auto-execute) per 2026-06-30 directive |7273## Task classification7475| Task type | Executor | Pattern |76|---|---|---|77| Code generation / refactor | OpenCode-Zen | delegate_task (Hermes) / spawn subagent (OpenClaw) / self (OpenCode) |78| Code review | Calling agent | self-execute with read-only tools |79| Infra / deploy / restart | A-FORGE | call_aforge_execute (requires lease) |80| Audit / verification | Calling agent | self-execute with verify tools |81| F1-F13 constitutional | 888-HOLD | route to propose-seal, not forge |82| PDF generation | Calling agent | self-execute via report generation |8384## T0-T3 Tier Classification (OpenCode primary, applies to all)8586| Tier | Examples | Behavior |87|---|---|---|88| **T0** | Read, grep, git log, port check | Auto-do, no announcement |89| **T1** | Edit, build, test, lint, format, commit, push, restart own session | Auto-do, F2 evidence in commit body |90| **T2** | Multi-file refactor, new dependency, deploy after green tests | Announce 10s window, then proceed |91| **T3** | rm -rf, DROP TABLE, force-push to main, paid API > $10/mo, F1-F13 changes | 888_HOLD — request sovereign ack |9293## Implementation9495```python96def forge_handler(task: str, agent_runtime: str):97 """Parameterized /forge handler"""9899 # 1. /init guard100 envelope = read_federation_session()101 if not envelope.get("session_id"):102 return "ERROR: /init first. No session bound."103104 # 2. Classify tier105 tier = classify_tier(task)106 if tier == "T3":107 return "🛑 888_HOLD — use /propose-seal for irreversible work"108109 # 3. Measure ΔS_before110 entropy_before = measure_session_entropy()111112 # 4. Route to executor113 executor = classify_task_executor(task, agent_runtime)114115 if agent_runtime == "opencode":116 # OpenCode self-executes coding tasks117 result = execute_coding_task(task)118 # LSP gate check (mandatory before commit)119 if not lsp_gate_passed(result):120 return "🛑 LSP GATE FAILED — fix errors before commit"121 elif agent_runtime == "openclaw":122 if executor == "opencode":123 result = spawn_opencode_subagent(124 task=task,125 worktree="/tmp/openclaw-worktree",126 toolsets=["code", "terminal"],127 timeout=300128 )129 elif executor == "aforge":130 result = call_aforge_execute(task=task, lease_type="T1")131 else:132 result = self_execute(task)133 elif agent_runtime == "hermes":134 if executor == "opencode":135 result = delegate_task(task=task, toolsets=["code", "terminal"], timeout=300)136 elif executor == "aforge":137 result = call_aforge_execute(task=task, lease_type="T1")138 else:139 result = self_execute(task)140141 # 5. Measure ΔS_after142 entropy_after = measure_session_entropy()143 delta_s = entropy_after - entropy_before144145 # 6. Build receipt146 receipt = {147 "ts": now_iso(),148 "event": "FORGE_EXECUTED",149 "actor": f"{agent_runtime}-{executor}",150 "session": envelope["session_id"],151 "task": task,152 "result_summary": summarize(result),153 "delta_s": delta_s,154 "evidence_hash": sha256_of_result(result),155 }156157 # 7. Return with receipt158 return render_forge_result(receipt)159```160161## Doctrine162163- `/forge` = the action layer between /init and /propose-seal164- `/forge` is NOT the seal — seal is /propose-seal → 888-APEX165- `/forge` is the "go execute" that happens AFTER /init establishes identity166- F1 reversibility is the hard gate — if ΔS > 0, HALT and HOLD167- F11 audit — every /forge appends a receipt to the session168- F13 sovereignty — T3 requires Arif's ack, no exceptions169170## ZEN171172```173/init = WHO AM I?174/forge = GO DO IT175/propose-seal = RECORD IT PERMANENTLY176177Together:178 /init → /forge → /propose-seal179180The forge cycle:181 identity → action → evidence → verdict → permanent record182183Without /init: /forge has no actor context184Without /forge: /propose-seal has nothing to seal185Without /propose-seal: /forge result is temporary186```187188## Error states189190| Condition | Response |191|---|---|192| No /init called | `ERROR: /init first. No session bound.` |193| Task classified T3 | `🛑 888_HOLD — use /propose-seal for irreversible work` |194| LSP gate failed (OpenCode) | `🛑 LSP GATE FAILED — fix errors before commit` |195| Test failures (OpenCode) | `🛑 TESTS FAILED — fix or HOLD before commit` |196| ΔS > 0 after execution | `🛑 F1 VIOLATION — ΔS positive. Rollback initiated.` |197| A-FORGE unreachable | `⚠️ A-FORGE offline. Self-executing within agent authority.` |198| OpenCode busy (max 3 concurrent) | `⏳ Queue full. /forge queued — priority = NORMAL` |199| Commit blocked (deploy guard) | `⛔ deploy guard — local HEAD ahead of origin. Push first.` |