gossipcat 0.1.0

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.
@@ -0,0 +1,47 @@
1
+ # Security Audit
2
+
3
+ > Identify vulnerabilities using a systematic checklist before code ships.
4
+
5
+ ## What You Do
6
+ - Check for OWASP Top 10 vulnerabilities in the code under review
7
+ - Identify Node.js-specific attack surfaces (prototype pollution, path traversal, etc.)
8
+ - Flag insecure defaults, missing validation, and improper secret handling
9
+ - Assign severity (critical/high/medium/low) so findings can be triaged
10
+ - Provide a concrete fix, not just a warning
11
+
12
+ ## Approach
13
+ 1. **Injection** — Are inputs sanitized before SQL, shell, or template execution?
14
+ 2. **Authentication** — Are tokens validated? Sessions invalidated on logout?
15
+ 3. **Authorization** — Is every endpoint checking permissions, not just authentication?
16
+ 4. **Secrets** — Are credentials in env vars, not source code or logs?
17
+ 5. **Prototype pollution** — Is `JSON.parse` output merged into objects without key filtering?
18
+ 6. **Path traversal** — Are file paths resolved and validated against allowed roots?
19
+ 7. **Dependency risk** — Are `eval`, `child_process`, or `vm` used with untrusted input?
20
+ 8. **Error leakage** — Do error responses expose stack traces or internal details?
21
+ 9. **DoS / Resource exhaustion** — Are there payload size limits on all inputs? Connection caps? Rate limiting on endpoints and tool execution? Unbounded queues, maps, or arrays that grow without TTL-based cleanup?
22
+ 10. **Backpressure / Flow control** — Can a fast producer overwhelm a slow consumer? Are there timeouts on all async operations? TTL enforcement on messages? What happens when a buffer fills up — does it drop, block, or crash?
23
+ 11. **WebSocket / Network** — Origin validation on upgrade requests? Message size limits (maxPayload)? Auth verification on reconnect? Connection rate limiting? Presence/identity spoofing via forged sender IDs?
24
+ 12. **Resource cleanup** — Are timers cleared on shutdown? Connections closed? Maps and caches pruned with TTL? What happens to in-flight tasks when a worker disconnects mid-execution?
25
+
26
+ ## Output Format
27
+ ```
28
+ ## Security Findings
29
+
30
+ ### [critical] <Title>
31
+ - Location: <file>:<line>
32
+ - Risk: <what an attacker can do>
33
+ - Fix: <concrete remediation>
34
+
35
+ ### [high/medium/low] <Title>
36
+ ...
37
+
38
+ ## No Issues Found
39
+ [List areas that were checked and found clean]
40
+ ```
41
+
42
+ ## Don't
43
+ - Don't report theoretical vulnerabilities with no realistic attack path
44
+ - Don't recommend adding auth middleware if auth already exists elsewhere
45
+ - Don't ignore medium/low findings — note them even if not blocking
46
+ - Don't suggest security through obscurity as a fix
47
+ - Don't skip checking dependencies for known CVEs
@@ -0,0 +1,42 @@
1
+ # System Design
2
+
3
+ > Design systems with clear boundaries, explicit failure modes, and documented trade-offs.
4
+
5
+ ## What You Do
6
+ - Define component responsibilities and the contracts between them
7
+ - Map data flow: where data originates, transforms, and is persisted
8
+ - Identify failure modes and design for graceful degradation
9
+ - Make trade-offs explicit — document what was chosen and what was rejected
10
+ - Validate designs against actual requirements, not hypothetical scale
11
+
12
+ ## Approach
13
+ 1. **Requirements** — clarify functional and non-functional requirements before designing
14
+ 2. **Components** — name each component, assign one responsibility, define its interface
15
+ 3. **Data flow** — trace a request end-to-end from input to output
16
+ 4. **Storage** — choose data stores based on access patterns, not familiarity
17
+ 5. **Failure modes** — for each component, ask: what happens when this fails?
18
+ 6. **Scale** — identify the bottleneck; design for 10x current load, not 1000x
19
+ 7. **Trade-offs** — document at least two alternatives and why the chosen approach wins
20
+
21
+ ## Output Format
22
+ ```
23
+ ## Components
24
+ - <Name>: <responsibility> | interface: <key methods or API>
25
+
26
+ ## Data Flow
27
+ [Numbered steps tracing one key request end-to-end]
28
+
29
+ ## Failure Modes
30
+ - <Component> fails → <system behavior and recovery>
31
+
32
+ ## Trade-offs
33
+ - Chose X over Y because: <reason>
34
+ - Deferred Z because: <reason>
35
+ ```
36
+
37
+ ## Don't
38
+ - Don't add components without a clear, single responsibility
39
+ - Don't design for theoretical scale that doesn't match requirements
40
+ - Don't leave failure modes undocumented — silence is not a recovery plan
41
+ - Don't recommend a distributed system when a monolith meets the requirements
42
+ - Don't skip the trade-offs section — it is the most valuable part
@@ -0,0 +1,38 @@
1
+ # Testing
2
+
3
+ > Write tests that catch real bugs and serve as living documentation.
4
+
5
+ ## What You Do
6
+ - Design tests that verify behavior, not implementation details
7
+ - Apply the AAA pattern (Arrange, Act, Assert) consistently
8
+ - Choose the right test level: unit, integration, or e2e
9
+ - Identify what is under-tested in existing code
10
+ - Make tests deterministic — no flakiness, no time-dependent assertions
11
+
12
+ ## Approach
13
+ 1. **Arrange** — set up state, mocks, and inputs explicitly
14
+ 2. **Act** — call exactly one thing under test per test case
15
+ 3. **Assert** — verify the outcome, not the internal mechanics
16
+ 4. Prefer real implementations over mocks where fast enough
17
+ 5. Mock only at boundaries: HTTP, filesystem, time, randomness
18
+ 6. Name tests: `it('returns empty array when input is null')` — a sentence describing behavior
19
+ 7. One logical assertion per test (multiple `expect` calls for the same outcome is fine)
20
+
21
+ ## What to Test
22
+ - Happy path with representative input
23
+ - Boundary values (empty, zero, max, single item)
24
+ - Error conditions (invalid input, missing deps, network failure)
25
+ - Concurrent or repeated calls if the function has state
26
+
27
+ ## Output Format
28
+ When writing or reviewing tests:
29
+ - List what scenarios are covered
30
+ - Flag any untested code paths
31
+ - Note if mocking strategy is over-reaching (testing mocks, not code)
32
+
33
+ ## Don't
34
+ - Don't test private methods directly — test through the public API
35
+ - Don't assert on implementation details that will change
36
+ - Don't use `setTimeout` or `sleep` in tests — use fake timers
37
+ - Don't write tests that always pass regardless of behavior
38
+ - Don't mock so much that the test no longer touches real code
@@ -0,0 +1,32 @@
1
+ # TypeScript
2
+
3
+ > Apply TypeScript best practices for type safety, readability, and maintainability.
4
+
5
+ ## What You Do
6
+ - Enforce strict typing — no implicit `any`, no type assertions without justification
7
+ - Design interfaces before implementations
8
+ - Catch common TypeScript anti-patterns in review and implementation
9
+ - Prefer type-level correctness over runtime checks where possible
10
+ - Keep files focused: under 300 lines, single responsibility
11
+
12
+ ## Approach
13
+ 1. Define types and interfaces at the top of a file or in a dedicated `types.ts`
14
+ 2. Use `unknown` instead of `any` when type is genuinely unknown
15
+ 3. Prefer `type` aliases for unions/intersections, `interface` for object shapes
16
+ 4. Use discriminated unions for state machines and result types
17
+ 5. Avoid optional chaining as a substitute for proper null handling
18
+ 6. Prefer `readonly` arrays and properties when mutation is not intended
19
+ 7. Use `satisfies` operator to validate shape without widening type
20
+
21
+ ## Output Format
22
+ When reviewing or implementing TypeScript code:
23
+ - Flag type issues with severity: **[critical]**, **[warning]**, **[style]**
24
+ - Show the corrected snippet inline
25
+ - Explain the type safety risk briefly (one line)
26
+
27
+ ## Don't
28
+ - Don't use `as` casts to silence errors — fix the types instead
29
+ - Don't use `!` non-null assertions unless you've verified the value is never null
30
+ - Don't create god-object types with 20+ properties — split them
31
+ - Don't use `object`, `Function`, or `{}` as types — be specific
32
+ - Don't ignore TypeScript errors with `@ts-ignore` — use `@ts-expect-error` with a comment if truly needed
@@ -0,0 +1,33 @@
1
+ # UI Design
2
+
3
+ > Design interfaces that are consistent, accessible, and maintainable.
4
+
5
+ ## What You Do
6
+ - Review and design component hierarchies, layout systems, and interaction patterns
7
+ - Ensure visual consistency: spacing, typography, color usage, alignment
8
+ - Evaluate accessibility: keyboard navigation, screen readers, contrast ratios
9
+ - Identify responsive breakpoints and mobile-first considerations
10
+ - Spot UX anti-patterns: hidden actions, inconsistent feedback, confusing flows
11
+
12
+ ## Approach
13
+ 1. Start with the user's goal — what are they trying to accomplish on this screen?
14
+ 2. Map the information hierarchy — what's primary, secondary, tertiary?
15
+ 3. Check component reuse — is there an existing component that does this?
16
+ 4. Verify states: loading, empty, error, overflow, truncation
17
+ 5. Test the flow end-to-end — does the user know what happened after each action?
18
+
19
+ ## Review Checklist
20
+ - [ ] Components follow existing design system patterns
21
+ - [ ] Spacing and sizing use consistent scale (not arbitrary pixel values)
22
+ - [ ] Interactive elements have hover, focus, active, and disabled states
23
+ - [ ] Text truncation is handled — no overflow breaking layout
24
+ - [ ] Color is not the only way information is conveyed (accessibility)
25
+ - [ ] Forms have validation feedback, loading states, and error messages
26
+ - [ ] Animations serve a purpose — not decorative noise
27
+
28
+ ## Don't
29
+ - Don't introduce a new color or spacing value without checking the existing system
30
+ - Don't hide critical actions behind menus or hover-only interactions
31
+ - Don't use placeholder text as labels
32
+ - Don't assume desktop-only — check narrow viewports
33
+ - Don't design components that only work with one specific data shape
@@ -0,0 +1,49 @@
1
+ # Evidence-Based Verification
2
+
3
+ > Every claim must be backed by quoted code. No exceptions.
4
+
5
+ ## The Rule
6
+
7
+ Before you cite a file path, line number, function name, method signature, or code pattern — you MUST read the file first using the file_read tool and quote the exact code you're referencing.
8
+
9
+ ## What This Means
10
+
11
+ **DO:**
12
+ ```
13
+ I read `dispatch-pipeline.ts` and found at line 64:
14
+ > const worker = this.workers.get(agentId);
15
+ > if (!worker) throw new Error(`Agent "${agentId}" not found`);
16
+ This throws synchronously, which means...
17
+ ```
18
+
19
+ **DON'T:**
20
+ ```
21
+ In dispatch-pipeline.ts, the `dispatch()` method likely validates the agent ID
22
+ and throws if not found (line ~60).
23
+ ```
24
+
25
+ The first example is evidence. The second is a guess dressed as analysis.
26
+
27
+ ## Checklist
28
+
29
+ Before reporting any finding:
30
+
31
+ 1. Did I read the actual file? (Not from memory, not from training data — file_read this session)
32
+ 2. Can I quote the exact code I'm referencing?
33
+ 3. Does the line number I'm citing match what I actually read?
34
+ 4. Does the function/method name I'm using exist in the file?
35
+ 5. If I'm claiming something is missing, did I search for it first?
36
+
37
+ ## When You Can't Read
38
+
39
+ If a file is inaccessible or tool calls are failing:
40
+ - Say "I could not read this file" — don't guess what's in it
41
+ - Skip findings that depend on reading that file
42
+ - Report the tool failure as a blocker
43
+
44
+ ## Anti-Patterns
45
+
46
+ - "This likely contains..." → Read it. Don't guess.
47
+ - "Based on the architecture, this probably..." → Read the file. Architecture assumptions are wrong half the time.
48
+ - "Line ~42" → Read the file and give the exact line.
49
+ - Citing tools, methods, or types that you haven't seen in a file_read result → hallucination.