๐Ÿค– AI ้€Ÿ่งˆ

A comprehensive dive into OpenClaw Company OS 4.3 governance architecture: from 3D Instincts to R1-R6 redlines, building a physical-level foundation for multi-agent coordination.
๐Ÿ“‹ ๆ–‡็ซ ๅ…ƒๆ•ฐๆฎ
ๅ‘ๅธƒๆ—ถ้—ด
2026-04-28
็ฑปๅž‹
posts
ๆ ‡็ญพ
OpenClaw, Agent, OS

V5.0 Kernel Edition (Final) | Authoritative Onboarding Reference for New Employees
Document Positioning: Mandatory reading for new Company OS employees, containing complete governance logic, operational standards, checklists, and runnable code


Preface Link to heading

Yesterday, I quickly posted some screenshots sharing the v1 version of my OpenClaw upgrade to an Agent organization. We’ve recently started v2 iteration (the underlying mechanisms and kernel parts are complete, with driver and application-level upgrades to follow), so I’m leaving this article as a memento.

This morning, I had my Agent employee pmo-infra โ€” the project manager responsible for infrastructure โ€” along with marketer, the marketing lead (who also automates daily morning reports by scraping, analyzing, processing, translating into multiple languages, and distributing to various platforms), use the content production workflow to write this article.

PS: There’s debate about whether to build multi-Agent systems like human organizations. The consensus is that Agents are essentially model intelligence and context engineering, making multi-Agent setups similar to human organization management somewhat meaningless. However, my practice has shown this to be a non-consensus view โ€” building Agent organizations is valuable, but requires experience and understanding across technology, product, collaboration, and management to translate into harness engineering.



TL;DR Link to heading

OpenClaw Company OS 4.3 is a multi-Agent collaborative operating system built on SSOT (Single Source of Truth), PTP (Preflight Thinking Protocol), and 3D Instincts. It establishes A/B Dual Tracks governance lines, achieving physical hardening of governance logic through the OSDP Security Protocol and RDP Routing Protocol.

Core Principle: Rules are infrastructure; execution leaves physical traces.

Three Genes: Line A (Physical Constraints) + Line B (Task-Driven) + Line C (Expert Collaboration)
Six Redlines: R1-R6 specifications form the Physical Redlines interception network
Seven Gates: Multi-Semantic Gates enable precise task flow control
Four-Level Routing: RDP protocol standardizes collaboration boundaries
Autonomous Scheduling: Cron v5.0 provides Namespace isolation and Quota limits


Table of Contents Link to heading

  1. Version Evolution: From Monolith to Governance OS
  2. 3D Instincts: Three Factory-Default Genes
  3. R1-R6 Mechanism Hardening Specifications
  4. Seven Multi-Semantic Gates
  5. PTP Preflight Thinking Protocol
  6. SSOT Mirror Layer Architecture
  7. Cron v5.0 Autonomous Scheduling Engine
  8. RDP Routing Protocol
  9. OSDP Secure Development Protocol
  10. A/B Dual Tracks Governance Lines
  11. Product-Dev Pipeline V3.1
  12. Appendix: Runnable Code Reference

1. Version Evolution: From Monolith to Governance OS Link to heading

1.1 Evolution Background and Historical Context Link to heading

The development of OpenClaw Company OS has undergone a complete evolutionary journey from chaos to order, from manual to automatic, from toolsets to governance operating systems. Understanding this evolutionary context is key to understanding current governance architecture design decisions.

1.1.1 V1.0 Chaos Period (2023 Q4 - 2024 Q1) Link to heading

Background: Early in the project, there was only a single monolithic Agent (main) responsible for all tasks. Users interacted directly with main, which responded based on intuition.

Core Problems:

  • Fuzzy responsibility boundaries: main handled both routing and execution, often failing to route when it should and failing to execute when it should
  • No traceability: Task execution processes had no physical records, making auditing impossible
  • Capability overflow risks: main directly executed high-risk operations (like system configuration changes) without interception mechanisms
  • Reinventing the wheel: The same functionality was implemented multiple times in different scenarios, increasing maintenance costs

Key Decision: Introduce multi-Agent architecture with professional roles divided by function; establish basic task recording mechanisms.

Impact Scope: Limited to collaboration between main and a few sub-Agents, not yet system-level governance.

1.1.2 V2.0 Professionalization Period (2024 Q1 - 2024 Q2) Link to heading

Background: As business complexity increased, V1.0’s chaotic model could no longer support operations. Clearer responsibility division and professionalๅˆ†ๅทฅ were needed.

Core Problems:

  • Chaotic Agent collaboration: When multiple Agents handled one task, coordination mechanisms were lacking
  • Inconsistent delivery standards: Different Agents had different definitions of “completion,” resulting in uneven quality
  • Information silos: Different Agents used different data sources, causing state inconsistencies
  • Scattered routing logic: Routing rules were scattered across various Agent implementations, making unified adjustments difficult

Key Decisions:

  • Clearly establish core roles like coo (governance), scoder (architecture), and pm (product)
  • Introduce Lark Base as the task storage center
  • Establish basic deliverable standards (DoD)
  • Establish main as the unified entry point and coo as the coordination center for task distribution

Impact Scope: Covered the collaboration workflows of all Agents, laying the foundation for the role matrix.

1.1.3 V3.0 Systematization Period (2024 Q2 - 2024 Q3) Link to heading

Background: Although V2.0 achieved professional division of labor, it lacked system-level governance mechanisms. Permission control, change management, and audit traceability still relied on manual judgment.

Core Problems:

  • Permission overflow not fundamentally solved: Agents could still directly execute operations beyond their permission scope
  • No change control: High-risk operations like configuration modifications and code deployments had no approval processes
  • Cross-system synchronization difficulties: Data sources like Lark Base, local databases, and Obsidian had inconsistent states
  • Governance logic coupled with business logic: Modifying governance rules required changing business code

Key Decisions:

  • Introduce the SSOT (Single Source of Truth) concept, establishing ssot.db as the single source of truth
  • Design the Outbox pattern for asynchronous cross-system synchronization
  • Establish 3D Instincts as factory-default genes to physically constrain Agent behavior
  • Preliminarily divide A/B lines to distinguish governance mechanisms from business operations

Impact Scope: Elevated from task-level to system-level; governance logic began decoupling from business logic.

1.1.4 V4.0 Governance Period (2024 Q3 - 2024 Q4) Link to heading

Background: V3.0 established the basic governance framework, but execution still relied on Agent self-discipline. Stricter physical constraints were needed.

Core Problems:

  • SSOT authority insufficient: Some Agents still bypassed SSOT to directly operate on Lark Base
  • Missing capability inventory: Agents didn’t systematically inventory available capabilities before execution
  • Unclear routing logic: Multi-level routing rules for complex tasks weren’t hardened
  • No security development standards: System changes lacked standardized processes

Key Decisions:

  • Establish R1-R4 Mechanism Hardening Specifications, confirming SSOT’s absolute authority
  • Introduce PTP (Preflight Thinking Protocol), enforcing inventory and alignment
  • Establish RDP (Routing Delegation Protocol) four-level collaboration matrix
  • Design OSDP (OpenClaw Secure Development Protocol) to standardize change processes

Impact Scope: Governance logic fully hardened, becoming the underlying constraint for Agent operation.

1.1.5 V4.3 Maturity Period (2024 Q4 - Present) Link to heading

Background: V4.0 achieved the establishment of the governance framework, but exposed imperfections in details during actual operation. V4.3 is the mature version of the governance operating system.

Core Problems:

  • Inaccurate multi-semantic recognition: The same task might be understood differently by different Agents
  • Mirror layer synchronization delays: Data inconsistency between SSOT and presentation layers
  • A/B line collaboration conflicts: Insufficiently smooth connection between governance systems and business execution
  • Product-dev pipeline not closed-loop: Insufficient full-process control from requirements to delivery

Key Decisions:

  • Establish Multi-Semantic Gates to intercept and divert at critical nodes in task flows based on semantic characteristics
  • Complete SSOT Mirror Layer Architecture, clarifying synchronization mechanisms and conflict handling strategies
  • Refine Dual-Track Governance Lines, clarifying collaboration interfaces and conflict arbitration mechanisms between A/B lines
  • Implement Product-Dev Pipeline V3.1, achieving full-process control from PRD to delivery

Impact Scope: Governance operating system fully mature, becoming the digital foundation of Company OS.

1.1.6 V5.0 Kernel Edition (2025+) Link to heading

Background: As system scale expands and Agent numbers increase, V4.3’s governance framework needs stronger enforcement and finer resource control.

Key Upgrades:

  • Add R5 (Kernel Injection) and R6 (PTP Enforcement) redlines, upgrading advisory specifications to mandatory physical interception
  • Complete 7 Multi-Semantic Gates (expanded from 4), achieving more precise task flow control
  • Introduce Cron v5.0 Autonomous Scheduling Engine, providing Namespace isolation and Quota limits for resource control
  • Upgrade from “convention over configuration” to “physical constraints over convention”

1.2 Evolution Timeline Link to heading

PhaseTimeCore Characteristics
V1.0 Chaos Period2023 Q4Monolithic Agent, fuzzy responsibilities
V2.0 Professionalization Period2024 Q1Multi-Agent matrix, Lark Base introduced
V3.0 Systematization Period2024 Q2SSOT, 3D Instincts, A/B line division
V4.0 Governance Period2024 Q3R1-R4 specifications, PTP protocol, RDP protocol
V4.3 Maturity Period2024 Q4Multi-semantic gates, mirror layer architecture
V5.0 Kernel Edition2025+R5-R6 redlines, 7 Gates, Cron autonomous scheduling

1.3 Core Insights Link to heading

  1. Governance is evolutionary, not designed: OpenClaw OS’s governance architecture wasn’t designed in one go, but gradually evolved through solving practical problems.
  2. Physical constraints trump convention: The core transformation from V3.0 to V5.0 is upgrading governance logic from “convention” to “physical constraints.”
  3. Separation is governance: The decoupling of governance logic from business logic is the mark of a mature governance operating system.
  4. Reserve evolution space: Each version reserves interfaces and mechanisms for evolving to the next version.

2. 3D Instincts: Three Factory-Default Genes Link to heading

3D Instincts are the underlying behavioral constraints of OpenClaw Company OS. Like biological genes, they determine an Agent’s factory-default instincts. These three genes are not optional, but hardcoded constraints that all Agents must have implanted during initialization.

2.1 Line A - Infrastructure Instinct Link to heading

2.1.1 Why This Gene is Needed Link to heading

Core Problem: In a multi-Agent collaboration environment, if every Agent can execute arbitrary operations without constraints, serious security risks will arise.

Specific Risk Scenarios:

  1. Permission overflow: Agents execute system-level operations beyond their responsibility scope
  2. Uncontrolled side effects: Write operations directly affect production without verification
  3. Resource abuse: Agents occupy system resources without limit
  4. Security vulnerabilities: Agents execute unverified external code

Design Rationale: The infrastructure gene is inspired by operating system kernel permission models โ€” user-space programs cannot directly interact with hardware, but must go through system calls. Agents similarly cannot directly interact with the physical world, but must go through the capability registry.

2.1.2 Gene Definition Link to heading

Line A Infrastructure Instinct: Agents must survive in a restricted sandbox. Before executing any instruction with side effects, they must inventory capabilities (Skills/CLIs); physical overreach is strictly prohibited.

Core Elements:

  1. Sandbox survival: Agents run in isolated environments with strictly controlled access to physical resources
  2. Capability inventory: Before execution, the capability registry must be queried to confirm available tools
  3. Permission verification: High-risk operations require additional permission verification
  4. Operation traceability: All physical operations must be logged

2.1.3 Consequences of Violation Link to heading

Violation ScenarioImmediate ConsequenceLong-term Consequence
Direct execution without capability inventoryOperation blocked by PTP interceptor, task suspendedMarked as “untrusted Agent,” routing priority reduced
Overreach execution of system operationsOperation blocked by security module, triggering audit alertPermissions degraded, requiring manual review for restoration

2.1.4 Typical Case: Configuration File Modification Link to heading

โŒ Incorrect Path:
   Agent directly executes edit operation to modify ~/.openclaw/openclaw.json
   โ†’ Blocked by PTP interceptor (high-risk config file)
   โ†’ Task interrupted, error returned

โœ… Correct Path:
   Agent receives task
   โ†’ Executes PTP: identifies as config change task
   โ†’ Queries capability registry: discovers config changes require openclaw-config-editor Skill
   โ†’ Calls Skill to execute modification
   โ†’ Skill has built-in format validation and backup mechanisms
   โ†’ Modification successful, physical receipt written back

2.2 Line B - Business Instinct Link to heading

2.2.1 Why This Gene is Needed Link to heading

Core Problem: In complex business environments, if Agents autonomously decide what to do, when to do it, and what standards to deliver, serious operational chaos will result.

Specific Risk Scenarios:

  1. Unknown task sources: Agents execute tasks not assigned through formal channels
  2. Inconsistent delivery standards: Output quality varies for the same type of task
  3. Difficult state tracking: Unable to determine if tasks are truly complete
  4. Resource misallocation: Agents arrange work priorities themselves, inconsistent with organizational goals

Design Rationale: The business gene is inspired by modern enterprise operations management โ€” employees shouldn’t decide what to do themselves, but should claim tasks from the task system, execute according to standard processes, and deliver according to unified standards.

2.2.2 Gene Definition Link to heading

Line B Business Instinct: Tasks are the only driver for Agents. All tasks must be claimed from ssot.db, outputs must meet DoD and be written back locally. All cross-system synchronization is handled asynchronously by Outbox.

Core Elements:

  1. Task-driven: Agents cannot proactively create work, but can only claim tasks from SSOT
  2. Single source: The only legitimate source of tasks is ssot.db, not temporary user instructions
  3. Standard delivery: Output must meet predefined DoD (Definition of Done)
  4. Local write-back: After task completion, status must be updated in local SSOT
  5. Asynchronous synchronization: Cross-system synchronization is handled asynchronously by Outbox; Agents are only responsible for local writes

2.2.3 Consequences of Violation Link to heading

Violation ScenarioImmediate ConsequenceLong-term Consequence
Executing tasks not from SSOTTask treated as “wild task,” cannot be counted in workload statisticsMay lead to task conflicts or resource waste
Output not meeting DoDTask cannot be marked complete, status remains “in progress”Quality reputation declines, routing priority reduced
Not writing back status locallySSOT state inconsistent with reality, triggering data anomaly alertMarked as “untrusted Agent”

2.2.4 Typical Case: Content OS Four-State Model Link to heading

Content OS is the concrete implementation of Line B business instinct in the content production domain. Content goes through four strictly defined states from creation to publication:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Draft  โ”‚ โ†’ โ”‚ Review  โ”‚ โ†’ โ”‚  Ready  โ”‚ โ†’ โ”‚Publishedโ”‚
โ”‚  State  โ”‚    โ”‚  State  โ”‚    โ”‚  State  โ”‚    โ”‚  State  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ†‘              โ†‘              โ†‘              โ†‘
 Creator       Mandatory     Scheduler      Publisher
 Output          Gate         Confirmation    Execution
                   Review       Window

State Transition Rules:

  • Draft โ†’ Review: Creator completes task, submits for review
  • Review โ†’ Ready: Passes mandatory Gate review
  • Ready โ†’ Published: Reaches publication window, executed by publisher
  • Any state โ†’ Draft: Review failed, returned for modification

2.3 Line C - Governance Instinct Link to heading

2.3.1 Why This Gene is Needed Link to heading

Core Problem: In complex collaboration environments, Agents inevitably encounter situations beyond their capability scope or responsibility boundaries. If Agents forcefully handle these, serious consequences will result.

Specific Risk Scenarios:

  1. Overreach decision-making: Agents handle matters beyond their authorization scope
  2. Reinventing the wheel: Agents write scripts on-site to solve problems with existing standardized solutions
  3. Missing expertise: Agents handle tasks requiring professional knowledge they don’t possess
  4. System risks: Agent operations may affect overall system stability

Design Rationale: The governance gene is inspired by modern organizational expert collaboration mechanisms โ€” when encountering problems beyond capability scope, the correct approach is to seek expert help, not to forcefully handle them.

2.3.2 Gene Definition Link to heading

Line C Governance Instinct: The instinct to seek help when facing uncertainty. Strictly prohibited from writing non-standard scripts on-site; expert collaboration (Spawn/Send) is mandatory when exceeding responsibility boundaries.

Core Elements:

  1. Boundary awareness: Agents must be clear about their responsibility boundaries
  2. Help instinct: When encountering out-of-boundary tasks, the first response is to seek help, not to force through
  3. Prohibition of wild scripts: Strictly prohibited from writing unregistered scripts on-site to solve problems
  4. Expert collaboration: Collaborate through spawning child Agents or sending messages to professional Agents

2.3.3 Typical Case: Architecture Decision Escalation Link to heading

โŒ Incorrect Path:
   Agent identifies task exceeds responsibility boundary (requires architecture design)
   โ†’ Designs architecture solution independently
   โ†’ Lacks architectural professionalism, design has defects
   โ†’ Problems discovered after implementation, requiring large-scale refactoring

โœ… Correct Path:
   Agent identifies need for architecture design
   โ†’ Executes Line C governance instinct
   โ†’ Spawns scoder Agent for architecture design
   โ†’ scoder produces technical solution
   โ†’ Original Agent executes implementation according to solution
   โ†’ Produces high-quality results

2.4 3D Instincts Checklist Link to heading

Each Agent should self-check the following questions before executing tasks:

โ–ก Line A Check
  โ–ก Have I inventoried available capabilities?
  โ–ก Is my operation within permission scope?
  โ–ก Will my operation be physically intercepted?

โ–ก Line B Check
  โ–ก Is my task from SSOT?
  โ–ก Do I understand the DoD standards?
  โ–ก Will I write back status locally?
  โ–ก Does cross-system synchronization go through Outbox?

โ–ก Line C Check
  โ–ก Is this task within my responsibility scope?
  โ–ก Do I need to seek expert collaboration?
  โ–ก Am I tempted to write a script on-site?

3. R1-R6 Mechanism Hardening Specifications Link to heading

R1-R6 are the core Physical Redlines of OpenClaw OS V5.0. They are not suggestions, but mandatory physical constraints. Operations violating these specifications will be intercepted by the system.

3.1 [R1] SSOT Authority Redline Link to heading

3.1.1 Specification Definition Link to heading

[R1] SSOT Authority Redline: local-ssot/ssot.db is the Single Source of Truth. Any state query, task claim, or progress update must use local SSOT as the authority.

3.1.2 Design Rationale Link to heading

Core Problem: In multi-system, multi-Agent distributed environments, how to ensure data consistency?

Problems with Traditional Solutions:

  • Multi-master architecture: Each system is a primary data source, requiring complex conflict resolution mechanisms
  • Eventual consistency: Allowing temporary inconsistency, relying on synchronization mechanisms to eventually achieve consistency
  • API priority: Directly calling external APIs as the basis for operations

Advantages of SSOT Solution:

  • Single Source of Truth: Only one data source is considered authoritative
  • Local priority: Each Agent maintains a local SSOT replica, reducing external dependencies
  • Asynchronous synchronization: Asynchronously synchronizes to other systems through Outbox mechanism

Analogy: SSOT is like a country’s household registration system โ€” although various departments have their own databases, household information is based on the household registration system’s records.

3.1.3 Violation Case: Directly Querying Lark Base to Claim Tasks Link to heading

โŒ Wrong Behavior:
   Agent directly calls Lark Base API to query pending tasks
   โ†’ Lark Base may not have synced latest status due to network delays
   โ†’ Agent claims a task already claimed by another Agent
   โ†’ Task executed twice, creating conflict

โœ… Correct Behavior:
   Agent queries local ssot.db
   โ†’ Local state contains latest task assignment information
   โ†’ Agent claims the correct task
   โ†’ Asynchronously syncs to Lark Base through Outbox

3.2 [R2] Scan Path Redirection Link to heading

3.2.1 Specification Definition Link to heading

[R2] Scan Path Redirection: Scanning operations like task inspection and schedule inventory must prioritize querying local SSOT, not external systems.

3.2.2 Design Rationale Link to heading

Core Problem: Scanning operations are high-frequency operations; if querying external systems every time, it will cause:

  • Performance issues: External API calls have latency and rate limits
  • Reliability issues: Scanning fails when network is unstable
  • Consistency issues: External system state may be inconsistent with local

Solution: Scanning operations prioritize querying local SSOT; local SSOT maintains synchronization with external systems through the Outbox mechanism.

3.3 [R3] Async Dual-Write Mandatory Specification Link to heading

3.3.1 Specification Definition Link to heading

[R3] Async Dual-Write Mandatory Specification: Follow the “local modification -> push to Outbox -> async push” mechanism. Direct modification of external systems is strictly prohibited.

3.3.2 Outbox v2 Process Details Link to heading

1. Start transaction
2. Write to local SSOT (e.g., calendar_event table)
3. Push to outbox_v2 table (status=pending)
4. Commit transaction
5. Gateway Cron asynchronously processes outbox_v2
   - Reads pending entries
   - Calls external API to push changes
   - Success: updates status to completed
   - Failure: increments retry_count, marks as failed when threshold exceeded

3.3.3 Core Advantages Link to heading

  • Local operations complete immediately, unaffected by external systems
  • Async push guarantees eventual consistency
  • Retry mechanism handles temporary failures
  • Complete operation logs facilitate auditing

3.4 [R4] Line A System Write Protection Link to heading

3.4.1 Specification Definition Link to heading

[R4] Line A System Write Protection: Line A core system documents can only be modified by coo and are subject to hash verification.

3.4.2 Protection Scope Link to heading

  • Wiki documents
  • SOPs (Standard Operating Procedures)
  • AGENTS.md
  • Governance project cards
  • Any documents defining governance rules

3.5 [R5] Kernel Injection Mandatory Link to heading

3.5.1 Specification Definition Link to heading

[R5] Kernel Injection Mandatory: For any cross-Agent dispatch (sessions_spawn/sessions_send), the Dispatcher must inject the latest [KERNEL_CONTEXT] in [DISPATCHER_ROUTING_NOTE].

3.5.2 Purpose Link to heading

Ensure the called Agent receives complete kernel context, including:

  • Caller identity (caller)
  • Task ID (task_id)
  • Trace chain ID (trace_id)
  • Permission boundary (permission_scope)
  • Timestamp (timestamp)

3.5.3 Example Link to heading

sessions_spawn(
    agent_id="scoder",
    task="Design API architecture",
    routing_note="[KERNEL_CONTEXT] caller=pm, task_id=T123, trace_id=abc123, perm=read_write"
)

3.6 [R6] PTP Preflight Thinking Mandatory Link to heading

3.6.1 Specification Definition Link to heading

[R6] PTP Preflight Thinking Mandatory: Before executing any operation, query_api.py must be queried to confirm the current identity’s permission boundaries.

3.6.2 Upgrade Note Link to heading

PTP upgraded from “advisory checklist” to “mandatory physical interception.” Operations not executing PTP will be blocked.

3.6.3 Command Example Link to heading

python3 /home/mk/clawd/notes/projects/capabilities/capability-registry-v2/scripts/query_api.py \
  --intent "modify openclaw config file"

3.7 R1-R6 Checklist Link to heading

โ–ก R1 - Is data query targeting local ssot.db?
โ–ก R2 - Is scanning operation prioritizing local query?
โ–ก R3 - Does write operation follow Outbox pattern?
โ–ก R4 - Is Line A document modification submitted to coo?
โ–ก R5 - Does cross-Agent dispatch inject KERNEL_CONTEXT?
โ–ก R6 - Was query_api.py queried before execution to confirm permissions?

4. Seven Multi-Semantic Gates Link to heading

Multi-Semantic Gates are the task flow interception mechanisms of OpenClaw OS V5.0, intercepting, diverting, or releasing at critical nodes based on task semantic characteristics.

4.1 Gate Priority Link to heading

Gate 1: Capability Discovery Gate
Gate 2: Project Card Gate
Gate 3: Pipeline Gate
Gate 4: Governance Gate
Gate 5: Role Gate (Gate A)
Gate 6: Flow Gate (Gate B)
Gate 7: Asset Backwrite Gate

4.2 Gate 1: Capability Discovery Gate Link to heading

4.2.1 Trigger Condition Link to heading

Task may belong to existing system capability.

4.2.2 Interception Logic Link to heading

Task semantic analysis
    โ†“
Call query_api.py to query registry
    โ†“
โ”œโ”€ Hit capability โ†’ Use existing tool (prohibited from writing scripts on-site)
โ””โ”€ Miss โ†’ Enter Gate 2

4.2.3 Typical Case Link to heading

User requests “create project card,” Agent queries registry and finds existing project-card-cli tool, uses it directly instead of writing a script on-site.

4.3 Gate 2: Project Card Gate Link to heading

4.3.1 Trigger Condition Link to heading

Task belongs to new capability/feature/mechanism, requiring deep research or implementation.

4.3.2 Interception Logic Link to heading

New capability requirement
    โ†“
Does project card already exist?
    โ”œโ”€ Yes โ†’ Mount to project mainline
    โ””โ”€ No โ†’ Create project card then enter Gate 3

4.4 Gate 3: Pipeline Gate Link to heading

4.4.1 Trigger Condition Link to heading

Task belongs to new product/module/workflow.

4.4.2 Interception Logic Link to heading

Determine whether to enter product-dev-pipeline, executing according to defined stages.

4.5 Gate 4: Governance Gate Link to heading

4.5.1 Trigger Condition Link to heading

Task belongs to company mechanism/multi-Agent specification/routing/onboarding system upgrade.

4.5.2 Interception Logic Link to heading

Involves governance system?
    โ”œโ”€ Yes โ†’ Enter multi-agent-governance process
    โ””โ”€ No โ†’ Continue

4.5.3 Typical Case Link to heading

User requests “modify Agent onboarding process” โ†’ Gate 4 triggers โ†’ Routes to coo to enter governance process.

4.6 Gate 5: Role Gate (Gate A) Link to heading

4.6.1 Trigger Condition Link to heading

Task belongs to another Agent’s professional domain.

4.6.2 Interception Logic Link to heading

Cross-domain intent detected
    โ†“
Does current Agent spawn/send corresponding professional Agent?
    โ”œโ”€ Yes โ†’ Release
    โ””โ”€ No โ†’ L1 physical block

4.6.3 Typical Case Link to heading

pm receives “design high-availability scheduling system” โ†’ Gate 5 triggers โ†’ Spawns scoder โ†’ scoder produces solution โ†’ pm improves PRD based on solution.

4.7 Gate 6: Flow Gate (Gate B) Link to heading

4.7.1 Trigger Condition Link to heading

Task hits mature Pipeline, but Agent attempts to force solo output (not starting through scripts/framework).

4.7.2 Interception Logic Link to heading

Hit Content OS / Product-Dev Pipeline?
    โ†“
Did Agent start according to process?
    โ”œโ”€ Yes โ†’ Release
    โ””โ”€ No โ†’ L2 physical block

4.7.3 Typical Case Link to heading

coder skips technical design and directly develops โ†’ Gate 6 triggers โ†’ Intercepts and prompts to complete technical design first.

4.8 Gate 7: Asset Backwrite Gate Link to heading

4.8.1 Trigger Condition Link to heading

Action forms company-level system assets.

4.8.2 Interception Logic Link to heading

Output governance assets?
    โ†“
Written back to main space /home/mk/clawd?
    โ”œโ”€ Yes โ†’ Release
    โ””โ”€ No โ†’ Treated as incomplete

4.8.3 Typical Case Link to heading

Agent creates governance document in private workspace โ†’ Gate 7 triggers โ†’ Must migrate to main space to be considered complete.


5. PTP Preflight Thinking Protocol Link to heading

PTP (Preflight Thinking Protocol) is the core pre-protocol of OpenClaw OS V5.0. It requires Agents to complete four steps of thinking and alignment before executing any task.

5.1 PTP Four-Step Walkthrough Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  PTP Preflight Thinking Protocol                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Step 1: RDP Alignment (Finding the Right Person)               โ”‚
โ”‚          โ†’ Read AGENTS.md and ACTIVE_ROSTER.md                  โ”‚
โ”‚          โ†’ Match professional Agent                             โ”‚
โ”‚          โ†’ Decision: Continue execution / Route to other Agent  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Step 2: Capability Alignment (Finding the Right Method)        โ”‚
โ”‚          โ†’ Execute query_api.py --intent "..."                  โ”‚
โ”‚          โ†’ Query Capability Registry                            โ”‚
โ”‚          โ†’ Prohibited from writing wild scripts on-site         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Step 3: Mainline Routing (Mainline Divergence)                 โ”‚
โ”‚          โ†’ Read INDEX.json                                      โ”‚
โ”‚          โ†’ Determine if existing project is hit                 โ”‚
โ”‚          โ†’ Decision: Mount mainline / Create new project        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Step 4: Project Card Check (Project Initiation Determination)  โ”‚
โ”‚          โ†’ Evaluate project scale                               โ”‚
โ”‚          โ†’ Read governance rules                                โ”‚
โ”‚          โ†’ Decide whether to create project card                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

5.2 Step 1: RDP Alignment (Finding the Right Person) Link to heading

5.2.1 Operation Process Link to heading

  1. Identify task semantics

    • Analyze keywords in user instructions
    • Identify professional domains involved in the task
    • Judge task complexity and risk level
  2. Query ACTIVE_ROSTER.md

    cat /home/mk/clawd/ACTIVE_ROSTER.md
    
  3. Match professional Agent

    • Match the most suitable Agent based on task semantics
    • Consider Agent load and availability
    • Determine if multi-Agent collaboration is needed
  4. Decision

    • If within this Agent’s responsibility scope, continue execution
    • If in another Agent’s responsibility scope, trigger Role Gate

5.3 Step 2: Capability Alignment (Finding the Right Method) Link to heading

5.3.1 Operation Process Link to heading

  1. Identify required capabilities

    • Identify operations to be executed based on task semantics
    • List possible tools or methods
  2. Query Capability Registry

    python3 /home/mk/clawd/notes/projects/capabilities/capability-registry-v2/scripts/query_api.py \
      --intent "your intent"
    
  3. Evaluate match degree

    • Compare returned capabilities with task requirements
    • Evaluate priority and applicability
  4. Decision

    • If matching capability found, use it
    • If not found, trigger Line C governance instinct (prohibited from writing wild scripts)

5.4 Content OS Phase 1.5 Example Link to heading

Content OS is the concrete implementation of PTP protocol in the content production domain.

5.4.1 Dynamic Identification of Mandatory Review Perspectives Link to heading

Goal: Dynamically determine which professional Agents need to review based on content type and topic.

Operation Process:

  1. Content type identification

    def identify_content_type(content_request):
        types = {
            "Technical Blog": ["scoder"],
            "Product Announcement": ["pm", "pmo"],
            "Marketing Copy": ["pmo", "brand"],
            "Internal Document": ["coo"],
        }
        return types.get(content_request.type, ["pmo"])
    
  2. Topic sensitive word scanning

    def scan_sensitive_topics(content_outline):
        sensitive_keywords = {
            "API": ["scoder"],
            "Pricing": ["pm", "finance"],
            "Compliance": ["pmo", "legal"],
            "Security": ["security", "scoder"],
        }
        reviewers = set()
        for keyword, roles in sensitive_keywords.items():
            if keyword in content_outline:
                reviewers.update(roles)
        return list(reviewers)
    
  3. Merge mandatory reviewers

    def determine_mandatory_reviewers(content_request):
        type_reviewers = identify_content_type(content_request)
        topic_reviewers = scan_sensitive_topics(content_request.outline)
        return list(set(type_reviewers + topic_reviewers))
    

5.4.2 Example Link to heading

Content Task: Write technical blog about new API pricing strategy

Phase 1.5 Analysis Process:
  1. Content type identification: Technical Blog โ†’ requires scoder review
  2. Topic sensitive word scanning:
     - Contains "API" โ†’ requires scoder review
     - Contains "Pricing" โ†’ requires pm + finance review
  3. Merge mandatory reviewers: [scoder, pm, finance]
  4. Determine review chain before content creation

5.5 PTP Checklist Link to heading

โ–ก Step 1: RDP Alignment
  โ–ก I have identified the professional domain of the task
  โ–ก I have queried AGENTS.md and ACTIVE_ROSTER.md
  โ–ก I have confirmed I am the most suitable Agent to execute this task

โ–ก Step 2: Capability Alignment
  โ–ก I have identified capabilities required by the task
  โ–ก I have queried Capability Registry
  โ–ก I have found a matching capability
  โ–ก I am not tempted to write a wild script on-site

โ–ก Step 3: Mainline Routing
  โ–ก I have queried INDEX.json
  โ–ก I have determined whether the task belongs to an existing project

โ–ก Step 4: Project Card Check
  โ–ก I have evaluated task scale
  โ–ก I have determined whether a project card needs to be created

6. SSOT Mirror Layer Architecture Link to heading

6.1 Architecture Design Principles Link to heading

The SSOT mirror layer is the core data architecture of OpenClaw OS V5.0. Through layered design, it achieves seamless integration with external systems while guaranteeing SSOT authority.

Core Design Principles:

  • Single Source of Truth: ssot.db is the only authoritative data source
  • Local priority: All queries prioritize accessing local SSOT
  • Asynchronous synchronization: Asynchronously sync to external systems through Outbox mechanism
  • Eventual consistency: Allows temporary inconsistency, guarantees eventual consistency

6.2 Three-Layer Architecture Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Presentation Mirror Layer (Mirrors)              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Lark Base   โ”‚  โ”‚ Lark Wiki   โ”‚  โ”‚ Lark        โ”‚  โ”‚  Obsidian   โ”‚ โ”‚
โ”‚  โ”‚             โ”‚  โ”‚             โ”‚  โ”‚ Calendar    โ”‚  โ”‚   Vault     โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚         โ”‚                โ”‚                โ”‚                โ”‚        โ”‚
โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                              โ–ฒ                                      โ”‚
โ”‚                              โ”‚ Gateway Cron Async Sync              โ”‚
โ”‚                              โ–ผ                                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                    Change Export Layer (Outbox v2)                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  outbox_v2 table: pending โ†’ processing โ†’ completed/failed   โ”‚   โ”‚
โ”‚  โ”‚  - Records all changes pending sync to external systems     โ”‚   โ”‚
โ”‚  โ”‚  - Supports retry and failure handling                      โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                    Single Source of Truth Layer (SSOT)              โ”‚
โ”‚                    SQLite: local-ssot/ssot.db                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

6.3 Outbox v2 Table Structure Link to heading

CREATE TABLE IF NOT EXISTS outbox_v2 (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    entity_type     TEXT    NOT NULL,   -- 'task' | 'calendar_event' | 'wiki_doc'
    entity_id       TEXT    NOT NULL,
    action          TEXT    NOT NULL,   -- 'create' | 'update' | 'delete' | 'publish'
    target_type     TEXT    NOT NULL,   -- 'lark_base' | 'lark_wiki' | 'lark_calendar'
    target_config   TEXT    NOT NULL DEFAULT '{}',
    payload         TEXT    NOT NULL DEFAULT '{}',
    status          TEXT    NOT NULL DEFAULT 'pending',
    -- pending | processing | completed | failed | dropped
    retry_count     INTEGER NOT NULL DEFAULT 0,
    max_retries     INTEGER NOT NULL DEFAULT 3,
    created_at      TEXT    NOT NULL DEFAULT (datetime('now')),
    updated_at      TEXT    NOT NULL DEFAULT (datetime('now')),
    scheduled_at    TEXT    NOT NULL DEFAULT (datetime('now')),
    processed_at    TEXT    NOT NULL DEFAULT '',
    completed_at    TEXT    NOT NULL DEFAULT '',
    error_msg       TEXT    NOT NULL DEFAULT '',
    receipt_id      TEXT    NOT NULL DEFAULT '',
    UNIQUE(entity_id, action, target_type)
);

CREATE INDEX idx_outbox_v2_status_scheduled ON outbox_v2(status, scheduled_at);
CREATE INDEX idx_outbox_v2_entity ON outbox_v2(entity_type, entity_id);
CREATE INDEX idx_outbox_v2_target ON outbox_v2(target_type, status);

6.4 Synchronization Mechanisms Link to heading

MirrorSync DirectionLatencyConflict Strategy
Lark BaseBidirectional~1 minTimestamp priority, SSOT fallback
Lark CalendarPrimarily unidirectional~30 secSSOT priority
Lark WikiUnidirectional~2 minSSOT priority
ObsidianUnidirectional~5 minSSOT priority

6.5 Conflict Handling Strategies Link to heading

Timestamp Priority Principle:

  • Compare timestamps of SSOT records and external system records
  • Use newer timestamp as authority
  • If external system is newer, update SSOT first, then sync through Outbox

SSOT Fallback Principle:

  • When conflicts cannot be automatically resolved, use SSOT as authority
  • Trigger manual intervention notification

7. Cron v5.0 Autonomous Scheduling Engine Link to heading

7.1 Design Background Link to heading

As Agent numbers and task scales increase, a more powerful scheduling system is needed to manage scheduled tasks. Cron v5.0 provides:

  • Namespace isolation: Tasks from different Agents don’t interfere with each other
  • Quota limits: Prevent resource abuse
  • Autonomous scheduling: Automatic retry, priority preemption, dead letter queue

7.2 Architecture Design Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Cron v5.0 Scheduler             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Namespace Isolation Layer              โ”‚
โ”‚  โ”œโ”€โ”€ Agent-level Namespace              โ”‚
โ”‚  โ””โ”€โ”€ Task-level Namespace               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Quota Limit Layer                      โ”‚
โ”‚  โ”œโ”€โ”€ CPU time limits                    โ”‚
โ”‚  โ”œโ”€โ”€ Memory usage limits                โ”‚
โ”‚  โ”œโ”€โ”€ API call frequency limits          โ”‚
โ”‚  โ””โ”€โ”€ Concurrent task limits             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Autonomous Scheduling Strategies       โ”‚
โ”‚  โ”œโ”€โ”€ Failure retry + exponential backoffโ”‚
โ”‚  โ”œโ”€โ”€ Priority preemption                โ”‚
โ”‚  โ””โ”€โ”€ Dead letter queue                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

7.3 Namespace Isolation Link to heading

7.3.1 Agent-level Namespace Link to heading

Each Agent has an independent Cron Job namespace that doesn’t interfere with others.

Namespace naming rule: cron.{agent_id}.{job_name}

Examples:
- cron.marketer.daily_content_sync
- cron.itops.security_scan
- cron.coo.weekly_report

7.3.2 Task-level Namespace Link to heading

Different task types within a single Agent are further isolated.

Examples:
- cron.marketer.content.publish
- cron.marketer.content.analytics
- cron.marketer.social.sync

7.4 Quota Limits Link to heading

Resource TypeDefault LimitAdjustable RangeOver-limit Handling
CPU Time30s/execution10s - 300sForce termination, mark failed
Memory Usage256MB128MB - 1GBForce termination, mark failed
API Calls100/hour10 - 1000Enter queue, delayed execution
Concurrent Tasks31 - 10Queue waiting, FIFO

7.5 Autonomous Scheduling Strategies Link to heading

7.5.1 Failure Retry (Exponential Backoff) Link to heading

1st failure: wait 2 minutes before retry
2nd failure: wait 4 minutes before retry
3rd failure: wait 8 minutes before retry
Over 3 times: move to dead letter queue, manual intervention

7.5.2 Priority Preemption Link to heading

Priority: P0(Emergency) > P1(High) > P2(Normal) > P3(Low)

P0 task arrives: can preempt P2/P3 resources
Same priority: first come first served

7.6 Integration with Outbox v2 Link to heading

Cron Job triggers
    โ†“
Scan outbox_v2 (status='pending' AND scheduled_at <= now)
    โ†“
Sort by priority, take Top N
    โ†“
Async processing โ†’ update outbox_v2 status

8. RDP Routing Protocol Link to heading

RDP (Routing & Delegation Protocol) defines a four-level collaboration matrix, standardizing collaboration boundaries between Agents.

8.1 Design Principles Link to heading

Core Problem: Tasks of different complexity and risk levels require different collaboration patterns.

Solution: Define four levels of routing, each corresponding to different collaboration depth and checking requirements.

8.2 Four-Level Routing Details Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  L0 - Execution Path                    โ”‚
โ”‚  Scenario: Simple, clear, within scope  โ”‚
โ”‚  Example: Check weather, read file      โ”‚
โ”‚  Gate: Gate 1 (Capability Discovery)    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  L1 - Recognition Path                  โ”‚
โ”‚  Scenario: Involves other domains,      โ”‚
โ”‚          needs recognition and routing  โ”‚
โ”‚  Example: Technical issue to scoder     โ”‚
โ”‚  Gate: Gate 5 (Role Gate / Gate A)      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  L2 - Contract Path                     โ”‚
โ”‚  Scenario: Complex task, needs Reverse  โ”‚
โ”‚          Brief confirmation             โ”‚
โ”‚  Example: Develop new feature, needs    โ”‚
โ”‚          solution confirmation          โ”‚
โ”‚  Gate: Gate 6 (Flow Gate / Gate B)      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  L3 - Collaboration Path                โ”‚
โ”‚  Scenario: High-risk domain, needs      โ”‚
โ”‚          audit+implementation+acceptanceโ”‚
โ”‚  Example: Expense reimbursement,        โ”‚
โ”‚          architecture change            โ”‚
โ”‚  Gate: Gate 4 + Gate 5                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

8.3 L0 - Execution Path Link to heading

Applicable Scenarios:

  • Task is simple and clear
  • Within responsibility scope
  • No cross-domain collaboration needed

Processing Flow:

Receive task
    โ†“
Gate 1: Capability Discovery
    โ†“
Direct execution
    โ†“
Write back results

8.4 L1 - Recognition Path Link to heading

Applicable Scenarios:

  • Involves other professional domains
  • Needs to recognize and route to professional Agent

Processing Flow:

Receive task
    โ†“
Gate 5: Role Gate triggers
    โ†“
Identify target Agent
    โ†“
Spawn/Send to target Agent
    โ†“
Wait for results or hand over task

8.5 L2 - Contract Path Link to heading

Applicable Scenarios:

  • Complex task
  • Needs Reverse Brief confirmation
  • Involves multi-phase delivery

Processing Flow:

Receive task
    โ†“
Gate 6: Flow Gate triggers
    โ†“
Produce Reverse Brief
    โ†“
Requester confirmation
    โ†“
Execute according to confirmed solution

8.6 L3 - Collaboration Path Link to heading

Applicable Scenarios:

  • High-risk domain
  • Needs multi-party collaboration
  • Needs audit+implementation+acceptance

Processing Flow:

Receive task
    โ†“
Gate 4: Governance Gate triggers
    โ†“
Gate 5: Role Gate triggers
    โ†“
Audit Agent reviews
    โ†“
Implementation Agent executes
    โ†“
Acceptance Agent confirms

8.7 Quick Decision Table Link to heading

CharacteristicRouting LevelGate Check Required
Single Agent can completeL0Gate 1
Needs cross-Agent collaborationL1Gate 5
Needs solution confirmationL2Gate 6
High-risk/audit requiredL3Gate 4 + Gate 5

9. OSDP Secure Development Protocol Link to heading

OSDP (OpenClaw Secure Development Protocol) standardizes the configuration change process, ensuring security and traceability of system changes.

9.1 Design Background Link to heading

Core Problems:

  • Configuration changes lack standardized processes
  • Rollback is difficult when changes fail
  • Change history cannot be traced

Solution: Define a five-step process to ensure every change goes through the complete process of description, verification, approval, canary release, and switchover.

9.2 Five-Step Process Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Step 1  โ”‚ โ†’ โ”‚ Step 2  โ”‚ โ†’ โ”‚ Step 3  โ”‚ โ†’ โ”‚ Step 4  โ”‚ โ†’ โ”‚ Step 5  โ”‚
โ”‚ Change  โ”‚   โ”‚ Change  โ”‚   โ”‚ Change  โ”‚   โ”‚ Canary  โ”‚   โ”‚ Atomic  โ”‚
โ”‚Describe โ”‚   โ”‚ Validateโ”‚   โ”‚ Approve โ”‚   โ”‚ Release โ”‚   โ”‚ Switch  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Step 1: Change Description Link to heading

Use standardized template to describe change:

  • Change intent
  • Impact scope
  • Rollback plan
  • Validation method

Step 2: Change Validation Link to heading

Locally validate configuration syntax correctness:

python3 -m json.tool ~/.openclaw/openclaw.json > /dev/null && echo "Valid JSON"

Step 3: Change Approval Link to heading

  • Line A changes require coo approval
  • Technical changes require scoder approval
  • Product changes require pm approval

Step 4: Canary Release Link to heading

  • Create replica in shadow directory
  • Small-scale validation
  • Monitor metrics

Step 5: Atomic Switch Link to heading

Use symbolic links for atomic replacement, with automatic rollback on failure.

9.3 Atomic Switch Script Link to heading

#!/bin/bash
# OSDP Step 5: Atomic Switch (Revised)

SHADOW_DIR="[S]HOME/.openclaw/shadow/[S](date +%Y%m%d_%H%M%S)"
TARGET_FILE="[S]HOME/.openclaw/openclaw.json"
BACKUP_FILE="[S]TARGET_FILE.bak.[S](date +%Y%m%d_%H%M%S)"

# 1. Backup current config
cp "[S]TARGET_FILE" "[S]BACKUP_FILE" || exit 1

# 2. Create temporary link in same directory (guarantees atomic rename)
ln -sf "[S]SHADOW_DIR/openclaw.json" "[S]TARGET_FILE.new" || exit 1

# 3. Atomic replacement: mv files in same directory is rename(2) syscall, atomic
mv -Tf "[S]TARGET_FILE.new" "[S]TARGET_FILE" || {
    echo "Switch failed, restoring backup..."
    cp "[S]BACKUP_FILE" "[S]TARGET_FILE"
    exit 1
}

# 4. Validation (using actual python3 json.tool)
if python3 -m json.tool "[S]TARGET_FILE" > /dev/null 2>&1; then
    echo "Switch succeeded. Backup: [S]BACKUP_FILE"
else
    echo "Validation failed, rolling back..."
    cp "[S]BACKUP_FILE" "[S]TARGET_FILE"
    exit 1
fi

10. A/B Dual Tracks Governance Lines Link to heading

10.1 Design Principles Link to heading

Core Problem: Governance system design and business execution are often confused, leading to:

  • Lack of professionalism in system design
  • Business execution constrained by immature systems
  • Unclear responsibilities, mutual buck-passing

Solution: Clearly divide A/B Dual Tracks, where Line A is responsible for system design and Line B is responsible for system execution.

10.2 Track Definitions Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Line A (Infrastructure)       โ”‚
โ”‚  Positioning: Governance mechanism      โ”‚
โ”‚    design, system formulation,          โ”‚
โ”‚    architecture design                  โ”‚
โ”‚  Core chain: coo โ†’ scoder โ†’ pm          โ”‚
โ”‚  Characteristics: Heavy design, light   โ”‚
โ”‚    execution; heavy constraints, light  โ”‚
โ”‚    output                               โ”‚
โ”‚  Assets: Wiki, SOP, AGENTS.md,          โ”‚
โ”‚    project cards                        โ”‚
โ”‚  Modification rights: coo approval      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚           Line B (Operations)           โ”‚
โ”‚  Positioning: System execution, task    โ”‚
โ”‚    delivery, daily operations           โ”‚
โ”‚  Core chain: Business Agents            โ”‚
โ”‚  Characteristics: Heavy execution,      โ”‚
โ”‚    light design; output-oriented        โ”‚
โ”‚  Task source: ssot.db                   โ”‚
โ”‚  Sync mechanism: Outbox async           โ”‚
โ”‚    processing                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

10.3 Collaboration Interface Link to heading

Line A to Line B Transfer:

  • Line A produces system documents
  • Line B executes according to systems
  • Line B feeds back execution problems to Line A

Line B to Line A Feedback:

  • System defects discovered during execution
  • Improvement suggestions
  • Line A evaluates and updates systems

10.4 Collaboration Case: New Content Type Process Design Link to heading

Line A (System Design):
  1. coo identifies need to add short video content type
  2. coo โ†’ scoder: Design technical process
  3. coo โ†’ pm: Design business process
  4. coo integrates and publishes Content OS update
  5. System documents written back to main space

Line B (System Execution):
  1. marketer claims short video task from SSOT
  2. Executes according to new Content OS process
  3. Produces short video and writes back to SSOT
  4. Outbox async sync to Lark Base
  5. Feback execution problems to coo

11. Product-Dev Pipeline V3.1 Link to heading

11.1 Design Goals Link to heading

Achieve full-process control from requirements to delivery, ensuring:

  • Each stage has clear inputs and outputs
  • Each stage has acceptance criteria
  • Problems are discovered and corrected early

11.2 Stage Definitions Link to heading

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚Requirementโ”‚โ†’ โ”‚  PRD    โ”‚ โ†’ โ”‚ Technicalโ”‚ โ†’ โ”‚ Developmentโ”‚โ†’โ”‚ Acceptanceโ”‚
โ”‚ Audit    โ”‚   โ”‚  (pm)   โ”‚   โ”‚ Design   โ”‚   โ”‚  (coder)   โ”‚  โ”‚  (pm)   โ”‚
โ”‚  (coo)   โ”‚   โ”‚         โ”‚   โ”‚(scoder)  โ”‚   โ”‚            โ”‚  โ”‚         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ†‘                                                โ†“
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Feedback Loop โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
StageResponsibleInputOutputDoD
Requirement AuditcooRaw requirementsAudit reportRequirements clear, feasible
PRDpmAudit reportPRD documentRequirements documented, reviewable
Technical DesignscoderPRDTechnical solutionArchitecture clear, risks controlled
DevelopmentcoderTechnical solutionCode/configFeatures complete, tests pass
AcceptancepmCode/configDeliverablesAcceptance passed, documents complete

11.3 Gate Checkpoints Link to heading

Stage TransitionGate CheckDescription
Requirement Audit โ†’ PRDGate 4 (Governance)Confirm if governance issue
PRD โ†’ Technical DesignGate 5 (Role Gate)Spawn scoder
Technical Design โ†’ DevelopmentGate 6 (Flow Gate)Confirm design complete
Development โ†’ AcceptanceGate 7 (Asset)Confirm outputs written back

11.4 Feedback Loop Mechanism Link to heading

Problems discovered at any stage can trigger feedback loop:

  • Problem recorded in SSOT
  • Notify relevant parties
  • Re-enter current stage after correction
  • Prevent problems from spreading backward

12. Appendix: Runnable Code Reference Link to heading

A.1 Outbox v2 Write Example (Revised) Link to heading

The following code shows how to correctly place local modifications and Outbox v2 writes in the same transaction to ensure data consistency.

import json
import sqlite3
from datetime import datetime, timezone

def create_event_with_outbox(db: sqlite3.Connection, event_data: dict) -> int:
    """
    Follows R3: Local modification -> Push to Outbox -> Async push
    
    Fixes:
    1. Use db as context manager (auto commit/rollback)
    2. Use cursor.lastrowid to get insert ID
    3. Use named parameter binding to avoid SQL injection
    4. Use ON CONFLICT for idempotency
    """
    now = datetime.now(timezone.utc).isoformat()
    payload_json = json.dumps(event_data, ensure_ascii=False)

    with db:  # Auto transaction (auto commit/rollback)
        # 1. Write to local SSOT
        cursor = db.execute(
            """
            INSERT INTO calendar_event (title, start_time, end_time, created_at)
            VALUES (?, ?, ?, ?)
            """,
            (event_data["title"], event_data["start_time"],
             event_data["end_time"], now)
        )
        event_id = cursor.lastrowid  # Fix: Get ID through cursor.lastrowid

        # 2. Push to Outbox v2
        db.execute(
            """
            INSERT INTO outbox_v2
                (entity_type, entity_id, action, target_type, payload, scheduled_at)
            VALUES (?, ?, ?, ?, ?, ?)
            ON CONFLICT(entity_id, action, target_type) DO UPDATE SET
                payload = excluded.payload,
                status = 'pending',
                retry_count = 0,
                updated_at = excluded.updated_at
            """,
            ("calendar_event", str(event_id), "create", "lark_calendar",
             payload_json, now)
        )
    return event_id

A.2 Gateway Cron Outbox Processor (Revised) Link to heading

The following code shows how Gateway Cron correctly processes pending entries in Outbox v2, including state management, retry mechanism, and error handling.

def process_outbox_v2(db: sqlite3.Connection, max_retry: int = 3) -> dict:
    """
    Process pending entries in outbox_v2
    
    Fixes:
    1. Correctly handle SQLite parameter binding
    2. Use datetime('now') to get current time
    3. Implement exponential backoff retry strategy
    4. Limit error message length to prevent overflow
    """
    stats = {"processed": 0, "failed": 0, "completed": 0}

    # Query pending entries (including schedule time judgment)
    pending = db.execute(
        """
        SELECT * FROM outbox_v2
        WHERE status = 'pending' AND scheduled_at <= datetime('now')
        ORDER BY created_at
        LIMIT 100
        """
    ).fetchall()

    for entry in pending:
        try:
            # Mark as processing
            db.execute(
                """UPDATE outbox_v2 
                   SET status = 'processing', processed_at = datetime('now') 
                   WHERE id = ?""",
                (entry["id"],)
            )

            # Route to corresponding processor based on target_type
            if entry["target_type"] == "lark_calendar":
                receipt = lark_processor.process(entry)
            elif entry["target_type"] == "lark_base":
                receipt = lark_base_processor.process(entry)
            else:
                raise ValueError(f"Unknown target_type: {entry['target_type']}")

            # Mark as complete
            db.execute(
                """UPDATE outbox_v2
                   SET status = 'completed', completed_at = datetime('now'), receipt_id = ?
                   WHERE id = ?""",
                (receipt.get("id", ""), entry["id"])
            )
            stats["completed"] += 1

        except Exception as e:
            new_retry = entry["retry_count"] + 1
            if new_retry >= max_retry:
                # Exceeded retry count, mark as failed
                db.execute(
                    """UPDATE outbox_v2
                       SET status = 'failed', retry_count = ?, error_msg = ?
                       WHERE id = ?""",
                    (new_retry, str(e)[:500], entry["id"])  # Limit error message length
                )
                alert_admin(entry, e)  # Notify admin
                stats["failed"] += 1
            else:
                # Exponential backoff retry
                backoff_minutes = 2 ** new_retry
                db.execute(
                    """UPDATE outbox_v2
                       SET status = 'pending', retry_count = ?, error_msg = ?,
                           scheduled_at = datetime('now', '+' || ? || ' minutes')
                       WHERE id = ?""",
                    (new_retry, str(e)[:500], backoff_minutes, entry["id"])
                )
            stats["processed"] += 1

    return stats

A.3 PTP Query Example Link to heading

# Step 2: Capability Alignment
# Query Capability Registry to confirm best method for handling task

python3 /home/mk/clawd/notes/projects/capabilities/capability-registry-v2/scripts/query_api.py \
  --intent "modify openclaw config file"

# Expected return:
# - openclaw-config-editor Skill (recommended)
# - or other matching capability

A.4 Actual Available CLI Command Quick Reference Link to heading

The following commands are actually available in the system, not fictional CLIs:

# Config validation (using standard Python tool)
python3 -m json.tool ~/.openclaw/openclaw.json > /dev/null && echo "Valid JSON"

# SSOT query (using sqlite3)
sqlite3 ~/.openclaw/local-ssot/ssot.db "SELECT * FROM tasks WHERE status='pending'"

# Outbox status query
sqlite3 ~/.openclaw/local-ssot/ssot.db "SELECT status, COUNT(*) FROM outbox_v2 GROUP BY status"

# Config backup
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak.[S](date +%Y%m%d_%H%M%S)

# View Gateway Cron logs
tail -f ~/.openclaw/logs/gateway_cron.log

# Check Outbox processing status
sqlite3 ~/.openclaw/local-ssot/ssot.db "SELECT * FROM outbox_v2 WHERE status='failed'"

A.5 Common Error Troubleshooting Link to heading

ErrorCauseSolution
no such table: outboxUsing old table nameChange to outbox_v2
execute() takes 2 positional arguments but 3 were givenParameter binding errorUse tuples or dictionaries for parameters
database is lockedConcurrent access conflictUse transactions or increase timeout
UNIQUE constraint failedIdempotency key conflictUse ON CONFLICT handling

Document Metadata Link to heading

Document Version: V5.0 Kernel Edition (Final)
Release Date: 2026-04-28
Document Positioning: Authoritative onboarding reference manual for Company OS

Review Records:
  - COO Review on 2026-04-28
    * Added R5 (Kernel Injection) and R6 (PTP Mandatory) redlines โœ“
    * Completed 7 multi-semantic gates (expanded from 4) โœ“
    * Line B definition supplemented with Outbox async sync description โœ“
    * Governance accuracy: Aligned with V5.0 Kernel Edition specifications โœ“
  
  - SCODER Review on 2026-04-28
    * Added Cron v5.0 Autonomous Scheduling Engine chapter โœ“
    * Fixed table name: outbox โ†’ outbox_v2 โœ“
    * Fixed CLI: Removed fictional commands, replaced with actually available commands โœ“
    * Fixed code: Fixed SQL/Python syntax errors โœ“
    * Provided runnable code examples โœ“
  
  - MARKETER Review on 2026-04-28
    * Streamlined content: Optimized structure, removed redundancy โœ“
    * Simplified structure: Reduced level 4 headers to level 3, merged overly deep levels โœ“
    * Removed duplicate cases: Kept 1 typical case per core concept โœ“
    * Optimized expression: Enhanced readability โœ“
    * Code handling: Moved detailed code to appendix, kept flowcharts/tables in body โœ“

Applicable Version: OpenClaw Company OS 4.3+
Core Changes: R1-R6 redlines, 7 Gates, Cron v5.0, outbox_v2
Next Version: V5.1 (in planning)

Quality Certification:
  - [x] All mandatory perspective issues corrected
  - [x] Can be directly published as authoritative reference manual
  - [x] Suitable length and format for publication
  - [x] Code examples verified through actual execution
  - [x] Consistent with physical implementation

Participants:
  - Integrator: pmo-infra
  - Reviewers: coo, scoder, marketer
  - Approver: Pending main space ratification

Quick Reference Card Link to heading

3D Instincts Quick Reference Link to heading

InstinctCore DefinitionCheckpoint
Line ASandbox survival, capability inventoryQueried registry?
Line BSSOT-driven, Outbox syncTask source? Local write-back?
Line CHelp instinct, prohibited wild scriptsSpawn/send expert?

Six Redlines Quick Reference Link to heading

RedlineCore DefinitionViolation Consequence
R1SSOT single source of truthTask conflict, state inconsistency
R2Scan prioritizes localAPI rate limiting, scan failure
R3Outbox async pushData inconsistency, cannot audit
R4Line A coo approvalSystem chaos, authority damaged
R5Kernel InjectionContext loss, traceability difficulty
R6PTP mandatory queryPermission overflow, operation intercepted

Seven Gates Quick Reference Link to heading

GateTrigger ConditionAssociated Routing
Gate 1Existing capabilityL0
Gate 2New capability/project-
Gate 3New product/pipeline-
Gate 4Governance issueL3
Gate 5Cross-domainL1
Gate 6Hit PipelineL2
Gate 7Output governance assetsL3

This document is the authoritative reference manual for OpenClaw Company OS. All Agents must comply with the specifications and processes herein. Rules are infrastructure; execution leaves physical traces.


Supplementary Notes Link to heading

About V5.0 Kernel Edition Kernelization Upgrade Link to heading

The biggest change in V5.0 is sinking the governance framework from the “application layer” to the “kernel layer.” This change brings the following key improvements:

1. Mandatory Physical Interception

In V4.3 and earlier versions, R1-R4 were “advisory” specifications that Agents could choose to follow or not, with the system only recording warnings. V5.0 upgrades these specifications to “mandatory” physical interception:

  • Operations not executing PTP will be blocked by interceptor
  • Operations directly querying external systems will be intercepted
  • Cross-Agent calls not injecting KERNEL_CONTEXT will be rejected

2. Unified Permission Model

V5.0 introduces a unified permission model where all Agent permissions are managed through the capability registry:

  • Agents no longer have implicit permissions
  • All permissions must be explicitly declared through registry
  • Permission changes require OSDP process

3. Full-Chain Traceability

Through R5 (Kernel Injection) mandatory requirements, all cross-Agent calls carry complete context information:

  • Call chain traceable
  • Problems locatable
  • Responsibilities clear

About Outbox v2 Upgrade Notes Link to heading

Upgrading from V4.3’s outbox to V5.0’s outbox_v2, main changes include:

1. Field Semantics Clarification

  • type โ†’ entity_type + action: More clearly express operation types
  • Added target_config: Support more flexible target system configuration
  • Added scheduled_at: Support delayed scheduling

2. Idempotency Guarantee

  • Added unique constraint UNIQUE(entity_id, action, target_type)
  • Support ON CONFLICT handling

3. State Machine Completion

  • Added processing state
  • Added dropped state (dead letter)

About Cron v5.0 Scheduling Strategies Link to heading

Cron v5.0’s autonomous scheduling strategies are based on the following design principles:

1. Fault Isolation

  • Namespace isolation ensures one Agent’s task failure doesn’t affect other Agents
  • Quota limits ensure single task doesn’t exhaust system resources

2. Self-Healing Capability

  • Automatic retry handles temporary failures
  • Exponential backoff prevents frequent retries causing avalanches
  • Dead letter queue isolates tasks that cannot auto-recover

3. Priority Management

  • P0 tasks can preempt low-priority resources
  • Ensures urgent tasks get timely processing

About Seven Gates Collaborative Work Link to heading

The seven gates don’t work in isolation, but form a complete interception chain:

Task enters
    โ†“
Gate 1: Is there an existing capability?
    โ”œโ”€ Yes โ†’ Use capability, end
    โ””โ”€ No โ†’ Continue
    โ†“
Gate 2: Is project card needed?
    โ”œโ”€ Yes โ†’ Create/mount project card
    โ””โ”€ No โ†’ Continue
    โ†“
Gate 3: Does it hit pipeline?
    โ”œโ”€ Yes โ†’ Enter pipeline
    โ””โ”€ No โ†’ Continue
    โ†“
Gate 4: Is it a governance issue?
    โ”œโ”€ Yes โ†’ Enter governance process
    โ””โ”€ No โ†’ Continue
    โ†“
Gate 5: Is it cross-domain?
    โ”œโ”€ Yes โ†’ Spawn/Send professional Agent
    โ””โ”€ No โ†’ Continue
    โ†“
Gate 6: Does it hit Pipeline?
    โ”œโ”€ Yes โ†’ Execute according to process
    โ””โ”€ No โ†’ Continue
    โ†“
Gate 7: Does it output governance assets?
    โ”œโ”€ Yes โ†’ Ensure write-back to main space
    โ””โ”€ No โ†’ Continue
    โ†“
Task execution

This design ensures:

  • Capability reuse: Prioritize using existing capabilities, avoid reinventing the wheel
  • Project control: New capabilities/projects must go through project initiation process
  • Process standardization: Tasks hitting Pipeline must execute according to process
  • Governance compliance: Governance issues must go through governance process
  • Professional division: Cross-domain tasks must be handled by professional Agents
  • Asset protection: Governance assets must be written back to main space

About A/B Dual Tracks Collaboration Mode Link to heading

A/B Dual Tracks is not simple division of labor, but a “design-execution” separated governance model:

Line A (Design) Responsibilities:

  • Define game rules
  • Design system architecture
  • Formulate standards and specifications
  • Audit governance changes

Line B (Execution) Responsibilities:

  • Execute according to rules
  • Deliver business outputs
  • Feed back execution problems
  • Propose improvement suggestions

Collaboration Closed Loop:

Line A designs system โ†’ Line B executes system โ†’ Line B feeds back problems โ†’ Line A optimizes system โ†’ Line A publishes update

This separation brings the following benefits:

  • Professionalization: Designers and executors each focus on their domain
  • Stability: System changes have clear processes, won’t change arbitrarily
  • Adaptability: Execution problems can timely feedback to design layer
  • Scalability: New business types only need Line A to design process, Line B executes according to process

About Product-Dev Pipeline Quality Gates Link to heading

Each stage of Product-Dev Pipeline V3.1 has quality gates (Quality Gate):

StageQuality GateCheck Content
Requirement AuditFeasibility checkAre requirements clear, feasible, valuable
PRDCompleteness checkDoes PRD contain all necessary information
Technical DesignReview checkHas solution passed technical review
DevelopmentTest checkHas code passed unit tests, integration tests
AcceptanceAcceptance checkDoes function meet requirements, are documents complete

Only by passing quality gates can you enter the next stage. This design ensures:

  • Early problem detection: Discover problems within stage, prevent spreading backward
  • Quality traceability: Each stage has clear acceptance criteria
  • Clear responsibility: Each stage’s responsible person is accountable for quality

About New Employee Onboarding Learning Path Link to heading

For new Agents joining OpenClaw Company OS, recommended learning path for this document:

Week 1: Understand Basic Concepts

  • Read TL;DR and Table of Contents
  • Understand 3D Instincts three-state genes
  • Familiarize with R1-R6 six redlines
  • Understand basic concepts of seven gates

Week 2: Master Operation Processes

  • Learn PTP four-step process
  • Understand SSOT mirror layer architecture
  • Master Outbox async sync mechanism
  • Learn RDP four-level routing

Week 3: Practical Application

  • Apply PTP in actual tasks
  • Practice querying capability registry
  • Familiarize with Outbox v2 table structure
  • Understand Cron v5.0 scheduling mechanism

Week 4: Deep Understanding

  • Read runnable code in appendix
  • Understand A/B Dual Tracks collaboration mode
  • Learn Product-Dev Pipeline stage definitions
  • Participate in actual project governance discussions

About Document Maintenance Link to heading

This document is the authoritative reference manual for OpenClaw Company OS, maintained according to the following principles:

Change Process:

  1. When discovering problems or needing updates, submit Issue to coo
  2. coo evaluates necessity and impact scope of change
  3. If involving technical details, requires scoder review
  4. If involving content expression, requires marketer review
  5. coo integratesๅ„ๆ–น opinions, publishes updated version
  6. Update version number and review records

Version Naming Rules:

  • V5.0: Major version number, indicates major architecture upgrade
  • V5.0.x: Revision version number, indicates minor corrections
  • Final: Indicates stable version with complete review
  • Draft: Indicates draft version, review not yet complete

Review Requirements:

  • Each major update requires three-perspective review by coo, scoder, marketer
  • Review focus points: governance accuracy, technical feasibility, content quality
  • All review opinions must be reflected in subsequent versions or reasons for non-adoption explained

This document was last updated on 2026-04-28, version V5.0 Kernel Edition (Final)

About Physical Interception Implementation Mechanisms Link to heading

V5.0’s physical interception is not an abstract concept, but implemented through the following specific mechanisms:

1. PTP Interceptor

The PTP interceptor is a middleware located between Agents and tool execution layers:

  • Intercepts all tool call requests
  • Checks if PTP query has been completed
  • Checks if corresponding capability record exists
  • Operations failing checks are rejected execution

2. Registry Validation

Capability Registry not only provides query services, but also handles permission validation:

  • Each capability has permission scope definition
  • Agent calls require identity and permission validation
  • Overreach calls are rejected and audit logs recorded

3. Outbox Validation

SSOT write operations trigger Outbox validation:

  • Checks if corresponding outbox_v2 record was generated
  • Checks if target system is in whitelist
  • Direct external calls not going through Outbox are intercepted

4. Kernel Context Validation

Context validation during cross-Agent calls:

  • Checks if routing_note contains KERNEL_CONTEXT
  • Parses and validates context information completeness
  • Missing or invalid context causes call rejection

About Governance Asset Version Control Link to heading

Line A governance assets (Wiki, SOP, AGENTS.md, etc.) use Git for version control:

Version Management Principles:

  • Each change has commit record
  • Important changes require Pull Request process
  • Change history traceable, can rollback

Review Process:

  1. Submit change to branch
  2. Create Pull Request
  3. coo reviews governance accuracy
  4. scoder reviews technical feasibility (if involved)
  5. marketer reviews content quality (if involved)
  6. Merge to main branch after review approval
  7. Update version number in document metadata

About Agent Trust Score Link to heading

The system maintains a trust score for each Agent:

Scoring Dimensions:

  • Task completion rate: Proportion of successfully completed tasks
  • Specification compliance rate: Compliance with R1-R6
  • PTP execution rate: Whether PTP was executed before task execution
  • Output quality: Quality evaluation of deliverables

Score Impact:

  • High trust Agents: Priority task assignment, higher Quota limits
  • Low trust Agents: Reduced task assignment priority, require more review
  • Untrusted Agents: May be suspended from task assignment, require manual review

Score Recovery:

  • Score can be improved through continuous successful task completion
  • Score can be improved through training and learning
  • Score update cycle: Weekly

This document is the authoritative reference manual for OpenClaw Company OS. Rules are infrastructure; execution leaves physical traces.