fix: harden unicode safety checks

This commit is contained in:
Affaan Mustafa
2026-03-29 08:59:06 -04:00
parent dd675d4258
commit 866d9ebb53
239 changed files with 3780 additions and 3962 deletions

View File

@@ -78,7 +78,7 @@ Flag it clearly before resuming:
```
ASIDE: [answer]
⚠️ Note: This answer suggests [issue] with the current approach. Want to address this before continuing, or proceed as planned?
WARNING: Note: This answer suggests [issue] with the current approach. Want to address this before continuing, or proceed as planned?
```
Wait for the user's decision before resuming.
@@ -119,7 +119,7 @@ Note the change needed but do not make it during the aside:
```
ASIDE: [answer]
📝 Worth fixing: [what should be changed]. I'll flag this after the current task unless you want to address it now.
Worth fixing: [what should be changed]. I'll flag this after the current task unless you want to address it now.
```
**Question is ambiguous or too vague:**
@@ -150,7 +150,7 @@ No — the shared cache object in src/cache/store.ts:34 is mutated without locki
Under concurrent requests this is a race condition. It's low risk in a single-process
Node.js server but would be a real problem with worker threads or clustering.
⚠️ Note: This could affect the feature we're building. Want to address this now or continue and fix it in a follow-up?
WARNING: Note: This could affect the feature we're building. Want to address this now or continue and fix it in a follow-up?
```
---

View File

@@ -9,7 +9,7 @@ Comprehensive security and quality review of uncommitted changes:
**Security Issues (CRITICAL):**
- Hardcoded credentials, API keys, tokens
- SQL injection vulnerabilities
- XSS vulnerabilities
- XSS vulnerabilities
- Missing input validation
- Insecure dependencies
- Path traversal risks

View File

@@ -129,7 +129,7 @@ All tests passed.
| Files modified | 2 |
| Remaining issues | 0 |
Build Status: SUCCESS
Build Status: PASS: SUCCESS
```
## Common Errors Fixed

View File

@@ -108,16 +108,16 @@ void processUser(const User& user) {
- HIGH: 1
- MEDIUM: 0
Recommendation: Block merge until CRITICAL issue is fixed
Recommendation: FAIL: Block merge until CRITICAL issue is fixed
```
## Approval Criteria
| Status | Condition |
|--------|-----------|
| Approve | No CRITICAL or HIGH issues |
| ⚠️ Warning | Only MEDIUM issues (merge with caution) |
| Block | CRITICAL or HIGH issues found |
| PASS: Approve | No CRITICAL or HIGH issues |
| WARNING: Warning | Only MEDIUM issues (merge with caution) |
| FAIL: Block | CRITICAL or HIGH issues found |
## Integration with Other Commands

View File

@@ -182,7 +182,7 @@ Artifacts generated:
╔══════════════════════════════════════════════════════════════╗
║ E2E Test Results ║
╠══════════════════════════════════════════════════════════════╣
║ Status: ALL TESTS PASSED ║
║ Status: PASS: ALL TESTS PASSED ║
║ Total: 3 tests ║
║ Passed: 3 (100%) ║
║ Failed: 0 ║
@@ -191,15 +191,15 @@ Artifacts generated:
╚══════════════════════════════════════════════════════════════╝
Artifacts:
📸 Screenshots: 2 files
📹 Videos: 0 files (only on failure)
🔍 Traces: 0 files (only on failure)
📊 HTML Report: playwright-report/index.html
Screenshots: 2 files
Videos: 0 files (only on failure)
Traces: 0 files (only on failure)
HTML Report: playwright-report/index.html
View report: npx playwright show-report
```
E2E test suite ready for CI/CD integration!
PASS: E2E test suite ready for CI/CD integration!
```
## Test Artifacts
@@ -235,7 +235,7 @@ open artifacts/search-results.png
If a test fails intermittently:
```
⚠️ FLAKY TEST DETECTED: tests/e2e/markets/trade.spec.ts
WARNING: FLAKY TEST DETECTED: tests/e2e/markets/trade.spec.ts
Test passed 7/10 runs (70% pass rate)
@@ -254,10 +254,10 @@ Quarantine recommendation: Mark as test.fixme() until fixed
## Browser Configuration
Tests run on multiple browsers by default:
- Chromium (Desktop Chrome)
- Firefox (Desktop)
- WebKit (Desktop Safari)
- Mobile Chrome (optional)
- PASS: Chromium (Desktop Chrome)
- PASS: Firefox (Desktop)
- PASS: WebKit (Desktop Safari)
- PASS: Mobile Chrome (optional)
Configure in `playwright.config.ts` to adjust browsers.
@@ -285,7 +285,7 @@ Add to your CI pipeline:
For PMX, prioritize these E2E tests:
**🔴 CRITICAL (Must Always Pass):**
**CRITICAL (Must Always Pass):**
1. User can connect wallet
2. User can browse markets
3. User can search markets (semantic search)
@@ -294,7 +294,7 @@ For PMX, prioritize these E2E tests:
6. Market resolves correctly
7. User can withdraw funds
**🟡 IMPORTANT:**
**IMPORTANT:**
1. Market creation flow
2. User profile updates
3. Real-time price updates
@@ -305,20 +305,20 @@ For PMX, prioritize these E2E tests:
## Best Practices
**DO:**
- Use Page Object Model for maintainability
- Use data-testid attributes for selectors
- Wait for API responses, not arbitrary timeouts
- Test critical user journeys end-to-end
- Run tests before merging to main
- Review artifacts when tests fail
- PASS: Use Page Object Model for maintainability
- PASS: Use data-testid attributes for selectors
- PASS: Wait for API responses, not arbitrary timeouts
- PASS: Test critical user journeys end-to-end
- PASS: Run tests before merging to main
- PASS: Review artifacts when tests fail
**DON'T:**
- Use brittle selectors (CSS classes can change)
- Test implementation details
- Run tests against production
- Ignore flaky tests
- Skip artifact review on failures
- Test every edge case with E2E (use unit tests)
- FAIL: Use brittle selectors (CSS classes can change)
- FAIL: Test implementation details
- FAIL: Run tests against production
- FAIL: Ignore flaky tests
- FAIL: Skip artifact review on failures
- FAIL: Test every edge case with E2E (use unit tests)
## Important Notes

View File

@@ -140,7 +140,7 @@ ok project/internal/handler 0.023s
| Files modified | 2 |
| Remaining issues | 0 |
Build Status: SUCCESS
Build Status: PASS: SUCCESS
```
## Common Errors Fixed

View File

@@ -124,16 +124,16 @@ return fmt.Errorf("get user %s: %w", userID, err)
- HIGH: 1
- MEDIUM: 0
Recommendation: Block merge until CRITICAL issue is fixed
Recommendation: FAIL: Block merge until CRITICAL issue is fixed
```
## Approval Criteria
| Status | Condition |
|--------|-----------|
| Approve | No CRITICAL or HIGH issues |
| ⚠️ Warning | Only MEDIUM issues (merge with caution) |
| Block | CRITICAL or HIGH issues found |
| PASS: Approve | No CRITICAL or HIGH issues |
| WARNING: Warning | Only MEDIUM issues (merge with caution) |
| FAIL: Block | CRITICAL or HIGH issues found |
## Integration with Other Commands

View File

@@ -44,7 +44,7 @@ Import instincts from local file paths or HTTP(S) URLs.
## Import Process
```
📥 Importing instincts from: team-instincts.yaml
Importing instincts from: team-instincts.yaml
================================================
Found 12 instincts to import.
@@ -60,12 +60,12 @@ These will be added:
## Duplicate Instincts (3)
Already have similar instincts:
⚠️ prefer-functional-style
WARNING: prefer-functional-style
Local: 0.8 confidence, 12 observations
Import: 0.7 confidence
→ Keep local (higher confidence)
⚠️ test-first-workflow
WARNING: test-first-workflow
Local: 0.75 confidence
Import: 0.9 confidence
→ Update to import (higher confidence)
@@ -102,7 +102,7 @@ project_name: "my-project"
After import:
```
Import complete!
PASS: Import complete!
Added: 8 instincts
Updated: 1 instinct

View File

@@ -131,7 +131,7 @@ $ ./gradlew test
| Files modified | 2 |
| Remaining issues | 0 |
Build Status: SUCCESS
Build Status: PASS: SUCCESS
````
## Common Errors Fixed

View File

@@ -80,7 +80,7 @@ Agent:
## Static Analysis Results
✓ Build: Successful
✓ detekt: No issues
ktlint: 2 formatting warnings
WARNING: ktlint: 2 formatting warnings
## Issues Found
@@ -116,16 +116,16 @@ launch {
- HIGH: 1
- MEDIUM: 0
Recommendation: Block merge until CRITICAL issue is fixed
Recommendation: FAIL: Block merge until CRITICAL issue is fixed
````
## Approval Criteria
| Status | Condition |
|--------|-----------|
| Approve | No CRITICAL or HIGH issues |
| ⚠️ Warning | Only MEDIUM issues (merge with caution) |
| Block | CRITICAL or HIGH issues found |
| PASS: Approve | No CRITICAL or HIGH issues |
| WARNING: Warning | Only MEDIUM issues (merge with caution) |
| FAIL: Block | CRITICAL or HIGH issues found |
## Integration with Other Commands

View File

@@ -73,7 +73,7 @@ origin: auto-extracted
| **Absorb into [X]** | Should be appended to an existing skill | Show target skill and additions → Step 6 |
| **Drop** | Trivial, redundant, or too abstract | Explain reasoning and stop |
**Guideline dimensions** (informing the verdict, not scored):
**Guideline dimensions** (informing the verdict, not scored):
- **Specificity & Actionability**: Contains code examples or commands that are immediately usable
- **Scope Fit**: Name, trigger conditions, and content are aligned and focused on a single pattern

View File

@@ -204,9 +204,9 @@ Synthesize both analyses, generate **Step-by-step Implementation Plan**:
3. Output prompt in **bold text** (MUST use actual saved file path):
---
**Plan generated and saved to `.claude/plan/actual-feature-name.md`**
**Plan generated and saved to `.claude/plan/actual-feature-name.md`**
**Please review the plan above. You can:**
**Please review the plan above. You can:**
- **Modify plan**: Tell me what needs adjustment, I'll update the plan
- **Execute plan**: Copy the following command to a new session
@@ -215,7 +215,7 @@ Synthesize both analyses, generate **Step-by-step Implementation Plan**:
```
---
**NOTE**: The `actual-feature-name.md` above MUST be replaced with the actual saved filename!
**NOTE**: The `actual-feature-name.md` above MUST be replaced with the actual saved filename!
4. **Immediately terminate current response** (Stop here. No more tool calls.)

View File

@@ -89,7 +89,7 @@ Agent:
## Static Analysis Results
✓ ruff: No issues
✓ mypy: No errors
⚠️ black: 2 files need reformatting
WARNING: black: 2 files need reformatting
✓ bandit: No security issues
## Issues Found
@@ -155,7 +155,7 @@ with open("config.json") as f: # Good
- HIGH: 1
- MEDIUM: 2
Recommendation: Block merge until CRITICAL issue is fixed
Recommendation: FAIL: Block merge until CRITICAL issue is fixed
## Formatting Required
Run: `black app/routes/user.py app/services/auth.py`
@@ -165,9 +165,9 @@ Run: `black app/routes/user.py app/services/auth.py`
| Status | Condition |
|--------|-----------|
| Approve | No CRITICAL or HIGH issues |
| ⚠️ Warning | Only MEDIUM issues (merge with caution) |
| Block | CRITICAL or HIGH issues found |
| PASS: Approve | No CRITICAL or HIGH issues |
| WARNING: Warning | Only MEDIUM issues (merge with caution) |
| FAIL: Block | CRITICAL or HIGH issues found |
## Integration with Other Commands

View File

@@ -69,7 +69,7 @@ Deleted: 12 unused functions
Skipped: 2 items (tests failed)
Saved: ~450 lines removed
──────────────────────────────
All tests passing
All tests passing PASS:
```
## Rules

View File

@@ -65,9 +65,9 @@ WHAT WE'RE BUILDING:
[2-3 sentence summary in your own words]
CURRENT STATE:
Working: [count] items confirmed
🔄 In Progress: [list files that are in progress]
🗒️ Not Started: [list planned but untouched]
PASS: Working: [count] items confirmed
In Progress: [list files that are in progress]
Not Started: [list planned but untouched]
WHAT NOT TO RETRY:
[list every failed approach with its reason — this is critical]
@@ -99,10 +99,10 @@ If no next step is defined — ask the user where to start, and optionally sugge
Load the most recently modified matching file for that date, regardless of whether it uses the legacy no-id format or the current short-id format.
**Session file references files that no longer exist:**
Note this during the briefing — "⚠️ `path/to/file.ts` referenced in session but not found on disk."
Note this during the briefing — "WARNING: `path/to/file.ts` referenced in session but not found on disk."
**Session file is from more than 7 days ago:**
Note the gap — "⚠️ This session is from N days ago (threshold: 7 days). Things may have changed." — then proceed normally.
Note the gap — "WARNING: This session is from N days ago (threshold: 7 days). Things may have changed." — then proceed normally.
**User provides a file path directly (e.g., forwarded from a teammate):**
Read it and follow the same briefing process — the format is the same regardless of source.
@@ -126,13 +126,13 @@ Register and login endpoints are partially done. Route protection
via middleware hasn't been started yet.
CURRENT STATE:
Working: 3 items (register endpoint, JWT generation, password hashing)
🔄 In Progress: app/api/auth/login/route.ts (token works, cookie not set yet)
🗒️ Not Started: middleware.ts, app/login/page.tsx
PASS: Working: 3 items (register endpoint, JWT generation, password hashing)
In Progress: app/api/auth/login/route.ts (token works, cookie not set yet)
Not Started: middleware.ts, app/login/page.tsx
WHAT NOT TO RETRY:
Next-Auth — conflicts with custom Prisma adapter, threw adapter error on every request
localStorage for JWT — causes SSR hydration mismatch, incompatible with Next.js
FAIL: Next-Auth — conflicts with custom Prisma adapter, threw adapter error on every request
FAIL: localStorage for JWT — causes SSR hydration mismatch, incompatible with Next.js
OPEN QUESTIONS / BLOCKERS:
- Does cookies().set() work inside a Route Handler or only Server Actions?

View File

@@ -130,10 +130,10 @@ If nothing is queued: "No specific untried approaches identified."
| File | Status | Notes |
| ----------------- | -------------- | -------------------------- |
| `path/to/file.ts` | Complete | [what it does] |
| `path/to/file.ts` | 🔄 In Progress | [what's done, what's left] |
| `path/to/file.ts` | Broken | [what's wrong] |
| `path/to/file.ts` | 🗒️ Not Started | [planned but not touched] |
| `path/to/file.ts` | PASS: Complete | [what it does] |
| `path/to/file.ts` | In Progress | [what's done, what's left] |
| `path/to/file.ts` | FAIL: Broken | [what's wrong] |
| `path/to/file.ts` | Not Started | [planned but not touched] |
If no files were touched: "No files modified this session."
@@ -235,11 +235,11 @@ refreshes without exposing the token to JavaScript.
| File | Status | Notes |
| -------------------------------- | -------------- | ----------------------------------------------- |
| `app/api/auth/register/route.ts` | Complete | Works, tested |
| `app/api/auth/login/route.ts` | 🔄 In Progress | Token generates but not setting cookie yet |
| `lib/auth.ts` | Complete | JWT helpers, all tested |
| `middleware.ts` | 🗒️ Not Started | Route protection, needs cookie read logic first |
| `app/login/page.tsx` | 🗒️ Not Started | UI not started |
| `app/api/auth/register/route.ts` | PASS: Complete | Works, tested |
| `app/api/auth/login/route.ts` | In Progress | Token generates but not setting cookie yet |
| `lib/auth.ts` | PASS: Complete | JWT helpers, all tested |
| `middleware.ts` | Not Started | Route protection, needs cookie read logic first |
| `app/login/page.tsx` | Not Started | UI not started |
---

View File

@@ -133,7 +133,7 @@ FAIL lib/liquidity.test.ts
1 test failed, 0 passed
```
Tests fail as expected. Ready to implement.
PASS: Tests fail as expected. Ready to implement.
## Step 4: Implement Minimal Code (GREEN)
@@ -179,7 +179,7 @@ PASS lib/liquidity.test.ts
3 tests passed
```
All tests passing!
PASS: All tests passing!
## Step 6: Refactor (IMPROVE)
@@ -236,7 +236,7 @@ PASS lib/liquidity.test.ts
3 tests passed
```
Refactoring complete, tests still passing!
PASS: Refactoring complete, tests still passing!
## Step 8: Check Coverage
@@ -247,29 +247,29 @@ File | % Stmts | % Branch | % Funcs | % Lines
---------------|---------|----------|---------|--------
liquidity.ts | 100 | 100 | 100 | 100
Coverage: 100% (Target: 80%)
Coverage: 100% PASS: (Target: 80%)
```
TDD session complete!
PASS: TDD session complete!
```
## TDD Best Practices
**DO:**
- Write the test FIRST, before any implementation
- Run tests and verify they FAIL before implementing
- Write minimal code to make tests pass
- Refactor only after tests are green
- Add edge cases and error scenarios
- Aim for 80%+ coverage (100% for critical code)
- PASS: Write the test FIRST, before any implementation
- PASS: Run tests and verify they FAIL before implementing
- PASS: Write minimal code to make tests pass
- PASS: Refactor only after tests are green
- PASS: Add edge cases and error scenarios
- PASS: Aim for 80%+ coverage (100% for critical code)
**DON'T:**
- Write implementation before tests
- Skip running tests after each change
- Write too much code at once
- Ignore failing tests
- Test implementation details (test behavior)
- Mock everything (prefer integration tests)
- FAIL: Write implementation before tests
- FAIL: Skip running tests after each change
- FAIL: Write too much code at once
- FAIL: Ignore failing tests
- FAIL: Test implementation details (test behavior)
- FAIL: Mock everything (prefer integration tests)
## Test Types to Include

View File

@@ -57,7 +57,7 @@ File Before After
src/services/auth.ts 45% 88%
src/utils/validation.ts 32% 82%
──────────────────────────────
Overall: 67% 84%
Overall: 67% 84% PASS:
```
## Focus Areas