mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 16:40:47 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -0,0 +1,158 @@
|
|||
# Cron natural fire no duplicate
|
||||
|
||||
```yaml qa-scenario
|
||||
id: cron-natural-fire-no-duplicate
|
||||
title: Cron natural fire no duplicate
|
||||
surface: cron
|
||||
coverage:
|
||||
primary:
|
||||
- scheduling.cron
|
||||
secondary:
|
||||
- channels.qa-channel
|
||||
- scheduling.dedup
|
||||
objective: Verify one naturally fired cron run in a single gateway uptime produces exactly one qa-channel delivery for its marker.
|
||||
successCriteria:
|
||||
- A one-shot cron job fires from the scheduler timer without cron.run force mode.
|
||||
- The qa-channel receives exactly one outbound reply containing the run marker.
|
||||
- No second outbound reply with the same marker appears during the duplicate window.
|
||||
docsRefs:
|
||||
- docs/help/testing.md
|
||||
- docs/channels/qa-channel.md
|
||||
codeRefs:
|
||||
- src/cron/service.ts
|
||||
- src/cron/service/timer.ts
|
||||
- src/cron/run-log.ts
|
||||
- extensions/qa-lab/src/cron-run-wait.ts
|
||||
- extensions/qa-lab/src/suite-runtime-transport.ts
|
||||
execution:
|
||||
kind: flow
|
||||
summary: Let one cron job fire from the natural scheduler timer and assert qa-channel does not receive a duplicate delivery for the same marker.
|
||||
config:
|
||||
channelId: qa-room
|
||||
channelTitle: QA Room
|
||||
fireDelayMs: 12000
|
||||
duplicateWindowMs: 8000
|
||||
reminderPromptTemplate: "A natural QA cron dedupe check fired. Send a one-line ping back to the room containing this exact marker: {{marker}}"
|
||||
```
|
||||
|
||||
```yaml qa-flow
|
||||
steps:
|
||||
- name: creates a near-future cron job and waits for the scheduler timer
|
||||
actions:
|
||||
- call: reset
|
||||
- set: runStartedAt
|
||||
value:
|
||||
expr: "Date.now()"
|
||||
- set: scheduledFor
|
||||
value:
|
||||
expr: "new Date(runStartedAt + config.fireDelayMs).toISOString()"
|
||||
- set: cronMarker
|
||||
value:
|
||||
expr: "`QA-CRON-NATURAL-DEDUPE-${randomUUID().slice(0, 8)}`"
|
||||
- call: env.gateway.call
|
||||
saveAs: response
|
||||
args:
|
||||
- cron.add
|
||||
- name:
|
||||
expr: "`qa-natural-dedupe-${randomUUID()}`"
|
||||
enabled: true
|
||||
schedule:
|
||||
kind: at
|
||||
at:
|
||||
ref: scheduledFor
|
||||
sessionTarget: isolated
|
||||
wakeMode: now
|
||||
payload:
|
||||
kind: agentTurn
|
||||
message:
|
||||
expr: "config.reminderPromptTemplate.replace('{{marker}}', cronMarker)"
|
||||
delivery:
|
||||
mode: announce
|
||||
channel: qa-channel
|
||||
to:
|
||||
expr: "`channel:${config.channelId}`"
|
||||
- timeoutMs: 30000
|
||||
- set: jobId
|
||||
value:
|
||||
expr: response.id
|
||||
- assert:
|
||||
expr: "Boolean(jobId)"
|
||||
message: missing cron job id
|
||||
- set: scheduledAtMs
|
||||
value:
|
||||
expr: "new Date(response.schedule?.at ?? scheduledFor).getTime()"
|
||||
- set: scheduleDeltaMs
|
||||
value:
|
||||
expr: "scheduledAtMs - runStartedAt"
|
||||
- assert:
|
||||
expr: "scheduleDeltaMs >= config.fireDelayMs - 2000 && scheduleDeltaMs <= config.fireDelayMs + 5000"
|
||||
message:
|
||||
expr: "`expected near-future natural fire, got ${scheduleDeltaMs}ms`"
|
||||
- call: waitForCronRunCompletion
|
||||
saveAs: completedRun
|
||||
args:
|
||||
- callGateway:
|
||||
expr: "env.gateway.call.bind(env.gateway)"
|
||||
jobId:
|
||||
ref: jobId
|
||||
afterTs:
|
||||
ref: runStartedAt
|
||||
timeoutMs:
|
||||
expr: "liveTurnTimeoutMs(env, Math.max(60000, config.fireDelayMs + 45000))"
|
||||
- assert:
|
||||
expr: "Date.now() >= scheduledAtMs"
|
||||
message:
|
||||
expr: "`cron completed before scheduled time ${scheduledFor}`"
|
||||
- assert:
|
||||
expr: "completedRun?.status === 'ok'"
|
||||
message:
|
||||
expr: "`expected natural cron run ok, got ${JSON.stringify(completedRun)}`"
|
||||
detailsExpr: "`job=${jobId} marker=${cronMarker} scheduled=${scheduledFor}`"
|
||||
|
||||
- name: observes exactly one qa-channel delivery for the natural run
|
||||
actions:
|
||||
- call: waitForOutboundMessage
|
||||
saveAs: firstOutbound
|
||||
args:
|
||||
- ref: state
|
||||
- lambda:
|
||||
params: [candidate]
|
||||
expr: "candidate.conversation.id === config.channelId && candidate.text.includes(cronMarker)"
|
||||
- expr: liveTurnTimeoutMs(env, 45000)
|
||||
- set: firstOutboundId
|
||||
value:
|
||||
expr: firstOutbound.id
|
||||
- set: firstOutboundIndex
|
||||
value:
|
||||
expr: "getTransportSnapshot().messages.findIndex((message) => message.id === firstOutboundId)"
|
||||
- assert:
|
||||
expr: "firstOutboundIndex >= 0"
|
||||
message: first outbound message missing from qa-channel snapshot
|
||||
- call: sleep
|
||||
args:
|
||||
- expr: config.duplicateWindowMs
|
||||
- set: duplicateMatches
|
||||
value:
|
||||
expr: "getTransportSnapshot().messages.filter((message) => message.direction === 'outbound' && message.conversation.id === config.channelId && message.text.includes(cronMarker))"
|
||||
- assert:
|
||||
expr: "duplicateMatches.length === 1"
|
||||
message:
|
||||
expr: "`expected one natural outbound delivery for ${cronMarker}, saw ${duplicateMatches.length}: ${duplicateMatches.map((message) => message.text).join(' | ')}`"
|
||||
- call: env.gateway.call
|
||||
saveAs: runsPage
|
||||
args:
|
||||
- cron.runs
|
||||
- id:
|
||||
ref: jobId
|
||||
limit: 10
|
||||
sortDir: desc
|
||||
- timeoutMs: 30000
|
||||
- set: completedRuns
|
||||
value:
|
||||
expr: "runsPage.entries.filter((entry) => entry.ts >= runStartedAt && ['ok', 'error', 'skipped'].includes(entry.status))"
|
||||
- assert:
|
||||
expr: "completedRuns.length === 1"
|
||||
message:
|
||||
expr: "`expected one completed natural cron run for ${jobId}, saw ${completedRuns.length}: ${JSON.stringify(completedRuns)}`"
|
||||
detailsExpr: "`first outbound=${firstOutboundId}; duplicate window=${config.duplicateWindowMs}ms`"
|
||||
```
|
||||
117
openclaw/qa/scenarios/scheduling/cron-one-minute-ping.md
Normal file
117
openclaw/qa/scenarios/scheduling/cron-one-minute-ping.md
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# Cron one-minute ping
|
||||
|
||||
```yaml qa-scenario
|
||||
id: cron-one-minute-ping
|
||||
title: Cron one-minute ping
|
||||
surface: cron
|
||||
coverage:
|
||||
primary:
|
||||
- scheduling.cron
|
||||
secondary:
|
||||
- channels.qa-channel
|
||||
objective: Verify the agent can schedule a cron reminder one minute in the future and receive the follow-up in the QA channel.
|
||||
successCriteria:
|
||||
- Agent schedules a cron reminder roughly one minute ahead.
|
||||
- Reminder returns through qa-channel.
|
||||
- Agent recognizes the reminder as part of the original task.
|
||||
docsRefs:
|
||||
- docs/help/testing.md
|
||||
- docs/channels/qa-channel.md
|
||||
codeRefs:
|
||||
- extensions/qa-lab/src/bus-server.ts
|
||||
- extensions/qa-lab/src/self-check.ts
|
||||
execution:
|
||||
kind: flow
|
||||
summary: Verify the agent can schedule a cron reminder one minute in the future and receive the follow-up in the QA channel.
|
||||
config:
|
||||
channelId: qa-room
|
||||
channelTitle: QA Room
|
||||
reminderPromptTemplate: "A QA cron just fired. Send a one-line ping back to the room containing this exact marker: {{marker}}"
|
||||
```
|
||||
|
||||
```yaml qa-flow
|
||||
steps:
|
||||
- name: stores a reminder roughly one minute ahead
|
||||
actions:
|
||||
- call: reset
|
||||
- set: at
|
||||
value:
|
||||
expr: "new Date(Date.now() + 60000).toISOString()"
|
||||
- set: cronMarker
|
||||
value:
|
||||
expr: "`QA-CRON-${randomUUID().slice(0, 8)}`"
|
||||
- call: env.gateway.call
|
||||
saveAs: response
|
||||
args:
|
||||
- cron.add
|
||||
- name:
|
||||
expr: "`qa-suite-${randomUUID()}`"
|
||||
enabled: true
|
||||
schedule:
|
||||
kind: at
|
||||
at:
|
||||
ref: at
|
||||
sessionTarget: isolated
|
||||
wakeMode: now
|
||||
payload:
|
||||
kind: agentTurn
|
||||
message:
|
||||
expr: "config.reminderPromptTemplate.replace('{{marker}}', cronMarker)"
|
||||
delivery:
|
||||
mode: announce
|
||||
channel: qa-channel
|
||||
to:
|
||||
expr: "`channel:${config.channelId}`"
|
||||
- set: scheduledAt
|
||||
value:
|
||||
expr: "response.schedule?.at ?? at"
|
||||
- set: delta
|
||||
value:
|
||||
expr: "new Date(scheduledAt).getTime() - Date.now()"
|
||||
- assert:
|
||||
expr: "delta >= 45000 && delta <= 75000"
|
||||
message:
|
||||
expr: "`expected ~1 minute schedule, got ${delta}ms`"
|
||||
- set: jobId
|
||||
value:
|
||||
expr: response.id
|
||||
detailsExpr: scheduledAt
|
||||
|
||||
- name: forces the reminder through QA channel delivery
|
||||
actions:
|
||||
- assert:
|
||||
expr: "Boolean(jobId)"
|
||||
message: missing cron job id
|
||||
- assert:
|
||||
expr: "Boolean(cronMarker)"
|
||||
message: missing cron marker
|
||||
- set: runStartedAt
|
||||
value:
|
||||
expr: "Date.now()"
|
||||
- call: env.gateway.call
|
||||
args:
|
||||
- cron.run
|
||||
- id:
|
||||
ref: jobId
|
||||
mode: force
|
||||
- timeoutMs: 30000
|
||||
- call: waitForCronRunCompletion
|
||||
args:
|
||||
- callGateway:
|
||||
expr: "env.gateway.call.bind(env.gateway)"
|
||||
jobId:
|
||||
ref: jobId
|
||||
afterTs:
|
||||
ref: runStartedAt
|
||||
timeoutMs:
|
||||
expr: liveTurnTimeoutMs(env, 45000)
|
||||
- call: waitForOutboundMessage
|
||||
saveAs: outbound
|
||||
args:
|
||||
- ref: state
|
||||
- lambda:
|
||||
params: [candidate]
|
||||
expr: "candidate.conversation.id === config.channelId && candidate.text.includes(cronMarker)"
|
||||
- expr: liveTurnTimeoutMs(env, 45000)
|
||||
detailsExpr: outbound.text
|
||||
```
|
||||
153
openclaw/qa/scenarios/scheduling/cron-single-run-no-duplicate.md
Normal file
153
openclaw/qa/scenarios/scheduling/cron-single-run-no-duplicate.md
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
# Cron single run no duplicate
|
||||
|
||||
```yaml qa-scenario
|
||||
id: cron-single-run-no-duplicate
|
||||
title: Cron single run no duplicate
|
||||
surface: cron
|
||||
coverage:
|
||||
primary:
|
||||
- scheduling.cron
|
||||
secondary:
|
||||
- channels.qa-channel
|
||||
- scheduling.dedup
|
||||
objective: Verify one forced cron run produces exactly one qa-channel delivery for its marker.
|
||||
successCriteria:
|
||||
- A single forced cron run completes successfully.
|
||||
- The qa-channel receives exactly one outbound reply containing the run marker.
|
||||
- No second outbound reply with the same marker appears during the duplicate window.
|
||||
docsRefs:
|
||||
- docs/help/testing.md
|
||||
- docs/channels/qa-channel.md
|
||||
codeRefs:
|
||||
- src/cron/service.ts
|
||||
- src/cron/run-log.ts
|
||||
- extensions/qa-lab/src/cron-run-wait.ts
|
||||
- extensions/qa-lab/src/suite-runtime-transport.ts
|
||||
execution:
|
||||
kind: flow
|
||||
summary: Force one cron run and assert qa-channel does not receive a duplicate delivery for the same marker.
|
||||
config:
|
||||
channelId: qa-room
|
||||
channelTitle: QA Room
|
||||
duplicateWindowMs: 8000
|
||||
reminderPromptTemplate: "A QA cron dedupe check fired. Send a one-line ping back to the room containing this exact marker: {{marker}}"
|
||||
```
|
||||
|
||||
```yaml qa-flow
|
||||
steps:
|
||||
- name: creates a future cron job and forces one run
|
||||
actions:
|
||||
- call: reset
|
||||
- set: scheduledFor
|
||||
value:
|
||||
expr: "new Date(Date.now() + 10 * 60 * 1000).toISOString()"
|
||||
- set: cronMarker
|
||||
value:
|
||||
expr: "`QA-CRON-DEDUPE-${randomUUID().slice(0, 8)}`"
|
||||
- call: env.gateway.call
|
||||
saveAs: response
|
||||
args:
|
||||
- cron.add
|
||||
- name:
|
||||
expr: "`qa-dedupe-${randomUUID()}`"
|
||||
enabled: true
|
||||
schedule:
|
||||
kind: at
|
||||
at:
|
||||
ref: scheduledFor
|
||||
sessionTarget: isolated
|
||||
wakeMode: now
|
||||
payload:
|
||||
kind: agentTurn
|
||||
message:
|
||||
expr: "config.reminderPromptTemplate.replace('{{marker}}', cronMarker)"
|
||||
delivery:
|
||||
mode: announce
|
||||
channel: qa-channel
|
||||
to:
|
||||
expr: "`channel:${config.channelId}`"
|
||||
- set: jobId
|
||||
value:
|
||||
expr: response.id
|
||||
- assert:
|
||||
expr: "Boolean(jobId)"
|
||||
message: missing cron job id
|
||||
- set: runStartedAt
|
||||
value:
|
||||
expr: "Date.now()"
|
||||
- call: env.gateway.call
|
||||
saveAs: runResponse
|
||||
args:
|
||||
- cron.run
|
||||
- id:
|
||||
ref: jobId
|
||||
mode: force
|
||||
- timeoutMs: 30000
|
||||
- assert:
|
||||
expr: "runResponse?.ok === true && runResponse?.ran !== false"
|
||||
message:
|
||||
expr: "`expected cron.run to enqueue one run, got ${JSON.stringify(runResponse)}`"
|
||||
detailsExpr: "`job=${jobId} marker=${cronMarker}`"
|
||||
|
||||
- name: observes exactly one qa-channel delivery for that run
|
||||
actions:
|
||||
- call: waitForCronRunCompletion
|
||||
saveAs: completedRun
|
||||
args:
|
||||
- callGateway:
|
||||
expr: "env.gateway.call.bind(env.gateway)"
|
||||
jobId:
|
||||
ref: jobId
|
||||
afterTs:
|
||||
ref: runStartedAt
|
||||
timeoutMs:
|
||||
expr: liveTurnTimeoutMs(env, 45000)
|
||||
- assert:
|
||||
expr: "completedRun?.status === 'ok'"
|
||||
message:
|
||||
expr: "`expected cron run ok, got ${JSON.stringify(completedRun)}`"
|
||||
- call: waitForOutboundMessage
|
||||
saveAs: firstOutbound
|
||||
args:
|
||||
- ref: state
|
||||
- lambda:
|
||||
params: [candidate]
|
||||
expr: "candidate.conversation.id === config.channelId && candidate.text.includes(cronMarker)"
|
||||
- expr: liveTurnTimeoutMs(env, 45000)
|
||||
- set: firstOutboundId
|
||||
value:
|
||||
expr: firstOutbound.id
|
||||
- set: firstOutboundIndex
|
||||
value:
|
||||
expr: "getTransportSnapshot().messages.findIndex((message) => message.id === firstOutboundId)"
|
||||
- assert:
|
||||
expr: "firstOutboundIndex >= 0"
|
||||
message: first outbound message missing from qa-channel snapshot
|
||||
- call: sleep
|
||||
args:
|
||||
- expr: config.duplicateWindowMs
|
||||
- set: duplicateMatches
|
||||
value:
|
||||
expr: "getTransportSnapshot().messages.filter((message) => message.direction === 'outbound' && message.conversation.id === config.channelId && message.text.includes(cronMarker))"
|
||||
- assert:
|
||||
expr: "duplicateMatches.length === 1"
|
||||
message:
|
||||
expr: "`expected one outbound delivery for ${cronMarker}, saw ${duplicateMatches.length}: ${duplicateMatches.map((message) => message.text).join(' | ')}`"
|
||||
- call: env.gateway.call
|
||||
saveAs: runsPage
|
||||
args:
|
||||
- cron.runs
|
||||
- id:
|
||||
ref: jobId
|
||||
limit: 10
|
||||
sortDir: desc
|
||||
- timeoutMs: 30000
|
||||
- set: completedRuns
|
||||
value:
|
||||
expr: "runsPage.entries.filter((entry) => entry.ts >= runStartedAt && ['ok', 'error', 'skipped'].includes(entry.status))"
|
||||
- assert:
|
||||
expr: "completedRuns.length === 1"
|
||||
message:
|
||||
expr: "`expected one completed cron run for ${jobId}, saw ${completedRuns.length}: ${JSON.stringify(completedRuns)}`"
|
||||
detailsExpr: "`first outbound=${firstOutboundId}; duplicate window=${config.duplicateWindowMs}ms`"
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue