feat: before_install → POST /install-scan (terminal, fail-closed)#13
Merged
Conversation
Implement the last unimplemented adapter hook. before_install maps the
OpenClaw install event to POST /install-scan and enforces the decision:
- allow → {} (proceed)
- deny → { block: true, blockReason: feedback.message ?? reason ?? fallback }
- client { ok: false } (unreachable/timeout/5xx/malformed) → fail closed (block)
Terminal call — no /audit follow-up, no correlation threading.
Request-body mapping:
- package.source ← normalized request.kind (npm/git/archive/file/dir/skill),
NOT targetType (kind ≠ provenance; supply-chain rules match on origin)
- package.name ← plugin.packageName ?? targetName (true package identity)
- package.version ← plugin.version; package.spec ← request.requestedSpecifier
(omitted, not undefined, under exactOptionalPropertyTypes)
- metadata: mode, target_type, builtin_scan { critical, warn, info }
(OpenClaw's own static-scan summary, forwarded as context)
A default switch arm with a `never` binding makes future decision-enum
drift a compile error while staying fail-closed at runtime.
Re-exports PluginInstallRequestKind from the SDK types barrel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
before_install→POST /install-scan— the last unimplemented adapter hook (issue #11, Part B). Maps the OpenClaw install event to the scan endpoint and enforces the decision, fail-closed.Behavior
allow→{}(proceed)deny→{ block: true, blockReason: feedback.message ?? reason ?? 'Blocked by Helio' }{ ok: false }(unreachable / timeout / 5xx / malformed) → fail closed (block)/auditfollow-up, no correlation/evaluation_idthreading.Request-body mapping (per plan §B.2)
package.sourcerequest.kind(npm/git/archive/file/dir/skill) — nottargetType(kind ≠ provenance; supply-chain rules match on origin)package.nameplugin?.packageName ?? targetName(true package identity, universal fallback)package.versionplugin?.version(omitted when absent)package.specrequest.requestedSpecifier(omitted when absent)metadatamode,target_type,builtin_scan { critical, warn, info }(OpenClaw's own scan summary, forwarded as context)Optional fields are conditionally spread, not set to
undefined(exactOptionalPropertyTypes).Notes
defaultswitch arm with aneverbinding turns any future decision-enum drift into a compile error, while staying fail-closed at runtime.PluginInstallRequestKindfrom the SDK types barrel.Verification
pnpm verifygreen: format ✓, lint ✓, typecheck (0 errors) ✓, 185 tests pass, build ✓. 14 new unit tests cover the happy path, all sixkind→sourcemappings,packageNamefallback, deny via feedback/reason/default, update-mode + errored-scan metadata forwarding, and fail-closed unavailability.