@f4bioo/berry-shield 2026.3.3-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CONTRIBUTING.md +32 -0
  2. package/LICENSE +201 -0
  3. package/README.md +251 -0
  4. package/SECURITY_AUDIT.md +96 -0
  5. package/docs/wiki/README.md +108 -0
  6. package/docs/wiki/decision/README.md +48 -0
  7. package/docs/wiki/decision/modes.md +176 -0
  8. package/docs/wiki/decision/patterns.md +137 -0
  9. package/docs/wiki/decision/posture.md +68 -0
  10. package/docs/wiki/deploy/README.md +51 -0
  11. package/docs/wiki/deploy/auditing.md +56 -0
  12. package/docs/wiki/deploy/build.md +92 -0
  13. package/docs/wiki/deploy/github-ci-cd.md +107 -0
  14. package/docs/wiki/deploy/installation.md +348 -0
  15. package/docs/wiki/engine/README.md +53 -0
  16. package/docs/wiki/engine/match-engine.md +91 -0
  17. package/docs/wiki/engine/performance.md +114 -0
  18. package/docs/wiki/engine/redaction.md +120 -0
  19. package/docs/wiki/layers/README.md +68 -0
  20. package/docs/wiki/layers/leaf.md +126 -0
  21. package/docs/wiki/layers/pulp.md +139 -0
  22. package/docs/wiki/layers/root.md +130 -0
  23. package/docs/wiki/layers/stem.md +139 -0
  24. package/docs/wiki/layers/thorn.md +139 -0
  25. package/docs/wiki/layers/vine.md +154 -0
  26. package/docs/wiki/operation/README.md +31 -0
  27. package/docs/wiki/operation/cli/README.md +122 -0
  28. package/docs/wiki/operation/cli/add.md +157 -0
  29. package/docs/wiki/operation/cli/help.md +83 -0
  30. package/docs/wiki/operation/cli/init.md +52 -0
  31. package/docs/wiki/operation/cli/list.md +78 -0
  32. package/docs/wiki/operation/cli/mode.md +93 -0
  33. package/docs/wiki/operation/cli/policy.md +202 -0
  34. package/docs/wiki/operation/cli/profile.md +98 -0
  35. package/docs/wiki/operation/cli/remove.md +96 -0
  36. package/docs/wiki/operation/cli/report.md +66 -0
  37. package/docs/wiki/operation/cli/reset.md +99 -0
  38. package/docs/wiki/operation/cli/rules.md +161 -0
  39. package/docs/wiki/operation/cli/status.md +103 -0
  40. package/docs/wiki/operation/cli/test.md +119 -0
  41. package/docs/wiki/operation/cli/toggle.md +90 -0
  42. package/docs/wiki/operation/cli/vine.md +193 -0
  43. package/docs/wiki/operation/web/README.md +27 -0
  44. package/docs/wiki/tutorials/README.md +40 -0
  45. package/docs/wiki/tutorials/audit-to-enforce-rollout.md +99 -0
  46. package/docs/wiki/tutorials/build-custom-rules.md +99 -0
  47. package/docs/wiki/tutorials/choose-profile.md +91 -0
  48. package/docs/wiki/tutorials/incident-triage-report.md +99 -0
  49. package/docs/wiki/tutorials/secure-session.md +115 -0
  50. package/docs/wiki/tutorials/tune-policy.md +111 -0
  51. package/openclaw.plugin.json +293 -0
  52. package/package.json +70 -0
@@ -0,0 +1,48 @@
1
+ ---
2
+ summary: "Decision reference index for Berry Shield mode logic, matching behavior, and security posture"
3
+ read_when:
4
+ - Reviewing how Berry Shield decides allow/block/redact outcomes
5
+ - Updating mode and policy behavior documentation
6
+ title: "Decision Reference"
7
+ ---
8
+
9
+ # `Decision reference`
10
+
11
+ This page is the entry point for Berry Shield decision logic documentation.
12
+ If decision behavior changes, update this index and linked pages.
13
+
14
+ ## Security posture snapshot
15
+
16
+ Berry Shield decision logic is strong at application-layer mitigation, but it is not host isolation.
17
+
18
+ Known constraints to keep in mind:
19
+ - Some protections depend on OpenClaw hook availability/invocation on the deployed runtime version.
20
+ - Context injection paths influence model behavior, but are not hard execution control.
21
+ - Persistence-time hooks can have timing gaps relative to in-turn model exposure.
22
+
23
+ See full posture and limits:
24
+ - [security posture](posture.md)
25
+
26
+ ## Decision pages
27
+
28
+ - [modes](modes.md) (audit/enforce behavior and relation to policy profile)
29
+ - [patterns](patterns.md) (pattern categories and matching pipeline)
30
+ - [security posture](posture.md) (scope boundaries and SDK constraints)
31
+
32
+ ## Decision flow (high-level)
33
+
34
+ 1. Incoming operation is intercepted by a layer.
35
+ 2. Relevant data is extracted for matching.
36
+ 3. Pattern/rule matching evaluates risk.
37
+ 4. Runtime mode and policy context determine outcome.
38
+ 5. Layer returns allow, block, redact, or audit event path.
39
+
40
+ ## Notes
41
+ - Decision docs must be aligned with runtime behavior, not intended behavior.
42
+ - Claims about security behavior must be scoped and evidence-based.
43
+
44
+ ---
45
+
46
+ ## Navigation
47
+ - [Back to Wiki Index](../README.md)
48
+ - [Back to Repository README](../../../README.md)
@@ -0,0 +1,176 @@
1
+ ---
2
+ summary: "Decision model for audit and enforce runtime behavior, and how mode interacts with profile/adaptive policy"
3
+ read_when:
4
+ - You need to reason about allow/block/redact outcomes
5
+ - You are validating audit vs enforce behavior in real runs
6
+ - You are debugging mismatches between expected and observed security outcomes
7
+ title: "modes"
8
+ ---
9
+
10
+ # `modes`
11
+
12
+ This page defines how Berry Shield runtime mode affects security decisions.
13
+
14
+ ## What this page defines
15
+
16
+ - What `audit` means in decision paths.
17
+ - What `enforce` means in decision paths.
18
+ - How mode differs from profile.
19
+ - How adaptive triggers interact with mode.
20
+ - Which outcomes to expect in common scenarios.
21
+
22
+ ## Mental model
23
+
24
+ Mode answers this question:
25
+
26
+ **After risk is detected, should the system only record intent, or actively mitigate?**
27
+
28
+ - `audit` is observation-first posture.
29
+ - `enforce` is mitigation-first posture.
30
+
31
+ Mode does not define how frequently policy text is injected into agent context.
32
+ That belongs to profile/adaptive policy behavior.
33
+
34
+ ## Decision order (runtime perspective)
35
+
36
+ 1. A layer intercepts an operation or message.
37
+ 2. The layer extracts match candidates (path, command, output text, etc.).
38
+ 3. Rule matching determines whether risk is present.
39
+ 4. Mode determines whether matched risk is recorded-only or actively mitigated.
40
+ 5. The layer emits decision outcomes (for example would_block, blocked, would_redact, redacted) according to mode and path.
41
+
42
+ ## Mode behavior
43
+
44
+ ### audit
45
+
46
+ In audit mode, risk matches are treated as observable events.
47
+
48
+ Expected behavior pattern:
49
+ - decision events are still produced and logged
50
+ - operation flow generally continues
51
+ - outputs generally remain unblocked by mode-level mitigation
52
+
53
+ Important clarification:
54
+ - audit is **shadow mode for block/redact mitigation paths**
55
+ - audit is **not** "plugin fully passive"
56
+ - policy-injection strategy (full/short/none) still follows profile/adaptive settings
57
+ - message hygiene guards can still run (for example stripping leaked `<berry_shield_policy>` snippets)
58
+
59
+ Audit mode is useful for:
60
+ - measuring policy impact before hard enforcement
61
+ - understanding false-positive surface
62
+ - collecting decision evidence for rule tuning
63
+
64
+ ### enforce
65
+
66
+ In enforce mode, risk matches are treated as active mitigation points.
67
+
68
+ Expected behavior pattern:
69
+ - risky operations may be denied before execution
70
+ - risky output may be redacted before delivery
71
+ - decision events reflect active mitigation outcomes
72
+
73
+ Enforce mode is useful for:
74
+ - production workloads
75
+ - safety-critical environments
76
+ - workflows where prevention is required, not only observation
77
+
78
+ ## Mode vs profile
79
+
80
+ Mode and profile solve different problems:
81
+
82
+ - Mode (`audit | enforce`) controls **mitigation posture** after risk is detected.
83
+ - Profile (`strict | balanced | minimal`) controls **policy-injection strategy** in agent context.
84
+
85
+ These controls are complementary:
86
+ - Changing profile does not change mode identity.
87
+ - Changing mode does not change profile strategy.
88
+
89
+ ## Adaptive trigger interaction
90
+
91
+ Adaptive triggers (for example denied-based escalation windows and stale-based reinjection windows) change policy-injection intensity over time.
92
+
93
+ They do not redefine runtime mode.
94
+
95
+ Practical implication:
96
+ - You can have `enforce + minimal` (active mitigation with quieter injection strategy).
97
+ - You can have `audit + strict` (strong policy-injection strategy with observation-first mitigation posture).
98
+
99
+ ## Layer mapping (mode behavior by layer)
100
+
101
+ ### Stem (security gate tool)
102
+ - audit: emits would_block events and allows flow to continue.
103
+ - enforce: emits blocked events and returns denied outcomes.
104
+
105
+ ### Thorn (before_tool_call hook)
106
+ - audit: emits would_block events and does not hard-block the call.
107
+ - enforce: emits blocked events and returns block response.
108
+
109
+ ### Vine (external-content trust guard)
110
+ - audit: records trust-risk outcomes as would_block without hard-block.
111
+ - enforce: can block sensitive actions when external-risk state is active.
112
+
113
+ ### Pulp (output scanner hooks)
114
+ - audit: emits would_redact events and preserves content for observation paths.
115
+ - enforce: emits redacted events and returns redacted content.
116
+
117
+ ### Message policy-block hygiene
118
+ - outgoing message sanitation may still strip leaked `<berry_shield_policy>` snippets as a hygiene guard.
119
+ - this is not equivalent to full secret redaction behavior.
120
+
121
+ ## Scenarios
122
+
123
+ ### Scenario A: mode=enforce, profile=balanced
124
+
125
+ - operation hits a risky match
126
+ - runtime can actively deny/redact
127
+ - policy injection follows balanced adaptive strategy
128
+
129
+ Use case: default recommended operational baseline.
130
+
131
+ ### Scenario B: mode=audit, profile=strict
132
+
133
+ - operation hits a risky match
134
+ - runtime records decision outcomes as audit evidence
135
+ - policy injection remains strong/explicit by profile strategy
136
+
137
+ Use case: pre-enforcement tuning with high policy visibility.
138
+
139
+ ### Scenario C: mode=enforce, profile=minimal
140
+
141
+ - operation hits a risky match
142
+ - runtime can still deny/redact
143
+ - policy injection stays low-noise unless adaptive triggers escalate
144
+
145
+ Use case: low-noise interaction with active safety barriers.
146
+
147
+ ## Limits and non-goals
148
+
149
+ - Mode behavior is constrained by available runtime hooks.
150
+ - Hook availability/timing can affect when mitigation is observable.
151
+ - Mode does not provide host-level sandboxing or kernel isolation.
152
+ - Mode should not be interpreted as complete exploit prevention.
153
+
154
+ ## See CLI
155
+
156
+ For operational command usage:
157
+ - [CLI mode command](../operation/cli/mode.md)
158
+ - [CLI status command](../operation/cli/status.md)
159
+ - [CLI profile command](../operation/cli/profile.md)
160
+ - [CLI policy command](../operation/cli/policy.md)
161
+ - [CLI vine command](../operation/cli/vine.md)
162
+
163
+ ## Related pages
164
+ - [decision index](README.md)
165
+ - [patterns](patterns.md)
166
+ - [security posture](posture.md)
167
+ - [stem layer](../layers/stem.md)
168
+ - [thorn layer](../layers/thorn.md)
169
+ - [vine layer](../layers/vine.md)
170
+ - [pulp layer](../layers/pulp.md)
171
+
172
+ ---
173
+
174
+ ## Navigation
175
+ - [Back to Decision Index](README.md)
176
+ - [Back to Wiki Index](../README.md)
@@ -0,0 +1,137 @@
1
+ ---
2
+ summary: "Decision reference for pattern categories and matching pipeline used by Berry Shield"
3
+ read_when:
4
+ - Reviewing how Berry Shield matches risk patterns
5
+ - Updating rule categories or matching behavior docs
6
+ title: "patterns"
7
+ ---
8
+
9
+ # `patterns`
10
+
11
+ Berry Shield decisions are driven by pattern matching.
12
+ This page explains the decision contract: what is matched, where rules come from, and how matches become runtime outcomes.
13
+
14
+ ## What this page defines
15
+
16
+ - Pattern families used by runtime decisions.
17
+ - Built-in versus custom rule sources.
18
+ - The matching pipeline from candidate extraction to allow/block/redact outcomes.
19
+ - Known limits so operators can tune with realistic expectations.
20
+
21
+ ## Pattern categories
22
+
23
+ ### Secret patterns
24
+ Detect credential-like material in text payloads (API keys, tokens, private keys, secrets).
25
+
26
+ Primary effect:
27
+ - feeds redaction-related paths (for example output scanning and input auditing)
28
+ - contributes to observation or sanitization outcomes depending on mode
29
+
30
+ ### PII patterns
31
+ Detect personally identifiable information markers in text payloads.
32
+
33
+ Primary effect:
34
+ - feeds redaction-related paths
35
+ - contributes to privacy-preserving output behavior and audit signals
36
+
37
+ ### Sensitive file patterns
38
+ Detect sensitive file paths or file references in operation targets.
39
+
40
+ Primary effect:
41
+ - feeds operation-gating paths
42
+ - contributes to observation or deny outcomes depending on mode
43
+
44
+ ### Destructive command patterns
45
+ Detect destructive command intent before execution (for example unsafe deletion/format/destructive shell patterns).
46
+
47
+ Primary effect:
48
+ - feeds pre-execution safety gates
49
+ - contributes to observation or deny outcomes depending on mode
50
+
51
+ ## Rule sources
52
+
53
+ ### Built-in rules
54
+ Bundled with Berry Shield and loaded by default.
55
+
56
+ Operational meaning:
57
+ - baseline security coverage exists without custom configuration
58
+ - built-in coverage should be treated as starter baseline, not complete environment-specific policy
59
+
60
+ ### Custom rules
61
+ User-defined patterns persisted via CLI operations.
62
+
63
+ Operational meaning:
64
+ - used to close environment-specific gaps
65
+ - merged into runtime matching pipeline with built-in rules
66
+
67
+ ## Matching pipeline (runtime view)
68
+
69
+ 1. Layer intercepts a candidate event (tool call, tool result, outgoing message, input message).
70
+ 2. Layer extracts matchable candidate data (command text, path, content payload).
71
+ 3. Category-specific patterns are evaluated against candidate data.
72
+ 4. Match result is passed into layer decision logic.
73
+ 5. Mode (`audit` vs `enforce`) maps match result to observation-only or active mitigation outcome.
74
+ 6. Runtime emits structured event outcome for reporting.
75
+
76
+ ## Built-in + custom merge behavior
77
+
78
+ At runtime, Berry composes effective pattern sets by category:
79
+ - redaction patterns: built-in secret + built-in PII + custom secret-like additions
80
+ - file patterns: built-in sensitive-file + custom sensitive-file additions
81
+ - command patterns: built-in destructive-command + custom destructive-command additions
82
+
83
+ The runtime uses cached compiled sets for synchronous checks.
84
+ Rule reload refreshes cache from persisted custom rules.
85
+
86
+ ## How patterns map to layers
87
+
88
+ - Operation-gating patterns (sensitive files, destructive commands) are consumed by operation layers.
89
+ - Redaction patterns (secrets, PII) are consumed by content-scanning layers.
90
+ - External-origin trust signals are consumed by Vine for prompt-injection hardening.
91
+
92
+ See layer details:
93
+ - [See layer Stem](../layers/stem.md)
94
+ - [See layer Thorn](../layers/thorn.md)
95
+ - [See layer Vine](../layers/vine.md)
96
+ - [See layer Pulp](../layers/pulp.md)
97
+ - [See layer Leaf](../layers/leaf.md)
98
+
99
+ ## Practical outcomes by mode
100
+
101
+ When a match is found:
102
+ - in `audit`, runtime usually records intent without heavy mitigation
103
+ - in `enforce`, runtime may actively deny operations or sanitize content and emit mitigation outcomes
104
+
105
+ Mode semantics are defined in:
106
+ - [modes](modes.md)
107
+
108
+ ## Tuning guidance
109
+
110
+ Use built-in rules as default baseline, then tune in this order:
111
+ 1. Measure with `audit` to observe match volume and false-positive surface.
112
+ 2. Add targeted custom rules for environment-specific secrets/paths/commands.
113
+ 3. Validate expected outcomes in `enforce` before production rollout.
114
+
115
+ ## Limits and non-goals
116
+
117
+ - Pattern matching is heuristic, not complete semantic understanding.
118
+ - Coverage can vary by platform path conventions and tool argument formats.
119
+ - Some bypass forms depend on how candidate text is extracted by each layer.
120
+ - Pattern matching does not replace host sandboxing, IAM hardening, or network controls.
121
+
122
+ ## See CLI
123
+
124
+ For pattern lifecycle operations, see:
125
+ - [CLI add command](../operation/cli/add.md)
126
+ - [CLI list command](../operation/cli/list.md)
127
+ - [CLI test command](../operation/cli/test.md)
128
+
129
+ ## Related pages
130
+ - [decision index](README.md)
131
+ - [modes](modes.md)
132
+
133
+ ---
134
+
135
+ ## Navigation
136
+ - [Back to Decision Index](README.md)
137
+ - [Back to Wiki Index](../README.md)
@@ -0,0 +1,68 @@
1
+ ---
2
+ summary: "Security posture reference for Berry Shield scope boundaries and SDK dependency constraints"
3
+ read_when:
4
+ - Reviewing what Berry Shield does and does not protect
5
+ - Assessing SDK/runtime constraints that affect enforcement confidence
6
+ title: "security posture"
7
+ ---
8
+
9
+ # `security posture`
10
+
11
+ Berry Shield is a session-level security layer inside OpenClaw plugin boundaries.
12
+
13
+ ## Scope boundaries
14
+
15
+ ### In scope
16
+ - prompt and tool-level policy guidance for agent behavior
17
+ - pre-execution checks for risky operations
18
+ - output redaction and audit event generation
19
+
20
+ ### Out of scope
21
+ - kernel-level sandboxing
22
+ - host-level container isolation
23
+ - operating-system exploit mitigation
24
+
25
+ Berry Shield must be understood as application-layer protection, not host isolation.
26
+
27
+ ## Dependency on OpenClaw hooks
28
+
29
+ Berry Shield behavior depends on hook surfaces provided by OpenClaw runtime.
30
+ Changes in hook timing, propagation, or runner behavior can change effective security posture.
31
+
32
+ ## Known host constraints (OpenClaw-side)
33
+
34
+ - Hook definition is not the same as effective runtime invocation.
35
+ Verify behavior on the deployed OpenClaw build/version, not only by reading hook types.
36
+ - `before_agent_start` is instruction-level influence on context, not hard runtime execution control.
37
+ - `tool_result_persist` runs at persistence time; this can create timing gaps relative to what the model already saw in the same turn.
38
+ - Hook execution semantics (sync-only paths, void vs modifying hooks) are host constraints and can weaken assurance if misunderstood.
39
+
40
+ ## Practical posture guidance
41
+
42
+ ### Preferred baseline
43
+ - mode set to enforce for active mitigation behavior
44
+ - policy/profile configured intentionally for the deployment context
45
+ - status and report reviewed during validation cycles
46
+
47
+ ## See CLI
48
+
49
+ For posture verification operations, see:
50
+ - [CLI status command](../operation/cli/status.md)
51
+ - [CLI report command](../operation/cli/report.md)
52
+
53
+ ## Known risk classes
54
+
55
+ - prompt-level override attempts against weak policy instruction context
56
+ - bypass attempts through alternate tool paths when coverage is incomplete
57
+ - operational drift when mode/policy differs from expected deployment baseline
58
+ - runtime-version drift where expected hook behavior differs from deployed host behavior
59
+
60
+ ## Related pages
61
+ - [decision index](README.md)
62
+ - [modes](modes.md)
63
+
64
+ ---
65
+
66
+ ## Navigation
67
+ - [Back to Decision Index](README.md)
68
+ - [Back to Wiki Index](../README.md)
@@ -0,0 +1,51 @@
1
+ ---
2
+ summary: "Deployment index for installation tracks, local build flow, and GitHub CI/CD release flow"
3
+ read_when:
4
+ - You need to install Berry Shield in a real environment
5
+ - You need to choose between source-truth and release-truth deployment
6
+ - You need pre-release validation and audit gates
7
+ - You need the official GitHub release workflow (prepare-release/publish)
8
+ title: "Deploy Reference"
9
+ ---
10
+
11
+ # `Deploy reference`
12
+
13
+ This domain explains how to deploy Berry Shield safely and repeatably.
14
+ It covers installation tracks, local build gates, GitHub release workflow, and validation flow.
15
+
16
+ ## Deployment tracks
17
+
18
+ Berry supports two operational tracks:
19
+
20
+ - Source-truth track: run exactly what is in this repository (build from source).
21
+ - Release-truth track: consume published package artifact from the package registry.
22
+
23
+ Choose source-truth when you need repository-level auditability; choose release-truth when you need immutable package consumption.
24
+
25
+ ## Pages
26
+
27
+ - [installation](installation.md): installation paths and post-install verification
28
+ - [build](build.md): local development build and preflight gates
29
+ - [github-ci-cd](github-ci-cd.md): official GitHub Actions release workflow (`normal` and `reconcile`)
30
+ - [auditing](auditing.md): wiki sanity and documentation quality gates
31
+
32
+ ## Recommended sequence (local -> CI/CD)
33
+
34
+ 1. Choose installation track (source-truth or release-truth).
35
+ 2. Validate local quality gates using [build](build.md).
36
+ 3. Create release branch and PR via [github-ci-cd](github-ci-cd.md) (`prepare-release`).
37
+ 4. Merge release PR into `master`.
38
+ 5. Run publish workflow in [github-ci-cd](github-ci-cd.md) (`normal` or `reconcile`).
39
+ 6. Verify runtime mode/status/report.
40
+
41
+ ## Related pages
42
+ - [wiki index](../README.md)
43
+ - [operation index](../operation/README.md)
44
+ - [CLI init](../operation/cli/init.md)
45
+ - [CLI status](../operation/cli/status.md)
46
+
47
+ ---
48
+
49
+ ## Navigation
50
+ - [Back to Wiki Index](../README.md)
51
+ - [Back to Repository README](../../../README.md)
@@ -0,0 +1,56 @@
1
+ ---
2
+ summary: "Documentation sanity gate reference for deploy and release workflows"
3
+ read_when:
4
+ - You are validating wiki quality before release
5
+ - You need to understand warning vs error behavior in doc sanity
6
+ - You are enforcing documentation consistency gates
7
+ title: "auditing"
8
+ ---
9
+
10
+ # `Auditing and sanity`
11
+
12
+ Berry wiki quality is validated by the doc sanity script.
13
+ This gate is part of release validation flow and should be run before shipping documentation changes.
14
+
15
+ ## Main command
16
+
17
+ ```bash
18
+ npm run wiki:claim
19
+ ```
20
+ Result: Runs documentation sanity checks and reports warnings/errors.
21
+
22
+ ## What the sanity gate checks
23
+
24
+ - Symbol/reference integrity against code exports.
25
+ - Link validity and case-sensitive path correctness.
26
+ - Claim/evidence consistency checks.
27
+ - Tone and density warnings for documentation quality.
28
+ - CLI contract checks for command-block formatting in markdown.
29
+
30
+ ## Warning vs error behavior
31
+
32
+ - Warnings report quality issues but do not fail process exit by default.
33
+ - Errors trigger non-zero exit and fail the gate.
34
+
35
+ Operational implication:
36
+ - Release pipelines should treat errors as blocking.
37
+ - Teams may choose stricter policy for warnings at final review stage.
38
+
39
+ ## Recommended workflow
40
+
41
+ 1. Edit docs in focused scope.
42
+ 2. Run sanity gate.
43
+ 3. Fix blocking errors first.
44
+ 4. Resolve tone and consistency warnings according to team policy.
45
+
46
+ ## Related pages
47
+ - [deploy index](README.md)
48
+ - [build](build.md)
49
+ - [installation](installation.md)
50
+
51
+ ---
52
+
53
+ ## Navigation
54
+ - [Back to Deploy Index](README.md)
55
+ - [Back to Wiki Index](../README.md)
56
+
@@ -0,0 +1,92 @@
1
+ ---
2
+ summary: "Local build and validation reference for Berry Shield development workflow"
3
+ read_when:
4
+ - You are preparing a local development artifact
5
+ - You need to run local quality gates before opening a PR
6
+ - You are validating package scripts on your workstation
7
+ title: "build"
8
+ ---
9
+
10
+ # `Build (Local Dev)`
11
+
12
+ Berry local build flow is script-driven from package.json.
13
+ This page documents workstation commands only (not GitHub release workflows).
14
+
15
+ ## Core build commands
16
+
17
+ ### Build artifact
18
+
19
+ ```bash
20
+ npm run build
21
+ ```
22
+ Expected: `dist/index.js` is generated from `src/index.ts`.
23
+
24
+ ### Type checking
25
+
26
+ ```bash
27
+ npm run typecheck
28
+ ```
29
+ Result: TypeScript graph is validated without emitting files.
30
+
31
+ ### Test suite
32
+
33
+ ```bash
34
+ npm run test
35
+ ```
36
+ Result: Vitest suite executes and reports pass/fail status.
37
+
38
+ ## Local pre-release gates
39
+
40
+ ### Preflight gate
41
+
42
+ ```bash
43
+ npm run release:preflight
44
+ ```
45
+ Result: Runs build, typecheck, `vitest` on `__tests__`, and wiki sanity gate.
46
+
47
+ ## What local preflight validates
48
+
49
+ - Build success.
50
+ - Type safety.
51
+ - Test suite status.
52
+ - Wiki sanity gate status (`npm run wiki:claim`).
53
+
54
+ ## Practical use guidance
55
+
56
+ - For normal development deploy checks, run build + typecheck + test.
57
+ - For release candidate verification, run release:preflight.
58
+ - For GitHub release workflows (`prepare-release` / `publish`), see `github-ci-cd.md`.
59
+
60
+ ## Common failure: compatibility policy test
61
+
62
+ Symptom:
63
+ - `__tests__/compat-policy.test.ts` fails after local SDK updates.
64
+
65
+ Why:
66
+ - local `node_modules/openclaw` version does not satisfy `package.json` peer range, or
67
+ - peer range is not aligned with `COMPAT_POLICY` constants.
68
+
69
+ How to fix:
70
+ 1. Check local SDK version:
71
+ ```bash
72
+ npm ls openclaw
73
+ ```
74
+ Expected: installed version satisfies `peerDependencies.openclaw`.
75
+
76
+ 2. Reinstall dependencies if local graph is stale:
77
+ ```bash
78
+ npm install
79
+ ```
80
+ Expected: dependency graph is refreshed and tests can validate policy contract.
81
+
82
+ ## Related pages
83
+ - [deploy index](README.md)
84
+ - [installation](installation.md)
85
+ - [auditing](auditing.md)
86
+ - [GitHub CI/CD release flow](github-ci-cd.md)
87
+
88
+ ---
89
+
90
+ ## Navigation
91
+ - [Back to Deploy Index](README.md)
92
+ - [Back to Wiki Index](../README.md)