Skip to content

Commit 7b2affc

Browse files
committed
fix(skills): record skill usage again and retire dead curator tables
Skill lifecycle curation shipped in 2026.7.1 with two producers: a trusted `skill.used` consumer writing `skill_usage`, and a daily sweep aging skills into `skill_lifecycle`. The weekly collection review (#121653) replaced that policy and deleted both producers, but left every reader in place. Since then `skill_usage` has had no writer, so curator status reported `lastUsedAtMs: null` and `useCount: 0` forever, and `skill_lifecycle` had no writer either, so pin/unpin/restore either threw "not found" on fresh installs or, worse, "succeeded" on upgraded ones while gating nothing at all. `skill_workshop_proposal_origin_runs` was never read in any revision; proposal provenance is authoritative in `record_json`. Restore the usage producer at its owner and retire what has no owner: - `skill.used` events populate `skill_usage` again, registered with the collection-review maintenance it belongs beside. Curator status derives curated skills from applied Workshop create proposals and reports real usage. - Weekly review receives bounded `useCount` / `lastUsedDaysAgo` evidence, with prompt text stating usage supports keeping a procedure and never alone justifies a drop. - State schema 10 drops `skill_lifecycle` and `skill_workshop_proposal_origin_runs`. Previously archived skills return to the active collection, where review judges them by content; the migration logs how many. Reconcile now clears usage only for skills it actually drops. - `skills.curator.pin`/`unpin`/`restore` stay registered for existing clients but fail with an explicit retirement message instead of silently doing nothing. Retirement code moves to openclaw-state-db-table-retirements.ts to keep the schema-repair module under max-lines; that split is a pure relocation. Production delta is +23 raw: about -46 for the change itself, +44 for the file split, +25 for the ratchet fix in the previous commit.
1 parent 84b9f1e commit 7b2affc

49 files changed

Lines changed: 1292 additions & 919 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/macos/Tests/OpenClawIPCTests/PortGuardianRecordStoreTests.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ struct PortGuardianRecordStoreTests {
568568
let fixture = try Self.fixture()
569569
defer { fixture.cleanup() }
570570

571-
for version in [4, 5, 6, 7, 8, 9, 10] {
571+
for version in [4, 5, 6, 7, 8, 9, 10, 11] {
572572
let databaseURL = fixture.root.appendingPathComponent("supported-v\(version).sqlite")
573573
try Self.seedVersionedPortGuardianDatabase(databaseURL, schemaVersion: version)
574574
let store = try PortGuardianRecordStore(databaseURL: databaseURL)
@@ -580,7 +580,7 @@ struct PortGuardianRecordStoreTests {
580580
#expect(try store.records() == [record])
581581
}
582582

583-
for version in [11, 99] {
583+
for version in [12, 99] {
584584
let databaseURL = fixture.root.appendingPathComponent("newer-v\(version).sqlite")
585585
try Self.seedVersionedPortGuardianDatabase(databaseURL, schemaVersion: version)
586586
#expect(throws: PortGuardianStoreError.self) {

‎apps/shared/OpenClawKit/Sources/OpenClawNativeState/OpenClawNativeStateSQLite.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public enum OpenClawNativeStateSQLiteValueType: Equatable, Sendable {
3737
/// One recursive connection lock serializes transactions and statement access.
3838
public final class OpenClawNativeStateSQLite: @unchecked Sendable {
3939
// Keep aligned with OPENCLAW_STATE_SCHEMA_VERSION. Native clients never upgrade this database.
40-
private static let maximumSupportedSchemaVersion: Int64 = 10
40+
private static let maximumSupportedSchemaVersion: Int64 = 11
4141
private static let defaultBusyTimeoutMilliseconds: Int32 = 5000
4242

4343
private struct SchemaObject: Hashable {

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15549,6 +15549,8 @@ public struct SkillsCuratorStatusResult: Codable, Sendable {
1554915549
public let lastattemptatms: AnyCodable
1555015550
public let lastsuccessatms: AnyCodable
1555115551
public let lasterror: AnyCodable
15552+
public let collectionreview: [String: AnyCodable]?
15553+
public let experiencereview: [String: AnyCodable]?
1555215554
public let counts: [String: AnyCodable]
1555315555
public let skills: [SkillsCuratorActionResult]
1555415556
public let overlaps: [[String: AnyCodable]]
@@ -15557,13 +15559,17 @@ public struct SkillsCuratorStatusResult: Codable, Sendable {
1555715559
lastattemptatms: AnyCodable,
1555815560
lastsuccessatms: AnyCodable,
1555915561
lasterror: AnyCodable,
15562+
collectionreview: [String: AnyCodable]? = nil,
15563+
experiencereview: [String: AnyCodable]? = nil,
1556015564
counts: [String: AnyCodable],
1556115565
skills: [SkillsCuratorActionResult],
1556215566
overlaps: [[String: AnyCodable]])
1556315567
{
1556415568
self.lastattemptatms = lastattemptatms
1556515569
self.lastsuccessatms = lastsuccessatms
1556615570
self.lasterror = lasterror
15571+
self.collectionreview = collectionreview
15572+
self.experiencereview = experiencereview
1556715573
self.counts = counts
1556815574
self.skills = skills
1556915575
self.overlaps = overlaps
@@ -15573,6 +15579,8 @@ public struct SkillsCuratorStatusResult: Codable, Sendable {
1557315579
case lastattemptatms = "lastAttemptAtMs"
1557415580
case lastsuccessatms = "lastSuccessAtMs"
1557515581
case lasterror = "lastError"
15582+
case collectionreview = "collectionReview"
15583+
case experiencereview = "experienceReview"
1557615584
case counts
1557715585
case skills
1557815586
case overlaps

‎docs/cli/skills.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ Notes:
151151
| `curator --json` | Accepted before or after a Curator leaf command, for example `curator --json status` or `curator status --json`. |
152152
| `list` | Default action when no subcommand is provided. |
153153
| `list`/`info`/`check` output | Rendered output goes to stdout. With `--json`, the machine-readable payload stays on stdout for pipes and scripts. |
154-
| `curator status --json` | Returns legacy age-based lifecycle state written by older releases. Weekly collection review does not use this state. |
154+
| `curator status --json` | Reports live Workshop skill usage recorded from trusted `skill.used` events and the latest collection and experience review outcomes per workspace. |
155+
| `curator pin`/`unpin`/`restore` | Retired commands remain registered but return an error explaining that weekly collection review manages the skill collection. |
155156

156157
Community ClawHub skill installs and updates check trust before downloading.
157158
Versioned community archive releases use exact-release trust metadata.

‎docs/reference/database-schemas.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ Version 3 was an unshipped development step folded into version 4.
127127
| 8 | Cloud-worker placement execution modes and mode-aware turn claims | Unreleased |
128128
| 9 | In-root agent database registry paths stored relative to the state directory | Unreleased |
129129
| 10 | Six dead tables retired (agent_model_catalogs, android_notification_recent_packages, command_log_entries, diagnostic_stability_bundles, media_blobs, model_capability_cache) | Unreleased |
130+
| 11 | Legacy skill curator lifecycle table and never-read proposal origin-run projection retired | Unreleased |
131+
132+
### State schema 11
133+
134+
Schema 11 removes the `skill_lifecycle` and `skill_workshop_proposal_origin_runs` tables. Archived-skill lifecycle state is discarded during the upgrade: previously archived Workshop skills return to the active collection, where weekly collection review judges them by content. The origin-run rows were a never-read projection; canonical proposal provenance stays in `skill_workshop_proposals.record_json`. Recorded skill usage and collection-review state are preserved.
130135

131136
### State schema 9
132137

@@ -183,6 +188,60 @@ The general procedure is:
183188
3. Set `PRAGMA user_version` and `schema_meta.schema_version` to the target version.
184189
4. Run the target release's full database verification before starting the Gateway.
185190

191+
### Example: state schema 11 to 10
192+
193+
Schema 11 removed the retired skill lifecycle table and the never-read proposal
194+
origin-run projection. A schema 10 build still requires both canonical tables, so
195+
a manual downgrade must recreate their exact empty schemas and lifecycle indexes
196+
before lowering the version.
197+
198+
Run equivalent SQL against the global state database after inspecting the exact
199+
schema that wrote it:
200+
201+
```sql
202+
BEGIN IMMEDIATE;
203+
204+
CREATE TABLE skill_lifecycle (
205+
skill_file TEXT NOT NULL PRIMARY KEY,
206+
skill_key TEXT NOT NULL,
207+
skill_name TEXT NOT NULL,
208+
state TEXT NOT NULL CHECK (state IN ('active', 'stale', 'archived')),
209+
pinned INTEGER NOT NULL DEFAULT 0,
210+
state_changed_at_ms INTEGER NOT NULL,
211+
created_at_ms INTEGER NOT NULL,
212+
archived_reason TEXT
213+
) STRICT;
214+
215+
CREATE INDEX idx_skill_lifecycle_key
216+
ON skill_lifecycle(skill_key, skill_file);
217+
218+
CREATE INDEX idx_skill_lifecycle_state
219+
ON skill_lifecycle(state, skill_file);
220+
221+
CREATE TABLE skill_workshop_proposal_origin_runs (
222+
proposal_id TEXT NOT NULL,
223+
run_id TEXT NOT NULL,
224+
position INTEGER NOT NULL,
225+
mutation_count INTEGER NOT NULL CHECK (mutation_count > 0),
226+
PRIMARY KEY (proposal_id, run_id),
227+
FOREIGN KEY (proposal_id) REFERENCES skill_workshop_proposals(proposal_id) ON DELETE CASCADE
228+
) STRICT;
229+
230+
PRAGMA user_version = 10;
231+
UPDATE schema_meta
232+
SET schema_version = 10,
233+
updated_at = unixepoch('now') * 1000
234+
WHERE meta_key = 'primary';
235+
236+
COMMIT;
237+
```
238+
239+
Both recreated tables start empty. The upgrade discarded archived-skill
240+
lifecycle state, so those skills returned to the active collection and a manual
241+
downgrade cannot recover their previous archived state. Proposal origin-run
242+
rows were never read; authoritative provenance remains in each proposal's
243+
`record_json`. A botched downgrade means restore from the verified backup.
244+
186245
### Example: state schema 10 to 9
187246

188247
Schema 10 removed six dead shared-state tables. A schema 9 build still requires those canonical tables and indexes, so a manual downgrade must recreate their exact empty schemas before lowering the version.

‎docs/tools/self-learning.md‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,15 @@ with model fallbacks disabled. Provider pricing and data-handling terms apply to
211211
the additional run.
212212

213213
Weekly collection review also uses the configured agent model. It receives the
214-
names, descriptions, and ownership state of eligible workspace skills, then reads each
215-
skill it intends to change before one atomic call listing only changes. Disabled and
216-
agent-filtered skills stay untouched. Shared workspaces use the union of each
217-
agent's allowed skills only when provider, model, and resolved auth identity
218-
match. Reconciliation must leave every sharing agent at least one visible skill.
219-
It has no message tool or general agent tools. Skill bodies are treated as
214+
names, descriptions, ownership state, and available usage counts and last-used
215+
recency of eligible workspace skills, then reads each skill it intends to change
216+
before one atomic call listing only changes. Usage is supporting evidence: heavy
217+
use favors preserving a skill's procedure, while no recorded use alone never
218+
justifies dropping it. Disabled and agent-filtered skills stay untouched. Shared
219+
workspaces use the union of each agent's allowed skills only when provider,
220+
model, and resolved auth identity match. Reconciliation must leave every
221+
sharing agent at least one visible skill. It has no message tool or general
222+
agent tools. Skill bodies are treated as
220223
untrusted evidence, not as instructions. A persisted per-workspace attempt time
221224
prevents Gateway restarts from repeating a failed or successful review within 7 days. The
222225
foreground agent can restore the one retained collection backup when asked to
@@ -299,7 +302,9 @@ Check the following:
299302
An eligible experience review can still abstain. No proposal is the expected
300303
result when the evidence does not clear the reusable-procedure bar.
301304
Use `openclaw skills curator status` to inspect the last collection and
302-
experience review outcomes.
305+
experience review outcomes alongside live skill usage. Age-based curation is
306+
retired; the `curator pin`, `unpin`, and `restore` commands return an error
307+
explaining that weekly collection review manages the skill collection.
303308

304309
### Doctor reports that Workshop is hidden
305310

‎docs/tools/skill-workshop.md‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ skill created during collection review is recorded as an automatically applied
7272
`create` proposal, which makes that directory Workshop-owned. Disabled and
7373
agent-filtered skills stay untouched.
7474

75+
Recorded usage counts and last-used recency are supporting evidence, not an
76+
age-based lifecycle: heavy use favors preserving a skill's procedure, while no
77+
recorded use alone never justifies removing it.
78+
7579
Skills that predate ownership tracking, including skills that earlier reconcile
7680
runs created directly, have no applied `create` proposal. Skill Workshop
7781
intentionally classifies them as user-authored and read-only. It manages only
@@ -420,9 +424,12 @@ Proposal descriptions are always capped at 160 bytes, independent of
420424
| `skills.curator.unpin` | `operator.admin` |
421425
| `skills.curator.restore` | `operator.admin` |
422426

423-
`skills.curator.status` also reports the latest collection and experience review
424-
outcome per workspace. The other curator methods manage lifecycle state written
425-
by older releases. Weekly review does not use age, pin, or overlap state.
427+
`skills.curator.status` reports live skill usage recorded from trusted
428+
`skill.used` events, plus the latest collection and experience review outcomes
429+
per workspace. Age-based skill lifecycle curation is retired.
430+
`skills.curator.pin`, `skills.curator.unpin`, and `skills.curator.restore` remain
431+
registered for existing clients, but always return an error explaining that the
432+
weekly collection review now manages the skill collection.
426433

427434
`requestRevision` is Gateway-only (no CLI or agent-tool equivalent): it
428435
forwards free-text revision instructions to the owning agent's chat session
@@ -450,8 +457,9 @@ proposals.
450457

451458
Default state directory: `~/.openclaw`.
452459

453-
- `state/openclaw.sqlite`: canonical proposal records, the active generation
454-
reference, lifecycle status, origin attribution, and apply rollback metadata.
460+
- `state/openclaw.sqlite`: canonical proposal records and provenance, the active
461+
generation reference, proposal status, recorded skill usage, collection and
462+
experience review outcomes, and apply rollback metadata.
455463
- Each generation contains one `PROPOSAL.md` and all of that revision's support
456464
files. Revision publication never overwrites the active generation in place.
457465
- Generation files are flushed before publication. After the complete bundle is

‎extensions/voice-call/doctor-contract-api.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ function describeVoiceCallSchemaMigration(migration: OpenClawStateDatabaseSchema
146146
return "retired commitments storage -> removed table and indexes";
147147
case "state-table-retirement-v10":
148148
return "retired shared-state tables -> removed tables and indexes";
149+
case "state-table-retirement-v11":
150+
return "retired skill curator tables -> removed tables and indexes";
149151
case "worker-placement-execution-mode-v8":
150152
return "cloud worker placements -> execution-mode claims";
151153
case "operator-approvals-system-agent":

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2026.8.1",
44
"openclaw": {
55
"schemaVersions": {
6-
"state": 10,
6+
"state": 11,
77
"agent": 17
88
}
99
},

‎packages/gateway-protocol/src/schema/agents-models-skills.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ModelsProbeResultSchema,
1515
SkillProposalEvaluationSchema,
1616
SkillProposalLifecycleEventSchema,
17+
SkillsCuratorStatusResultSchema,
1718
SkillsDetailResultSchema,
1819
SkillsProposalEvaluateParamsSchema,
1920
SkillsProposalEvaluateResultSchema,
@@ -546,6 +547,46 @@ describe("SkillsProposalInspectResultSchema", () => {
546547
});
547548
});
548549

550+
describe("SkillsCuratorStatusResultSchema", () => {
551+
it("accepts typed collection and experience outcomes while rejecting invalid review records", () => {
552+
const legacyResult = {
553+
lastAttemptAtMs: 100,
554+
lastSuccessAtMs: 101,
555+
lastError: null,
556+
counts: { active: 1, stale: 0, archived: 0 },
557+
skills: [],
558+
overlaps: [],
559+
};
560+
const result = {
561+
...legacyResult,
562+
collectionReview: {
563+
workspace: { attemptedAtMs: 100, succeededAtMs: 101 },
564+
},
565+
experienceReview: {
566+
workspace: {
567+
attemptedAtMs: 102,
568+
outcome: "proposed",
569+
proposalId: "proposal-1",
570+
usage: { inputTokens: 40, cachedInputTokens: 20, outputTokens: 10 },
571+
},
572+
},
573+
};
574+
575+
expectAccepted(SkillsCuratorStatusResultSchema, result, legacyResult);
576+
expectRejected(
577+
SkillsCuratorStatusResultSchema,
578+
{
579+
...result,
580+
collectionReview: { workspace: { attemptedAtMs: 100, unexpected: true } },
581+
},
582+
{
583+
...result,
584+
experienceReview: { workspace: { attemptedAtMs: 102, outcome: "archived" } },
585+
},
586+
);
587+
});
588+
});
589+
549590
describe("SkillProposalEvaluationSchema", () => {
550591
const completedOutcome = {
551592
pluginId: "quality-plugin",

0 commit comments

Comments
 (0)