8.2 KiB
Continuity Plugin (MVP → generalized checkpoint)
中文版:
README.zh-TW.md
This package extracts the current approved-plan continuity hard gate into a small installable, testable OpenClaw plugin.
The package still preserves the current approved-plan behavior, but it now moves one step closer to a more general engine + adapter structure:
- a host-agnostic continuity engine input/output contract
- the existing
force-recallparity adapter - a new
generic-preflightadapter and manual runner for non-force-recallintegration
What this package currently provides
- continuity config validation
- dispatch receipt contract validation
- receipt file writing
- approved-plan continuity gate evaluation
- prompt block generation for the continuity gate
- a
force-recalladapter that maps hook wrapper/planner output into continuity input - a
generic-preflightadapter that accepts host-agnostic continuity input directly - a manual preflight runner for workspaces that do not use
force-recall
Install location
Recommended location inside an OpenClaw workspace:
<workspace>/plugins/continuity
Possible integration layouts now include both the original force-recall path and a more generic path:
<workspace>/
hooks/
force-recall/
handler.ts
HOOK.md
plugins/
continuity/
README.zh-TW.md
README.md
HOOK.md
package.json
examples/
src/
test/
scripts/
test_force_recall_long_task_preflight.mjs
Directory structure
plugins/continuity/
README.zh-TW.md
README.md
HOOK.md
package.json
examples/
approved-plan-receipt.example.json
openclaw.continuity.example.json
src/
index.mjs
adapters/
force-recall.mjs
generic-preflight.mjs
config/
defaults.mjs
schema.mjs
continuity/
engine.mjs
evaluator.mjs
receipt-store.mjs
receipt-validator.mjs
types.md
test/
continuity.config.test.mjs
continuity.evaluator.test.mjs
continuity.plugin.test.mjs
continuity.receipt-store.test.mjs
continuity.receipt-validator.test.mjs
continuity.smoke.test.mjs
Public surface
src/config/schema.mjssrc/config/defaults.mjssrc/continuity/engine.mjssrc/continuity/evaluator.mjssrc/continuity/receipt-validator.mjssrc/continuity/receipt-store.mjssrc/adapters/force-recall.mjssrc/adapters/generic-preflight.mjssrc/index.mjs
src/index.mjs currently re-exports:
defaultConfigcloneDefaultConfig()validateContinuityConfig()/normalizeContinuityConfig()normalizeContinuityEngineInput()createContinuityEngineResult()/createContinuityEngineContract()evaluateContinuity()/buildContinuityGateBlock()validateReceipt()/isValidReceipt()slugifyReceiptSegment()/buildReceiptFilename()/writeReceipt()buildApprovedPlanContinuityInput()createForceRecallContinuityAdapter()/runForceRecallContinuityAdapter()buildGenericContinuityInput()createGenericPreflightContinuityAdapter()/runGenericPreflightContinuityAdapter()runManualContinuityPreflight()
Host-agnostic engine contract
The generalized engine accepts a normalized continuity input with fields such as:
planIdcurrentTasktaskStatenextDerivedActionreplyClosureStatedispatchReceiptnextTaskKnownsameApprovedPlantaskBoundaryStophighRiskStop
Generalized adapters return a common contract:
inputresultevaluationblockmeta.adapterNamemeta.hostAgnostic
See src/continuity/types.md for the concise contract notes.
Example config
Start from examples/openclaw.continuity.example.json:
{
"enabled": true,
"planMatchers": ["approved-plan"],
"legalTerminalStates": [
"waiting_user",
"blocked",
"pending_verification"
],
"receiptDir": "state/approved-plan-continuity",
"requireRealDispatchReceipt": true,
"allowReplyClosureWithoutDispatch": false,
"debug": false,
"adapter": {
"forceRecall": {
"enabled": true,
"injectBlockLabel": "APPROVED_PLAN_CONTINUITY_GATE"
},
"genericPreflight": {
"enabled": true,
"injectBlockLabel": "APPROVED_PLAN_CONTINUITY_GATE"
}
}
}
Defaults are defined in src/config/defaults.mjs.
Integration path A: force-recall
The original MVP integration point remains hooks/force-recall/handler.ts.
import plugin from './plugins/continuity/src/index.mjs';
const out = plugin.runForceRecallContinuityAdapter({
config: plugin.defaultConfig,
wrapperResult,
autoChainPlanResult,
});
if (out?.block) {
context.bodyForAgent = `${out.block}\n${context.bodyForAgent}`;
}
Integration path B: generic/manual preflight
If your workspace does not use force-recall, you can still install and use the plugin by calling the generalized adapter or the manual runner directly.
Generic preflight adapter
import plugin from './plugins/continuity/src/index.mjs';
const out = plugin.runGenericPreflightContinuityAdapter({
config: plugin.defaultConfig,
source: {
planId: 'approved-plan-1',
currentTask: 'task-3',
taskState: 'complete',
nextTaskKnown: true,
sameApprovedPlan: true,
taskBoundaryStop: true,
nextTaskId: 'task-4',
nextDerivedAction: { type: 'message_subagent', task: 'continue' },
replyClosureState: 'completed',
dispatchReceipt: null,
},
});
Manual runner
import plugin from './plugins/continuity/src/index.mjs';
const out = plugin.runManualContinuityPreflight({
config: plugin.defaultConfig,
planId: 'approved-plan-1',
currentTask: 'task-3',
taskState: 'complete',
nextDerivedAction: { type: 'message_subagent', task: 'continue' },
replyClosureState: 'waiting_user',
});
If out.block is non-empty, prepend it into the prompt/body seen by the agent.
Receipt contract
Minimum receipt shape:
planIdcurrentTasknextDerivedActiondispatchedAtdispatchRunIdchildSessionKeyreplyClosureState
To persist a receipt:
import { writeReceipt } from './src/index.mjs';
await writeReceipt({
receiptDir: 'state/approved-plan-continuity',
receipt,
});
Smoke test / verification
Required plugin verification:
cd plugins/continuity
npm test
node test/continuity.smoke.test.mjs
If your workspace uses force-recall, also run:
cd /path/to/workspace
node scripts/test_force_recall_long_task_preflight.mjs
node --check hooks/force-recall/handler.ts
Install and apply steps for another OpenClaw workspace
- Copy
plugins/continuityinto your workspace. - Choose one integration path:
force-recall: loadrunForceRecallContinuityAdapter(...)- no
force-recall: callrunGenericPreflightContinuityAdapter(...)orrunManualContinuityPreflight(...)
- Adjust config as needed, especially:
planMatcherslegalTerminalStatesreceiptDiradapter.forceRecall.injectBlockLabeladapter.genericPreflight.injectBlockLabel
- If your dispatch flow creates child runs/sessions, persist a real receipt.
- Run plugin tests and the relevant workspace smoke path.
- Confirm the agent prompt contains the continuity gate block and that dry-run dispatch alone does not pass the gate.
Current limitations
- This is still centered on the approved-plan continuity hard gate, not a full general workflow engine.
- The generalized engine contract is intentionally minimal and conservative.
force-recallremains the most battle-tested adapter.- The receipt store only writes files; it does not manage retention, cleanup, or indexing.
- The receipt validator checks the minimum contract only; it does not deeply validate every
nextDerivedActionsubtype.
Notes
- Default legal terminal states are
waiting_user,blocked, andpending_verification - The evaluator preserves current behavior, including
missing_dispatch_receiptandmissing_auto_next_dispatch - The new generic path makes the plugin more reusable even without the
force-recallhook HOOK.mddescribes the plugin/hook adapter contract boundary, not the full installation guide
Chinese documentation
See README.zh-TW.md for the Traditional Chinese version.