contextos-agents 2.3.0 → 2.3.2
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.
- package/.agents/adapters/cursor/export.js +3 -27
- package/.agents/adapters/gemini/export.js +5 -7
- package/.agents/adapters/shared.js +14 -1
- package/.agents/adapters/zed/export.js +4 -16
- package/.agents/compiled/registry.v2.json +33 -33
- package/.agents/compiled/registry.v2.sha256 +1 -1
- package/.agents/compiler/manifest-compiler.js +8 -5
- package/.agents/core/skills/context-manager/EXAMPLES.md +5 -17
- package/.agents/core/skills/context-manager/SKILL.md +10 -100
- package/.agents/core/skills/context-manager/TROUBLESHOOTING.md +6 -6
- package/.agents/core/skills/context-manager/VALIDATION.json +115 -4
- package/.agents/core/skills/context-manager/references/context-rules.md +3 -57
- package/.agents/core/skills/context-manager/skill.yaml +1 -3
- package/.agents/core/skills/context-os/EXAMPLES.md +25 -15
- package/.agents/core/skills/context-os/SKILL.md +12 -135
- package/.agents/core/skills/context-os/TROUBLESHOOTING.md +11 -6
- package/.agents/core/skills/context-os/VALIDATION.json +115 -4
- package/.agents/core/skills/context-os/packs.yaml +10 -59
- package/.agents/core/skills/context-os/references/context-rules.md +27 -59
- package/.agents/core/skills/context-os/references/pipeline.md +14 -119
- package/.agents/core/skills/context-os/references/project-graph.md +11 -100
- package/.agents/core/skills/context-os/rules.yaml +8 -135
- package/.agents/core/skills/engineering-workflow/EXAMPLES.md +15 -50
- package/.agents/core/skills/engineering-workflow/SKILL.md +10 -10
- package/.agents/core/skills/engineering-workflow/TROUBLESHOOTING.md +11 -19
- package/.agents/core/skills/engineering-workflow/VALIDATION.json +115 -4
- package/.agents/core/skills/engineering-workflow/references/workflow.md +55 -317
- package/.agents/core/skills/gemini-precision/EXAMPLES.md +33 -53
- package/.agents/core/skills/gemini-precision/SKILL.md +11 -147
- package/.agents/core/skills/gemini-precision/TROUBLESHOOTING.md +12 -25
- package/.agents/core/skills/gemini-precision/VALIDATION.json +115 -4
- package/.agents/core/skills/gemini-precision/skill.yaml +1 -1
- package/.agents/core/skills/gstack-roles/EXAMPLES.md +5 -21
- package/.agents/core/skills/gstack-roles/SKILL.md +10 -12
- package/.agents/core/skills/gstack-roles/TROUBLESHOOTING.md +6 -12
- package/.agents/core/skills/gstack-roles/VALIDATION.json +115 -4
- package/.agents/core/skills/gstack-roles/references/roles.md +3 -147
- package/.agents/core/skills/ponytail-mindset/EXAMPLES.md +12 -45
- package/.agents/core/skills/ponytail-mindset/SKILL.md +10 -13
- package/.agents/core/skills/ponytail-mindset/TROUBLESHOOTING.md +10 -19
- package/.agents/core/skills/ponytail-mindset/VALIDATION.json +115 -4
- package/.agents/core/skills/ponytail-mindset/references/minimalism.md +58 -174
- package/.agents/core/skills/security/EXAMPLES.md +19 -55
- package/.agents/core/skills/security/SKILL.md +61 -137
- package/.agents/core/skills/security/TROUBLESHOOTING.md +13 -19
- package/.agents/core/skills/security/VALIDATION.json +115 -4
- package/.agents/core/skills/security/skill.yaml +1 -1
- package/.agents/generated/claude/skills/context-manager/EXAMPLES.md +5 -17
- package/.agents/generated/claude/skills/context-manager/SKILL.md +9 -96
- package/.agents/generated/claude/skills/context-manager/TROUBLESHOOTING.md +6 -6
- package/.agents/generated/claude/skills/context-manager/VALIDATION.json +115 -4
- package/.agents/generated/claude/skills/context-manager/references/context-rules.md +3 -57
- package/.agents/generated/claude/skills/context-os/EXAMPLES.md +25 -15
- package/.agents/generated/claude/skills/context-os/SKILL.md +11 -133
- package/.agents/generated/claude/skills/context-os/TROUBLESHOOTING.md +11 -6
- package/.agents/generated/claude/skills/context-os/VALIDATION.json +115 -4
- package/.agents/generated/claude/skills/context-os/packs.yaml +10 -59
- package/.agents/generated/claude/skills/context-os/references/context-rules.md +27 -59
- package/.agents/generated/claude/skills/context-os/references/pipeline.md +14 -119
- package/.agents/generated/claude/skills/context-os/references/project-graph.md +11 -100
- package/.agents/generated/claude/skills/context-os/rules.yaml +8 -135
- package/.agents/generated/claude/skills/engineering-workflow/EXAMPLES.md +15 -50
- package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +9 -9
- package/.agents/generated/claude/skills/engineering-workflow/TROUBLESHOOTING.md +11 -19
- package/.agents/generated/claude/skills/engineering-workflow/VALIDATION.json +115 -4
- package/.agents/generated/claude/skills/engineering-workflow/references/workflow.md +55 -317
- package/.agents/generated/claude/skills/gemini-precision/EXAMPLES.md +33 -53
- package/.agents/generated/claude/skills/gemini-precision/SKILL.md +10 -143
- package/.agents/generated/claude/skills/gemini-precision/TROUBLESHOOTING.md +12 -25
- package/.agents/generated/claude/skills/gemini-precision/VALIDATION.json +115 -4
- package/.agents/generated/claude/skills/gstack-roles/EXAMPLES.md +5 -21
- package/.agents/generated/claude/skills/gstack-roles/SKILL.md +9 -11
- package/.agents/generated/claude/skills/gstack-roles/TROUBLESHOOTING.md +6 -12
- package/.agents/generated/claude/skills/gstack-roles/VALIDATION.json +115 -4
- package/.agents/generated/claude/skills/gstack-roles/references/roles.md +3 -147
- package/.agents/generated/claude/skills/ponytail-mindset/EXAMPLES.md +12 -45
- package/.agents/generated/claude/skills/ponytail-mindset/SKILL.md +9 -12
- package/.agents/generated/claude/skills/ponytail-mindset/TROUBLESHOOTING.md +10 -19
- package/.agents/generated/claude/skills/ponytail-mindset/VALIDATION.json +115 -4
- package/.agents/generated/claude/skills/ponytail-mindset/references/minimalism.md +58 -174
- package/.agents/generated/claude/skills/security/EXAMPLES.md +19 -55
- package/.agents/generated/claude/skills/security/SKILL.md +60 -134
- package/.agents/generated/claude/skills/security/TROUBLESHOOTING.md +13 -19
- package/.agents/generated/claude/skills/security/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/context-manager/EXAMPLES.md +5 -17
- package/.agents/generated/gemini/skills/context-manager/SKILL.md +10 -99
- package/.agents/generated/gemini/skills/context-manager/TROUBLESHOOTING.md +6 -6
- package/.agents/generated/gemini/skills/context-manager/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/context-manager/references/context-rules.md +3 -57
- package/.agents/generated/gemini/skills/context-os/EXAMPLES.md +25 -15
- package/.agents/generated/gemini/skills/context-os/SKILL.md +12 -135
- package/.agents/generated/gemini/skills/context-os/TROUBLESHOOTING.md +11 -6
- package/.agents/generated/gemini/skills/context-os/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/context-os/packs.yaml +10 -59
- package/.agents/generated/gemini/skills/context-os/references/context-rules.md +27 -59
- package/.agents/generated/gemini/skills/context-os/references/pipeline.md +14 -119
- package/.agents/generated/gemini/skills/context-os/references/project-graph.md +11 -100
- package/.agents/generated/gemini/skills/context-os/rules.yaml +8 -135
- package/.agents/generated/gemini/skills/engineering-workflow/EXAMPLES.md +15 -50
- package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +10 -11
- package/.agents/generated/gemini/skills/engineering-workflow/TROUBLESHOOTING.md +11 -19
- package/.agents/generated/gemini/skills/engineering-workflow/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/engineering-workflow/references/workflow.md +55 -317
- package/.agents/generated/gemini/skills/gemini-precision/EXAMPLES.md +33 -53
- package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +11 -145
- package/.agents/generated/gemini/skills/gemini-precision/TROUBLESHOOTING.md +12 -25
- package/.agents/generated/gemini/skills/gemini-precision/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/gstack-roles/EXAMPLES.md +5 -21
- package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +10 -13
- package/.agents/generated/gemini/skills/gstack-roles/TROUBLESHOOTING.md +6 -12
- package/.agents/generated/gemini/skills/gstack-roles/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/gstack-roles/references/roles.md +3 -147
- package/.agents/generated/gemini/skills/ponytail-mindset/EXAMPLES.md +12 -45
- package/.agents/generated/gemini/skills/ponytail-mindset/SKILL.md +10 -14
- package/.agents/generated/gemini/skills/ponytail-mindset/TROUBLESHOOTING.md +10 -19
- package/.agents/generated/gemini/skills/ponytail-mindset/VALIDATION.json +115 -4
- package/.agents/generated/gemini/skills/ponytail-mindset/references/minimalism.md +58 -174
- package/.agents/generated/gemini/skills/security/EXAMPLES.md +19 -55
- package/.agents/generated/gemini/skills/security/SKILL.md +61 -136
- package/.agents/generated/gemini/skills/security/TROUBLESHOOTING.md +13 -19
- package/.agents/generated/gemini/skills/security/VALIDATION.json +115 -4
- package/.agents/resolver/canonical-resolver.js +34 -21
- package/.agents/rules/rule-catalog.js +5 -5
- package/.agents/validate.js +9 -2
- package/.agents/validation-evidence.js +89 -0
- package/README.md +132 -197
- package/bin/index.js +1 -1
- package/catalog/skills/typescript/SKILL.md +16 -2
- package/package.json +90 -89
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **Symptom**: Adding config options, generics, and plugin interfaces for features not requested.
|
|
12
|
-
- **Root Cause**: Premature future-proofing.
|
|
13
|
-
- **Fix**: Apply Rung 1 of the ladder: If it doesn't solve the immediate requirement, do not write it.
|
|
14
|
-
|
|
15
|
-
## 3. Reinventing Installed Dependencies
|
|
16
|
-
|
|
17
|
-
- **Symptom**: Writing a deep-clone helper when Lodash or native structuredClone is available.
|
|
18
|
-
- **Root Cause**: Skipping inspection of package.json and runtime environment.
|
|
19
|
-
- **Fix**: Inspect installed dependencies before writing utility functions.
|
|
1
|
+
# Minimalism troubleshooting
|
|
2
|
+
|
|
3
|
+
- A shorter patch removes validation: restore the boundary checks before comparing
|
|
4
|
+
implementation sizes.
|
|
5
|
+
- A helper is used once: evaluate its meaning, isolation, and readability rather
|
|
6
|
+
than automatically inlining it.
|
|
7
|
+
- A new dependency appears: inspect the existing stack and actual requirement.
|
|
8
|
+
- Retry behavior is assumed: check the SDK contract and test failure handling.
|
|
9
|
+
- A code example is illustrative: do not report a running integration until the
|
|
10
|
+
real imports, persistence, authentication, and checks have been supplied.
|
|
@@ -1,12 +1,123 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"x-contextos-evidence-contract": 1,
|
|
4
|
+
"title": "Scoped verification evidence",
|
|
5
|
+
"description": "Report shape and outcome consistency only; command execution and agent behavior require separate evidence.",
|
|
3
6
|
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"status",
|
|
10
|
+
"checks",
|
|
11
|
+
"limitations"
|
|
12
|
+
],
|
|
4
13
|
"properties": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
14
|
+
"status": {
|
|
15
|
+
"enum": [
|
|
16
|
+
"verified",
|
|
17
|
+
"partial",
|
|
18
|
+
"not_run"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"checks": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"additionalProperties": false,
|
|
26
|
+
"required": [
|
|
27
|
+
"command",
|
|
28
|
+
"exitCode",
|
|
29
|
+
"scope"
|
|
30
|
+
],
|
|
31
|
+
"properties": {
|
|
32
|
+
"command": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1
|
|
35
|
+
},
|
|
36
|
+
"exitCode": {
|
|
37
|
+
"type": [
|
|
38
|
+
"integer",
|
|
39
|
+
"null"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"scope": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"minLength": 1
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"limitations": {
|
|
50
|
+
"type": "array",
|
|
51
|
+
"items": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"minLength": 1
|
|
54
|
+
}
|
|
7
55
|
}
|
|
8
56
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
57
|
+
"allOf": [
|
|
58
|
+
{
|
|
59
|
+
"if": {
|
|
60
|
+
"properties": {
|
|
61
|
+
"status": {
|
|
62
|
+
"const": "verified"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"then": {
|
|
67
|
+
"properties": {
|
|
68
|
+
"checks": {
|
|
69
|
+
"minItems": 1,
|
|
70
|
+
"items": {
|
|
71
|
+
"properties": {
|
|
72
|
+
"exitCode": {
|
|
73
|
+
"const": 0
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"if": {
|
|
83
|
+
"properties": {
|
|
84
|
+
"status": {
|
|
85
|
+
"enum": [
|
|
86
|
+
"partial",
|
|
87
|
+
"not_run"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"then": {
|
|
93
|
+
"properties": {
|
|
94
|
+
"limitations": {
|
|
95
|
+
"minItems": 1
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"if": {
|
|
102
|
+
"properties": {
|
|
103
|
+
"status": {
|
|
104
|
+
"const": "not_run"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"then": {
|
|
109
|
+
"properties": {
|
|
110
|
+
"checks": {
|
|
111
|
+
"items": {
|
|
112
|
+
"properties": {
|
|
113
|
+
"exitCode": {
|
|
114
|
+
"type": "null"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
11
122
|
]
|
|
12
123
|
}
|
|
@@ -1,186 +1,70 @@
|
|
|
1
|
+
# Minimal maintainable implementation
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
## Decision ladder
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
1. Does this solve the requested outcome? Avoid speculative features.
|
|
6
|
+
2. Does project code or the installed component system already handle it?
|
|
7
|
+
3. Does the standard library provide the operation?
|
|
8
|
+
4. Does the native platform meet the actual requirements?
|
|
9
|
+
5. Can an installed dependency handle it without extra integration cost?
|
|
10
|
+
6. Can it be a readable one-liner without hiding boundary checks?
|
|
11
|
+
7. Otherwise write the smallest clear implementation.
|
|
5
12
|
|
|
6
|
-
|
|
13
|
+
The rule of three is a duplication heuristic, not a ban on named functions.
|
|
14
|
+
Extract a single-use helper when it clarifies an invariant or isolates an I/O
|
|
15
|
+
boundary. Prefer the project's established UI system; do not install shadcn or
|
|
16
|
+
another library merely because a generic guide names it. dayjs is a dependency,
|
|
17
|
+
not a standard-library API. Verify retry/circuit-breaker support in the actual
|
|
18
|
+
SDK; do not assume native fetch supplies an application retry policy.
|
|
7
19
|
|
|
8
|
-
##
|
|
20
|
+
## Preserve boundary validation
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Based on [DietrichGebert/ponytail](https://github.com/DietrichGebert/ponytail).
|
|
15
|
-
|
|
16
|
-
> _He says nothing. He writes one line. It works._
|
|
17
|
-
|
|
18
|
-
**Core Impact**: Dramatically reduces code footprint by eliminating premature abstraction, YAGNI violations, and boilerplate, while keeping all safety invariants (validation, error handling, security) 100% intact.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
### Core Principle
|
|
23
|
-
|
|
24
|
-
> **The best code is code you don't write.**\
|
|
25
|
-
> Write only what the task strictly needs. Lazy about the solution, never about reading and understanding.
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
### The 7-Rung Decision Ladder
|
|
30
|
-
|
|
31
|
-
**Before writing ANY code**, stop and check each rung in order. Stop at the first rung that holds:
|
|
32
|
-
|
|
33
|
-
```text
|
|
34
|
-
1. Does this need to exist?
|
|
35
|
-
→ No: YAGNI — skip it entirely. Don't build for "future use."
|
|
36
|
-
|
|
37
|
-
2. Already in this codebase or component library?
|
|
38
|
-
→ Yes: Reuse it. Don't rewrite. Call the existing function/component/module.
|
|
39
|
-
→ For UI: Check shadcn/ui FIRST. Before building a complex UI element from scratch, check if it exists in the component library. If yes, generate the install command: npx shadcn@latest add dialog — never manually rewrite what shadcn already provides.
|
|
40
|
-
|
|
41
|
-
3. Standard library does it?
|
|
42
|
-
→ Yes: Use it. Don't write formatDate() — use Intl.DateTimeFormat or dayjs.
|
|
43
|
-
|
|
44
|
-
4. Native platform feature?
|
|
45
|
-
→ Yes: Use it. Don't install flatpickr when <input type="date"> exists.
|
|
46
|
-
→ Exception for UI Components: If a native HTML element (like <input type="date"> or <select>) CANNOT be styled consistently across Chrome, Safari, and Firefox to match the premium design system — use the established component library (e.g., shadcn/ui <DatePicker>, <Select>) instead. Cross-browser inconsistency is a legitimate reason to NOT use native.
|
|
47
|
-
|
|
48
|
-
5. Already-installed dependency?
|
|
49
|
-
→ Yes: Use it. Don't install a new library to do what an existing one can.
|
|
50
|
-
|
|
51
|
-
6. Can it be done in one line?
|
|
52
|
-
→ Yes: One line. No abstraction layer needed.
|
|
53
|
-
|
|
54
|
-
7. Only then: write the MINIMUM that works.
|
|
55
|
-
→ No classes when a function works. No module when an inline does.
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
### The Rule of Three (Do Not Abstract Early)
|
|
61
|
-
|
|
62
|
-
- **First occurrence**: Write it inline directly where it is needed.
|
|
63
|
-
- **Second occurrence**: Duplicate it cleanly. Duplication is cheaper than the wrong abstraction.
|
|
64
|
-
- **Third occurrence**: Only now extract a shared helper or utility.
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
### 10 Concrete Over-Engineering Red Flags
|
|
69
|
-
|
|
70
|
-
1. Creating a `GenericRepository<T>` when you only have 2 database tables.
|
|
71
|
-
2. Creating a custom state machine or complex reducer for 2 boolean flags.
|
|
72
|
-
3. Adding a configuration file or environment variables for values that never change.
|
|
73
|
-
4. Writing custom retry/circuit-breaker logic when native `fetch` or SDK already handles it.
|
|
74
|
-
5. Building a generic `BaseService` with 15 hook methods implemented by only one class.
|
|
75
|
-
6. Wrapping every standard library call in a custom helper class (`StringUtils`, `DateUtils`, `ObjectUtils`).
|
|
76
|
-
7. Creating a multi-level folder structure (`domains/auth/adapters/driving/rest/controllers/dto/`) for a 30-line microservice.
|
|
77
|
-
8. Writing custom mock frameworks when Vitest/Jest/Node test runner provide standard mocks.
|
|
78
|
-
9. Installing a 50KB npm package for a 3-line utility (e.g. `left-pad`, `is-number`, `deep-clone`).
|
|
79
|
-
10. Pre-optimizing caching and indexing for endpoints serving 10 requests a day.
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
### The Sacred Exceptions (NEVER Cut These)
|
|
84
|
-
|
|
85
|
-
The ladder applies to features and abstractions. These 4 areas are **non-negotiable** and **never simplified away**:
|
|
86
|
-
|
|
87
|
-
#### 1. Input Validation
|
|
22
|
+
This runnable example defines a protected update operation around a supplied
|
|
23
|
+
persistence function. The caller must obtain the session through trusted
|
|
24
|
+
server-side authentication. The sample schema covers only name/email; adapt it
|
|
25
|
+
to the real product schema, error contracts, and tenant model.
|
|
88
26
|
|
|
27
|
+
<!-- example: ponytail-update -->
|
|
89
28
|
```javascript
|
|
90
|
-
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
29
|
+
export function createUserUpdater(update) {
|
|
30
|
+
if (typeof update !== 'function') throw new TypeError('Persistence function required');
|
|
31
|
+
return async function updateUser(id, data, session) {
|
|
32
|
+
if (typeof id !== 'string' || !id || session?.userId !== id) {
|
|
33
|
+
throw new Error('Forbidden');
|
|
34
|
+
}
|
|
35
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
36
|
+
throw new TypeError('Invalid update payload');
|
|
37
|
+
}
|
|
38
|
+
const keys = Object.keys(data);
|
|
39
|
+
if (!keys.length || keys.some(key => !['name', 'email'].includes(key))) {
|
|
40
|
+
throw new TypeError('Unknown or empty update fields');
|
|
41
|
+
}
|
|
42
|
+
const parsed = {};
|
|
43
|
+
if (Object.hasOwn(data, 'name')) {
|
|
44
|
+
if (typeof data.name !== 'string' || !data.name.trim() || data.name.length > 100) {
|
|
45
|
+
throw new TypeError('Invalid name');
|
|
46
|
+
}
|
|
47
|
+
parsed.name = data.name;
|
|
48
|
+
}
|
|
49
|
+
if (Object.hasOwn(data, 'email')) {
|
|
50
|
+
if (typeof data.email !== 'string' || data.email.length > 254 ||
|
|
51
|
+
!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) {
|
|
52
|
+
throw new TypeError('Invalid email');
|
|
53
|
+
}
|
|
54
|
+
parsed.email = data.email;
|
|
55
|
+
}
|
|
56
|
+
return update({ where: { id }, data: parsed });
|
|
57
|
+
};
|
|
101
58
|
}
|
|
102
59
|
```
|
|
103
60
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// [GOOD] Always handle errors explicitly
|
|
108
|
-
async function fetchUser(id) {
|
|
109
|
-
try {
|
|
110
|
-
const user = await db.findById(id);
|
|
111
|
-
if (!user) throw new NotFoundError(`User ${id} not found`);
|
|
112
|
-
return user;
|
|
113
|
-
} catch (err) {
|
|
114
|
-
logger.error('fetchUser failed', { id, err });
|
|
115
|
-
throw err;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
#### 3. Security Checks
|
|
121
|
-
|
|
122
|
-
- Authorization check BEFORE every query or mutation.
|
|
123
|
-
- Parameterized queries everywhere — zero string concatenation in SQL.
|
|
124
|
-
- Strict sanitization of all rendered HTML and markdown.
|
|
125
|
-
|
|
126
|
-
#### 4. Type Safety & Behavioral Tests
|
|
127
|
-
|
|
128
|
-
- Strict TypeScript types — no `any` evasion.
|
|
129
|
-
- Tests covering happy path, 4xx, and 5xx edge cases.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Code Examples
|
|
134
|
-
|
|
135
|
-
### Native Platform vs Over-Built Package
|
|
136
|
-
|
|
137
|
-
**Over-build**:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
npm install flatpickr
|
|
141
|
-
# Creates DatePickerWrapper.jsx (45 lines) + useDatePicker.js (30 lines) + styles (60 lines)
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**Ponytail approach (rung 4)**:
|
|
145
|
-
|
|
146
|
-
```html
|
|
147
|
-
<input type="date" name="date" aria-label="Appointment date" />
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Next.js App Router Server Action vs REST Endpoint
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
// Instead of /api/users/[id]/route.ts + custom fetch wrapper:
|
|
154
|
-
"use server";
|
|
155
|
-
|
|
156
|
-
export async function updateUser(id: string, data: UpdateUserInput) {
|
|
157
|
-
const session = await getSession(); // auth check — never skip
|
|
158
|
-
if (session?.userId !== id) throw new Error("Forbidden");
|
|
159
|
-
return db.users.update(id, data);
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## Validation Checklist
|
|
166
|
-
|
|
167
|
-
- [ ] Every new dependency has been verified: cannot be solved with native platform or existing dependencies.
|
|
168
|
-
- [ ] No single-use abstractions, wrappers, or interfaces created.
|
|
169
|
-
- [ ] Sacred exceptions preserved: 100% input validation, explicit error handling, security checks intact.
|
|
170
|
-
- [ ] All code written passes all existing unit and integration tests.
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Common Mistakes
|
|
175
|
-
|
|
176
|
-
- **Cutting validation to write less code**: The goal is less architecture/boilerplate, never less safety.
|
|
177
|
-
- **Creating utilities "for future use"**: Only write utilities when used 3+ times.
|
|
178
|
-
- **Rewriting component libraries**: Building custom modals, tabs, or tooltips from scratch when shadcn/ui or Radix is already in the project.
|
|
179
|
-
|
|
180
|
-
---
|
|
61
|
+
The verifier runs this block with an injected persistence function and asserts
|
|
62
|
+
that denied users, invalid emails, and unknown privilege fields never reach it.
|
|
63
|
+
This is boundary evidence, not proof of a live database or authentication setup.
|
|
181
64
|
|
|
182
|
-
##
|
|
65
|
+
## Verification checklist
|
|
183
66
|
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
67
|
+
- Each dependency or abstraction solves an inspected requirement.
|
|
68
|
+
- Protected inputs and operations retain their checks.
|
|
69
|
+
- Errors have a meaningful contract; avoid redundant catch/log/rethrow layers.
|
|
70
|
+
- Behavior checks cover relevant success and failure cases.
|
|
@@ -1,64 +1,28 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Security boundary examples
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Protected document mutation
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Illustrative integration sketch: authenticate through trusted middleware, check
|
|
6
|
+
the tenant role permits the action, and scope the query by document ID and trusted
|
|
7
|
+
tenant ID. Return the established denied/missing response when no accessible
|
|
8
|
+
document matches. Tenant membership alone may not permit deletion.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function verifyApiKey(providedKey: string, storedKey: string): boolean {
|
|
10
|
-
return providedKey === storedKey; // Vulnerable to timing analysis!
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Best practice: ContextOS Standard (Constant-time buffer comparison)
|
|
10
|
+
Do not report a working endpoint from a sketch with assumed ORM/middleware.
|
|
11
|
+
Verify another user's or tenant's document is inaccessible before persistence.
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
// GOOD: crypto.timingSafeEqual executes in constant time
|
|
18
|
-
import crypto from 'crypto';
|
|
13
|
+
## Executable controls
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
The original runnable HMAC and partner-fetch blocks are in [SKILL.md](SKILL.md).
|
|
16
|
+
The verifier extracts these blocks rather than manually maintained copies.
|
|
17
|
+
Checks cover signatures and URL scheme, credentials, host, port, transport, and
|
|
18
|
+
redirect policy. Egress, DNS, and replay defenses need separate integration tests.
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
20
|
+
## Source-checkout scanner
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
```powershell
|
|
23
|
+
node bin/index.js scan --staged --enforce --placeholders
|
|
30
24
|
```
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### Anti-pattern: Anti-pattern (Trusting client ID without ownership check)
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
// BAD: any authenticated user can delete any other user's document!
|
|
40
|
-
app.delete('/api/documents/:id', requireAuth, async (req, res) => {
|
|
41
|
-
await prisma.document.delete({ where: { id: req.params.id } });
|
|
42
|
-
res.status(204).end();
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Best practice: ContextOS Standard (Multi-tenant scoped authorization check)
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
// GOOD: document deletion is strictly scoped to authenticated user or org
|
|
50
|
-
app.delete('/api/documents/:id', requireAuth, async (req, res) => {
|
|
51
|
-
const deleted = await prisma.document.deleteMany({
|
|
52
|
-
where: {
|
|
53
|
-
id: req.params.id,
|
|
54
|
-
organizationId: req.user.organizationId, // Tenant isolation
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (deleted.count === 0) {
|
|
59
|
-
return res.status(404).json({ error: 'Document not found or access denied' });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return res.status(204).end();
|
|
63
|
-
});
|
|
64
|
-
```
|
|
26
|
+
This checks staged secrets and placeholders. Supply --scope <file> with the
|
|
27
|
+
actual scope JSON for write boundaries. Inspect unstaged changes separately.
|
|
28
|
+
An empty index does not prove a candidate contains no unsafe code.
|