feat(plugin-state): add registerIfAbsent keyed store#77135
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: not applicable. this is an additive API feature PR, not a bug report. Current main source confirms the method is absent, and the PR diff adds the method plus focused coverage. Next step before merge Security Review detailsBest possible solution: Land one approved atomic keyed-store claim primitive with docs, changelog, and focused tests, then handle BlueBubbles and Feishu consumer migrations separately after their retry semantics are settled. Do we have a high-confidence way to reproduce the issue? Not applicable; this is an additive API feature PR, not a bug report. Current main source confirms the method is absent, and the PR diff adds the method plus focused coverage. Is this the best way to solve the issue? Yes, with maintainer approval: the primitive-only shape is a narrow maintainable way to unblock dedupe consumers and avoids the BlueBubbles consumer semantic blocker found on #77134. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 361737d1f1cb. Re-review progress:
|
Summary
registerIfAbsent(key, value, opts?)toPluginStateKeyedStore, backed by aBEGIN IMMEDIATESQLite transaction andINSERT OR IGNORE, with tests for duplicate, expiry, isolation, eviction, limits, and parallel claims.registerupsert semantics remain unchanged.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
N/A
Regression Test Plan (if applicable)
src/plugin-state/plugin-state-store.test.ts,src/plugin-state/plugin-state-store.runtime.test.ts,src/plugin-state/plugin-state-store.e2e.test.tsUser-visible / Behavior Changes
Bundled plugins can now call
api.runtime.state.openKeyedStore(...).registerIfAbsent(...)for atomic keyed-store dedupe claims.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
registerIfAbsentto the state-store type and implementation.Expected
registerIfAbsentreturnstrueonly when the claim is inserted andfalsefor an existing live key without mutating it.Actual
Evidence
Human Verification (required)
What I personally verified:
pnpm exec oxfmt --check --threads=1 src/plugin-state/plugin-state-store.ts src/plugin-state/plugin-state-store.sqlite.ts src/plugin-state/plugin-state-store.types.ts src/plugin-state/plugin-state-store.test.ts src/plugin-state/plugin-state-store.e2e.test.ts src/plugin-state/plugin-state-store.runtime.test.ts docs/plugins/sdk-runtime.md CHANGELOG.mdpnpm test src/plugin-state/plugin-state-store.test.ts src/plugin-state/plugin-state-store.runtime.test.ts src/plugin-state/plugin-state-store.e2e.test.ts -- --reporter=verbosepnpm test src/plugin-state/plugin-state-store.permissions.test.ts -- --reporter=verbosepnpm tsgo:corepnpm tsgo:core:testpnpm plugin-sdk:api:checkgit diff --checkEdge cases checked:
createdAt, or TTL.What I did not verify:
pnpm check:changed/full suite; this PR used targeted local proof for the touched state-store seam.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations