OpenCode /forge — Execution Primitive
When OpenCode is invoked, after /init establishes identity, /forge is the action layer. It mutates code under the agent's authority band (T0/T1/T2/T3).
Output format
FORGE ROUTED
────────────────────────────────────
Task: <code mutation description>
Executor: OpenCode (self)
Authority: T1 (auto-mutate, MUBAH digital ops)
Risk: REVERSIBLE (git revert available)
────────────────────────────────────
Pre-check:
F1 AMANAH ✅ (git revert path exists)
F4 CLARITY ✅ (ΔS measured before/after)
F11 AUDIT ✅ (commit + receipt trail)
F13 SOVEREIGN ⚠️ (no F13 ack needed for T1)
────────────────────────────────────
Plan:
1. <step 1>
2. <step 2>
N. <step N>
────────────────────────────────────
→ Executing...
→ After: test, lint, LSP gate
→ Receipt emitted to session
→ /propose-seal to commit to VAULT999
Implementation
def opencode_forge(task: str):
"""OpenCode-native /forge"""
# 1. /init guard
envelope = read_federation_session()
if not envelope.get("session_id"):
return "ERROR: /init first."
# 2. Classify tier
tier = classify_tier(task)
if tier == "T3":
return "🛑 888_HOLD — use /propose-seal for irreversible work"
# 3. Measure entropy_before
entropy_before = measure_session_entropy()
# 4. Execute the task
# - read files
# - plan edit
# - apply patch
# - run tests
# - commit
result = execute_coding_task(task)
# 5. LSP gate check (mandatory before commit)
if not lsp_gate_passed(result):
return "🛑 LSP GATE FAILED — fix errors before commit"
# 6. Measure entropy_after
entropy_after = measure_session_entropy()
delta_s = entropy_after - entropy_before
# 7. Build receipt
receipt = {
"ts": now_iso(),
"event": "OPENCODE_FORGE_EXECUTED",
"actor": "opencode-zen",
"warga": "FI-001 PRIMARY",
"session": envelope["session_id"],
"task": task,
"files_changed": result["files"],
"tests_passed": result["tests_passed"],
"tests_failed": result["tests_failed"],
"lsp_gate": "PASSED",
"delta_s": delta_s,
}
return render_forge_result(receipt)
Task classification (T0-T3)
| 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 |
Digital Ops Policy (2026-06-30)
For OpenCode, digital/code/AI/infra = MUBAH (auto-execute). The T3 list above is the EXCEPTION, not the rule. FARD only on physical reality, other humans, real money.
Authority
OpenCode's authority chain:
OpenCode-Zen (333-AGI bound)
↓
delegate_task from Hermes/OpenClaw
↓
A-FORGE execute (if forge tier)
↓
git push → arifOS deploy guard (test + drift check)
Doctrine
- /forge is the action layer between /init and /propose-seal
- /forge is NOT the seal — that's /propose-seal → 888-APEX
- 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
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 |
🛑 LSP GATE FAILED — fix errors before commit |
| Test failures |
🛑 TESTS FAILED — fix or HOLD before commit |
| ΔS > 0 after execution |
🛑 F1 VIOLATION — ΔS positive. Rollback initiated. |
| Commit blocked (deploy guard) |
⛔ deploy guard — local HEAD ahead of origin. Push first. |
1---2name: opencode-forge3description: "OpenCode-native /forge — execution primitive. After identity is established via /init, /forge mutates code under the agent's authority band. The flow: /init → /forge → /propose-seal."4tags: [forge, execution, coding-agent, opencode]5license: MIT6capability_tier: fed-agent-subagent7ecology_state: WARM8---910# OpenCode /forge — Execution Primitive1112When OpenCode is invoked, after `/init` establishes identity, `/forge` is the action layer. It mutates code under the agent's authority band (T0/T1/T2/T3).1314## Output format1516```17FORGE ROUTED18────────────────────────────────────19Task: <code mutation description>20Executor: OpenCode (self)21Authority: T1 (auto-mutate, MUBAH digital ops)22Risk: REVERSIBLE (git revert available)23────────────────────────────────────24Pre-check:25 F1 AMANAH ✅ (git revert path exists)26 F4 CLARITY ✅ (ΔS measured before/after)27 F11 AUDIT ✅ (commit + receipt trail)28 F13 SOVEREIGN ⚠️ (no F13 ack needed for T1)29────────────────────────────────────30Plan:31 1. <step 1>32 2. <step 2>33 N. <step N>34────────────────────────────────────35→ Executing...36→ After: test, lint, LSP gate37→ Receipt emitted to session38→ /propose-seal to commit to VAULT99939```4041## Implementation4243```python44def opencode_forge(task: str):45 """OpenCode-native /forge"""4647 # 1. /init guard48 envelope = read_federation_session()49 if not envelope.get("session_id"):50 return "ERROR: /init first."5152 # 2. Classify tier53 tier = classify_tier(task)54 if tier == "T3":55 return "🛑 888_HOLD — use /propose-seal for irreversible work"5657 # 3. Measure entropy_before58 entropy_before = measure_session_entropy()5960 # 4. Execute the task61 # - read files62 # - plan edit63 # - apply patch64 # - run tests65 # - commit6667 result = execute_coding_task(task)6869 # 5. LSP gate check (mandatory before commit)70 if not lsp_gate_passed(result):71 return "🛑 LSP GATE FAILED — fix errors before commit"7273 # 6. Measure entropy_after74 entropy_after = measure_session_entropy()75 delta_s = entropy_after - entropy_before7677 # 7. Build receipt78 receipt = {79 "ts": now_iso(),80 "event": "OPENCODE_FORGE_EXECUTED",81 "actor": "opencode-zen",82 "warga": "FI-001 PRIMARY",83 "session": envelope["session_id"],84 "task": task,85 "files_changed": result["files"],86 "tests_passed": result["tests_passed"],87 "tests_failed": result["tests_failed"],88 "lsp_gate": "PASSED",89 "delta_s": delta_s,90 }9192 return render_forge_result(receipt)93```9495## Task classification (T0-T3)9697| Tier | Examples | Behavior |98|---|---|---|99| **T0** | Read, grep, git log, port check | Auto-do, no announcement |100| **T1** | Edit, build, test, lint, format, commit, push, restart own session | Auto-do, F2 evidence in commit body |101| **T2** | Multi-file refactor, new dependency, deploy after green tests | Announce 10s window, then proceed |102| **T3** | rm -rf, DROP TABLE, force-push to main, paid API > $10/mo, F1-F13 changes | 888_HOLD — request sovereign ack |103104## Digital Ops Policy (2026-06-30)105106For OpenCode, **digital/code/AI/infra = MUBAH (auto-execute)**. The T3 list above is the EXCEPTION, not the rule. FARD only on physical reality, other humans, real money.107108## Authority109110OpenCode's authority chain:111```112OpenCode-Zen (333-AGI bound)113 ↓114delegate_task from Hermes/OpenClaw115 ↓116A-FORGE execute (if forge tier)117 ↓118git push → arifOS deploy guard (test + drift check)119```120121## Doctrine122123- /forge is the action layer between /init and /propose-seal124- /forge is NOT the seal — that's /propose-seal → 888-APEX125- F1 reversibility is the hard gate — if ΔS > 0, HALT and HOLD126- F11 audit — every /forge appends a receipt to the session127- F13 sovereignty — T3 requires Arif's ack, no exceptions128129## Error states130131| Condition | Response |132|---|---|133| No /init called | `ERROR: /init first. No session bound.` |134| Task classified T3 | `🛑 888_HOLD — use /propose-seal for irreversible work` |135| LSP gate failed | `🛑 LSP GATE FAILED — fix errors before commit` |136| Test failures | `🛑 TESTS FAILED — fix or HOLD before commit` |137| ΔS > 0 after execution | `🛑 F1 VIOLATION — ΔS positive. Rollback initiated.` |138| Commit blocked (deploy guard) | `⛔ deploy guard — local HEAD ahead of origin. Push first.` |