Skip to content

Commit d035dba

Browse files
authored
chore: scope SQLite session lifecycle CI (#121917)
* oc-358: scope SQLite lifecycle CI * chore(ci): cover shared session lifecycle owner
1 parent 4ccbdf5 commit d035dba

7 files changed

Lines changed: 229 additions & 32 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ jobs:
9393
frozen_target: ${{ steps.manifest.outputs.frozen_target }}
9494
run_qa_smoke_ci: ${{ steps.manifest.outputs.run_qa_smoke_ci }}
9595
run_prompt_snapshots: ${{ steps.manifest.outputs.run_prompt_snapshots }}
96+
run_sqlite_session_lifecycle: ${{ steps.manifest.outputs.run_sqlite_session_lifecycle }}
9697
checks_fast_core_matrix: ${{ steps.manifest.outputs.checks_fast_core_matrix }}
9798
run_plugin_contracts_shards: ${{ steps.manifest.outputs.run_plugin_contracts_shards }}
9899
plugin_contracts_matrix: ${{ steps.manifest.outputs.plugin_contracts_matrix }}
@@ -681,7 +682,20 @@ jobs:
681682
eventName !== "pull_request" ||
682683
typeof changedNodeTestPlan.hasPromptSnapshotAffectingChange !== "function" ||
683684
changedNodeTestPlan.hasPromptSnapshotAffectingChange(changedPaths);
684-
const runBuildArtifacts = runNodeFull && changedScopeHasBuildImpact;
685+
const supportsSqliteSessionLifecycleProof = existsSync(
686+
"test/scripts/sqlite-sessions-transcripts-flip-proof.built-cli.e2e.test.ts",
687+
);
688+
const changedScopeHasSqliteSessionLifecycleImpact =
689+
changedPaths === null ||
690+
eventName === "workflow_dispatch" ||
691+
typeof changedNodeTestPlan.hasSqliteSessionLifecycleAffectingChange !== "function" ||
692+
changedNodeTestPlan.hasSqliteSessionLifecycleAffectingChange(changedPaths);
693+
const runSqliteSessionLifecycle =
694+
runNodeFull &&
695+
supportsSqliteSessionLifecycleProof &&
696+
changedScopeHasSqliteSessionLifecycleImpact;
697+
const runBuildArtifacts =
698+
runNodeFull && (changedScopeHasBuildImpact || runSqliteSessionLifecycle);
685699
const runQaSmokeCi =
686700
runNodeFull &&
687701
changedScopeHasQaImpact &&
@@ -752,6 +766,7 @@ jobs:
752766
compatibility_target: compatibilityTarget,
753767
run_qa_smoke_ci: runQaSmokeCi,
754768
run_prompt_snapshots: runNodeFull && changedScopeHasPromptSnapshotImpact,
769+
run_sqlite_session_lifecycle: runSqliteSessionLifecycle,
755770
checks_fast_core_matrix: createMatrix(checksFastCoreTasks),
756771
run_plugin_contracts_shards: runPluginContractShards,
757772
plugin_contracts_matrix: createMatrix(
@@ -1437,6 +1452,38 @@ jobs:
14371452
path: .local/gateway-watch-regression/
14381453
retention-days: 7
14391454

1455+
sqlite-session-lifecycle:
1456+
permissions:
1457+
contents: read
1458+
name: check-sqlite-session-lifecycle
1459+
needs: [preflight, build-artifacts]
1460+
if: ${{ !cancelled() && always() && needs.preflight.outputs.run_sqlite_session_lifecycle == 'true' && needs.build-artifacts.result == 'success' }}
1461+
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-24.04') }}
1462+
timeout-minutes: 20
1463+
steps:
1464+
- *linux_node_checkout_step
1465+
- name: Setup Node environment
1466+
uses: ./.github/actions/setup-node-env
1467+
with:
1468+
install-bun: "false"
1469+
sticky-disk: ${{ github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false' }}
1470+
use-actions-cache: ${{ github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true' }}
1471+
1472+
- name: Download exact-run built runtime
1473+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
1474+
with:
1475+
name: dist-runtime-build
1476+
path: .artifacts/dist-runtime-build
1477+
1478+
- name: Extract built runtime
1479+
run: tar --extract --file .artifacts/dist-runtime-build/dist-runtime-build.tar.zst --use-compress-program unzstd
1480+
1481+
- name: Verify SQLite session lifecycle
1482+
env:
1483+
OPENCLAW_E2E_USE_PREBUILT_DIST: "1"
1484+
OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS: "660000"
1485+
run: node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/scripts/sqlite-sessions-transcripts-flip-proof.built-cli.e2e.test.ts
1486+
14401487
native-i18n:
14411488
permissions:
14421489
contents: read
@@ -2545,9 +2592,6 @@ jobs:
25452592
- check_name: check-plugin-sdk-api-baseline
25462593
group: plugin-sdk-api-baseline
25472594
runner: blacksmith-4vcpu-ubuntu-2404
2548-
- check_name: check-sqlite-session-flip-proof
2549-
group: sqlite-session-flip-proof
2550-
runner: blacksmith-8vcpu-ubuntu-2404
25512595
- check_name: check-additional-extension-package-boundary
25522596
group: extension-package-boundary
25532597
# Light-run critical-path pole: cold runs spend ~100s in nine
@@ -2774,15 +2818,6 @@ jobs:
27742818
plugin-sdk-api-baseline)
27752819
run_check "plugin-sdk:api:check" pnpm run plugin-sdk:api:check
27762820
;;
2777-
sqlite-session-flip-proof)
2778-
if [ ! -f test/scripts/sqlite-sessions-transcripts-flip-proof.e2e.test.ts ]; then
2779-
echo "[skip] SQLite sessions/transcripts flip proof is not present in this checkout"
2780-
else
2781-
# This lane owns a 420-second E2E case plus cold hosted-runner setup;
2782-
# keep the global watchdog strict and scope compatibility headroom here.
2783-
run_check "sqlite sessions/transcripts flip proof" env OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=660000 node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/scripts/sqlite-sessions-transcripts-flip-proof.e2e.test.ts
2784-
fi
2785-
;;
27862821
extension-package-boundary)
27872822
run_check "test:extensions:package-boundary:compile" pnpm run test:extensions:package-boundary:compile
27882823
run_check "test:extensions:package-boundary:canary" pnpm run test:extensions:package-boundary:canary
@@ -3751,6 +3786,7 @@ jobs:
37513786
- security-fast
37523787
- pnpm-store-warmup
37533788
- build-artifacts
3789+
- sqlite-session-lifecycle
37543790
- native-i18n
37553791
- checks-ui
37563792
- checks-ui-e2e
@@ -3784,6 +3820,7 @@ jobs:
37843820
SELECTED_RESULTS: |
37853821
pnpm-store-warmup=${{ needs.pnpm-store-warmup.result }}
37863822
build-artifacts=${{ needs.build-artifacts.result }}
3823+
sqlite-session-lifecycle=${{ needs.sqlite-session-lifecycle.result }}
37873824
native-i18n=${{ needs.native-i18n.result }}
37883825
checks-ui=${{ needs.checks-ui.result }}
37893826
checks-ui-e2e=${{ needs.checks-ui-e2e.result }}

‎docs/ci.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Separate iOS and macOS Periphery workflows enforce a zero-findings dead-code pol
102102
- **Workflow Sanity** runs `actionlint`, `zizmor` over all workflow YAML files, the composite-action interpolation guard, and the conflict-marker guard. The PR-scoped `security-fast` job also runs `zizmor` over changed workflow files so workflow security findings fail early in the main CI graph.
103103
- **Docs on `main` pushes** are checked by the standalone `Docs` workflow with the same ClawHub docs mirror used by CI, so mixed code+docs pushes do not also queue the CI `check-docs` shard. Pull requests and manual CI still run `check-docs` from CI when docs changed.
104104
- **TUI PTY** splits by proof ownership. The dedicated `core-runtime-tui-pty` Node shard owns the full real-backend suite against the exact-head built CLI. The `build-artifacts` job keeps only a local model roundtrip and a real Gateway connection canary, so every artifact boundary proves the built launcher without duplicating the full serial suite inside the build job.
105+
- **SQLite session lifecycle** runs the built-CLI migration, restart, compaction, cleanup, and session RPC proof only when the diff touches its direct storage/session owners or a reachable session path in the embedded runner. The dedicated `check-sqlite-session-lifecycle` job downloads the exact runtime produced by `build-artifacts`; manual and release dispatches always select it when the target contains the proof.
105106
- **CI routing-only edits, the small set of core-test fixtures the fast task runs directly, and narrow plugin contract helper edits** use a fast Node-only manifest path: `preflight`, `security-fast`, and only the fast lanes the change touches — a single `checks-fast-core` CI-routing task, the two plugin contract shards, or both. That path skips build artifacts, Node 22 compatibility, channel contracts, full core shards, bundled-plugin shards, and additional guard matrices.
106107
- **Windows Node checks** are scoped to Windows-specific process/path wrappers, npm/pnpm/UI runner helpers, package manager config, and the CI workflow surfaces that execute that lane; unrelated source, plugin, install-smoke, and test-only changes stay on the Linux Node lanes.
107108

@@ -182,15 +183,15 @@ for commands and recovery.
182183

183184
## Runners
184185

185-
| Runner | Jobs |
186-
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
187-
| `ubuntu-24.04` | `security-fast`, manual CI dispatch and non-canonical repository fallbacks, pull-request retries of both UI E2E jobs, the QA Smoke aggregate, CodeQL security and quality scans, workflow-sanity, labeler, auto-response, the standalone Docs workflow, and the whole Install Smoke workflow |
188-
| `blacksmith-4vcpu-ubuntu-2404` | `preflight`, `pnpm-store-warmup`, `native-i18n`, `checks-fast-core` except QA Smoke CI, plugin/channel contract shards, most bundled/lower-weight Linux Node shards, `check-*` lanes except `check-lint`, selected `check-additional-*` shards, `check-docs`, and `skills-python` |
189-
| `blacksmith-8vcpu-ubuntu-2404` | Retained heavy Linux Node suites, first-attempt same-repo pull requests and pushes for the serial Chromium/Vite `checks-ui-e2e` lane (three Control UI shards plus one browser extension shard), boundary/extension-heavy `check-additional-*` shards, and `android` |
190-
| `blacksmith-16vcpu-ubuntu-2404` | Automatic QA Smoke CI shards, first-attempt same-repo pull requests and pushes for `checks-ui-e2e-real-gateway`, `build-artifacts` in CI and Testbox, and `check-lint` (CPU-sensitive enough that 8 vCPU cost more than they saved) |
191-
| `blacksmith-8vcpu-windows-2025` | `checks-windows` |
192-
| `blacksmith-6vcpu-macos-15` | `macos-node` on `openclaw/openclaw`; forks fall back to `macos-15` |
193-
| `blacksmith-12vcpu-macos-26` | `macos-swift` and `ios-build` on `openclaw/openclaw`; forks fall back to `macos-26` |
186+
| Runner | Jobs |
187+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
188+
| `ubuntu-24.04` | `security-fast`, manual CI dispatch and non-canonical repository fallbacks, pull-request retries of both UI E2E jobs, the QA Smoke aggregate, CodeQL security and quality scans, workflow-sanity, labeler, auto-response, the standalone Docs workflow, and the whole Install Smoke workflow |
189+
| `blacksmith-4vcpu-ubuntu-2404` | `preflight`, `pnpm-store-warmup`, `native-i18n`, `checks-fast-core` except QA Smoke CI, plugin/channel contract shards, most bundled/lower-weight Linux Node shards, `check-*` lanes except `check-lint`, selected `check-additional-*` shards, `check-docs`, and `skills-python` |
190+
| `blacksmith-8vcpu-ubuntu-2404` | Retained heavy Linux Node suites, first-attempt same-repo pull requests and pushes for the serial Chromium/Vite `checks-ui-e2e` lane (three Control UI shards plus one browser extension shard), boundary/extension-heavy `check-additional-*` shards, `check-sqlite-session-lifecycle`, and `android` |
191+
| `blacksmith-16vcpu-ubuntu-2404` | Automatic QA Smoke CI shards, first-attempt same-repo pull requests and pushes for `checks-ui-e2e-real-gateway`, `build-artifacts` in CI and Testbox, and `check-lint` (CPU-sensitive enough that 8 vCPU cost more than they saved) |
192+
| `blacksmith-8vcpu-windows-2025` | `checks-windows` |
193+
| `blacksmith-6vcpu-macos-15` | `macos-node` on `openclaw/openclaw`; forks fall back to `macos-15` |
194+
| `blacksmith-12vcpu-macos-26` | `macos-swift` and `ios-build` on `openclaw/openclaw`; forks fall back to `macos-26` |
194195

195196
## Runner registration budget
196197

‎scripts/lib/ci-changed-node-test-plan.mts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,52 @@ export function hasPromptSnapshotAffectingChange(changedPaths: string[], options
148148
return hasImportGraphImpactOnTargets(sourcePaths, [PROMPT_SNAPSHOT_ENTRY], cwd);
149149
}
150150

151+
// The lifecycle proof crosses dynamic Gateway method registration, doctor
152+
// migrations, shared session coordination, the public session SDK, and the
153+
// built CLI. Keep those owners on the direct surface; use the import graph only
154+
// inside the embedded-runner neighborhood, whose session reachability is not
155+
// apparent from filenames.
156+
const SQLITE_SESSION_LIFECYCLE_PREFIX_RE =
157+
/^(?:src\/(?:agents\/(?:sessions\/|[^/]*(?:session|transcript|compaction)[^/]*)|commands\/doctor-session-|config\/sessions\/|gateway\/(?:agent-turn\/agent-session-persist|server-chat\.(?:load-gateway-session-row|persist-session-lifecycle)|server-methods\/sessions|server\.sessions|session-|sessions-)|plugin-sdk\/session-|sessions\/|state\/openclaw-agent-(?:db|schema))|\.github\/actions\/setup-node-env\/)/u;
158+
const SQLITE_SESSION_LIFECYCLE_EXACT_RE =
159+
/^(?:src\/config\/sessions\.ts|test\/helpers\/(?:openclaw-test-instance|sqlite-sessions-transcripts-flip-proof(?:-assertions)?)\.ts|test\/scripts\/(?:sqlite-sessions-transcripts-flip-proof(?:\.built-cli)?\.e2e\.test|vitest-e2e-global-setup\.test)\.ts|test\/vitest\/vitest\.e2e\.(?:config|global-setup)\.ts|scripts\/lib\/ci-changed-node-test-plan\.mts|\.github\/workflows\/ci\.yml|openclaw\.mjs|package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml)$/u;
160+
const SQLITE_SESSION_LIFECYCLE_ENTRY =
161+
"test/scripts/sqlite-sessions-transcripts-flip-proof.e2e.test.ts";
162+
const SQLITE_SESSION_LIFECYCLE_IMPORT_CANDIDATE_RE = /^src\/agents\/embedded-agent-runner\/run\//u;
163+
164+
/**
165+
* True when a changed path touches a SQLite session lifecycle owner or reaches
166+
* the proof from the embedded-runner neighborhood.
167+
*/
168+
export function hasSqliteSessionLifecycleAffectingChange(
169+
changedPaths: string[],
170+
options: CwdOptions = {},
171+
) {
172+
const cwd = options.cwd ?? process.cwd();
173+
if (
174+
changedPaths.some(
175+
(changedPath) =>
176+
(!isTestFileTarget(changedPath) && SQLITE_SESSION_LIFECYCLE_PREFIX_RE.test(changedPath)) ||
177+
SQLITE_SESSION_LIFECYCLE_EXACT_RE.test(changedPath),
178+
)
179+
) {
180+
return true;
181+
}
182+
const sourcePaths = changedPaths.filter(
183+
(changedPath) =>
184+
SQLITE_SESSION_LIFECYCLE_IMPORT_CANDIDATE_RE.test(changedPath) &&
185+
!isTestFileTarget(changedPath),
186+
);
187+
// Deleted sources cannot be graphed; fail safe to running the lifecycle proof.
188+
if (sourcePaths.some((changedPath) => !existsSync(path.join(cwd, changedPath)))) {
189+
return true;
190+
}
191+
if (sourcePaths.length === 0) {
192+
return false;
193+
}
194+
return hasImportGraphImpactOnTargets(sourcePaths, [SQLITE_SESSION_LIFECYCLE_ENTRY], cwd);
195+
}
196+
151197
function createBoundaryShard() {
152198
// Boundary tests scan the source tree (including test files) and build
153199
// their own fixtures; they do not consume the built dist artifact. When the

‎test/scripts/ci-changed-node-test-plan.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
hasBuildArtifactAffectingChange,
88
hasPromptSnapshotAffectingChange,
99
hasQaSmokeAffectingChange,
10+
hasSqliteSessionLifecycleAffectingChange,
1011
} from "../../scripts/lib/ci-changed-node-test-plan.mts";
1112
import { hasImportGraphImpactOnTargets } from "../../scripts/test-projects.test-support.mts";
1213
import { listGitTrackedFiles } from "../../src/test-utils/repo-files.js";
@@ -135,6 +136,46 @@ describe("CI changed Node test plan", () => {
135136
expect(hasPromptSnapshotAffectingChange(["src/infra/definitely-deleted-module.ts"])).toBe(true);
136137
});
137138

139+
it("classifies SQLite session lifecycle impact by owner and import graph", () => {
140+
expect(
141+
hasSqliteSessionLifecycleAffectingChange([
142+
"src/agents/embedded-agent-runner/run/attempt-session-runtime-prepare.ts",
143+
]),
144+
).toBe(true);
145+
expect(
146+
hasSqliteSessionLifecycleAffectingChange(["src/gateway/server-methods/sessions.ts"]),
147+
).toBe(true);
148+
expect(
149+
hasSqliteSessionLifecycleAffectingChange(["src/sessions/session-lifecycle-admission.ts"]),
150+
).toBe(true);
151+
expect(hasSqliteSessionLifecycleAffectingChange(["src/config/sessions.ts"])).toBe(true);
152+
expect(
153+
hasSqliteSessionLifecycleAffectingChange([
154+
"test/scripts/sqlite-sessions-transcripts-flip-proof.built-cli.e2e.test.ts",
155+
]),
156+
).toBe(true);
157+
expect(
158+
hasSqliteSessionLifecycleAffectingChange(["src/media-understanding/provider-id.ts"]),
159+
).toBe(false);
160+
expect(hasSqliteSessionLifecycleAffectingChange(["src/agents/model-auth.ts"])).toBe(false);
161+
expect(hasSqliteSessionLifecycleAffectingChange(["extensions/discord/src/index.ts"])).toBe(
162+
false,
163+
);
164+
expect(
165+
hasSqliteSessionLifecycleAffectingChange([
166+
"src/config/sessions/session-registry-maintenance.test.ts",
167+
]),
168+
).toBe(false);
169+
expect(
170+
hasSqliteSessionLifecycleAffectingChange(["src/infra/definitely-deleted-module.ts"]),
171+
).toBe(false);
172+
expect(
173+
hasSqliteSessionLifecycleAffectingChange([
174+
"src/agents/embedded-agent-runner/run/deleted-session-runtime.ts",
175+
]),
176+
).toBe(true);
177+
});
178+
138179
it("fails safe to the full plan for broad changes", () => {
139180
expect(createChangedNodeTestShards(["package.json"])).toBeNull();
140181
});

0 commit comments

Comments
 (0)