@ryuenn3123/agentic-senior-core 6.16.3 → 6.16.6

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 (84) hide show
  1. package/.agents/plugins/agentic-senior-core/.codex-plugin/plugin.json +1 -1
  2. package/.agents/plugins/agentic-senior-core/commands/asc-pentest.md +2 -0
  3. package/.agents/plugins/agentic-senior-core/commands/asc-pentest.toml +3 -0
  4. package/.agents/plugins/agentic-senior-core/commands/asc-test.md +1 -1
  5. package/.agents/plugins/agentic-senior-core/commands/asc-ui.md +1 -1
  6. package/.agents/plugins/agentic-senior-core/hooks/dedup-gate.js +137 -128
  7. package/.agents/plugins/agentic-senior-core/hooks/hooks.json +97 -0
  8. package/.agents/plugins/agentic-senior-core/hooks/ladder-pulse.js +53 -36
  9. package/.agents/plugins/agentic-senior-core/hooks/lib/known-ui-slop-patterns.json +5 -0
  10. package/.agents/plugins/agentic-senior-core/hooks/path-util.cjs +118 -4
  11. package/.agents/plugins/agentic-senior-core/hooks/post-edit-enforce.js +98 -81
  12. package/.agents/plugins/agentic-senior-core/hooks/pre-tool-dependency-gate.js +168 -191
  13. package/.agents/plugins/agentic-senior-core/hooks/session-pulse.js +48 -35
  14. package/.agents/plugins/agentic-senior-core/hooks/session-start.js +62 -11
  15. package/.agents/plugins/agentic-senior-core/hooks.json +4 -94
  16. package/.agents/plugins/agentic-senior-core/plugin.json +5 -13
  17. package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +3 -1
  18. package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +5 -2
  19. package/.agents/plugins/agentic-senior-core/skills/asc/references/writing-skills.md +1 -1
  20. package/.agents/plugins/agentic-senior-core/skills/asc-develop/SKILL.md +2 -2
  21. package/.agents/plugins/agentic-senior-core/skills/asc-pentest/SKILL.md +97 -0
  22. package/.agents/plugins/agentic-senior-core/skills/asc-pentest/references/api-security-idor.md +105 -0
  23. package/.agents/plugins/agentic-senior-core/skills/asc-pentest/references/dast-baseline.md +78 -0
  24. package/.agents/plugins/agentic-senior-core/skills/asc-pentest/references/fuzzing-dsl.md +66 -0
  25. package/.agents/plugins/agentic-senior-core/skills/asc-pentest/references/pentest-task-tree.md +70 -0
  26. package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +1 -1
  27. package/.agents/plugins/agentic-senior-core/skills/asc-test/SKILL.md +10 -3
  28. package/.agents/plugins/agentic-senior-core/skills/asc-test/references/mutation-testing.md +55 -0
  29. package/.agents/plugins/agentic-senior-core/skills/asc-test/references/performance-budgets.md +67 -0
  30. package/.agents/plugins/agentic-senior-core/skills/asc-test/references/property-testing.md +72 -0
  31. package/.agents/plugins/agentic-senior-core/skills/asc-test/references/regression-proof.md +2 -2
  32. package/.agents/plugins/agentic-senior-core/skills/asc-test/references/tdd-cycle.md +2 -2
  33. package/.agents/plugins/agentic-senior-core/skills/asc-test/references/uat.md +1 -1
  34. package/.agents/plugins/agentic-senior-core/skills/asc-ui/SKILL.md +31 -34
  35. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/accessibility.md +2 -2
  36. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/copy-i18n.md +24 -8
  37. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/craft/color-surfaces.md +32 -0
  38. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/craft/composition-patterns.md +299 -0
  39. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/craft/themes-catalog.md +199 -0
  40. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/divergence.md +65 -24
  41. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/modes/experience.md +4 -0
  42. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/modes/genre-calibration.md +93 -0
  43. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/modes/operate.md +31 -1
  44. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/modes/persuade.md +33 -23
  45. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/modes/read.md +4 -0
  46. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/redesign-audit.md +5 -10
  47. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/states-feedback.md +2 -2
  48. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-attio-dom.json +5 -0
  49. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-attio.png +0 -0
  50. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-cal-dom.json +5 -0
  51. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-cal.png +0 -0
  52. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-clerk-dom.json +5 -0
  53. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-clerk.png +0 -0
  54. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-dub-dom.json +5 -0
  55. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-dub.png +0 -0
  56. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-linear-dom.json +5 -0
  57. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-linear.png +0 -0
  58. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-marketplace-dom.json +5 -0
  59. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-marketplace.png +0 -0
  60. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-mintlify-dom.json +5 -0
  61. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-mintlify.png +0 -0
  62. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-raycast-dom.json +5 -0
  63. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-raycast.png +0 -0
  64. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-resend-dom.json +5 -0
  65. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-resend.png +0 -0
  66. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-stripe-dom.json +5 -0
  67. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-stripe.png +0 -0
  68. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-supabase-dom.json +5 -0
  69. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-supabase.png +0 -0
  70. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-tldraw-dom.json +5 -0
  71. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-tldraw.png +0 -0
  72. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-vercel-dom.json +5 -0
  73. package/.agents/plugins/agentic-senior-core/skills/asc-ui/references/visuals/real-vercel.png +0 -0
  74. package/bin/agentic-senior-core.js +19 -4
  75. package/gemini-extension.json +2 -2
  76. package/lib/cli/ascx/runtime.mjs +5 -27
  77. package/lib/cli/ascx/windows-spawn.mjs +348 -0
  78. package/lib/cli/commands/bootstrap.mjs +56 -0
  79. package/lib/cli/commands/dedup.mjs +500 -0
  80. package/lib/cli/commands/git-hook-generator.mjs +3 -2
  81. package/lib/cli/commands/global.mjs +109 -53
  82. package/lib/cli/commands/preview.mjs +34 -20
  83. package/package.json +1 -1
  84. package/plugin.yaml +3 -1
@@ -0,0 +1,70 @@
1
+ # The Pentesting Task Tree (PTT) Protocol
2
+
3
+ Derived from the USENIX Security architecture of **PentestGPT**. Prevents conversational context drift and maintains rigorous state tracking across multi-turn security engagements.
4
+
5
+ ---
6
+
7
+ ## 1. Task Taxonomies
8
+
9
+ Every security evaluation action must map to one of six explicit task kinds:
10
+
11
+ | Task Kind | Intent & Scope | Entry Criteria | Exit Criteria |
12
+ |---|---|---|---|
13
+ | **`DISCOVER`** | Network and surface mapping. Extract routes, ports, endpoints, and authentication schemes from source or running app. | Target URL / source repository provided. | Exhaustive inventory of accessible routes and protocols documented in session ledger. |
14
+ | **`ENUMERATE`** | Parameter and contract analysis. Identify parameter types, required fields, and boundary expectations per route. | Route inventory established. | Input vectors mapped (query parameters, body schema, headers, cookies). |
15
+ | **`TEST`** | Dynamic vulnerability probing. Execute targeted fuzzing, payload injection, or authorization checks. | Target parameters identified. | Target behavior analyzed; anomalies (5xx errors, reflection, unauthorized data) logged. |
16
+ | **`EXPLOIT`** | Proof-of-exploit verification. Formulate a minimal, non-destructive reproduction proving the vulnerability is real. | Anomaly confirmed under `TEST`. | Deterministic `curl` script or test assertion proving the vulnerability exists. |
17
+ | **`VERIFY`** | Patch verification. Re-run the reproduction script after developer code remediation. | Code patch applied. | Reproduction script fails (vulnerability successfully mitigated). |
18
+ | **`RECOVER`** | Environment restoration. Purge canary entities, tokens, or temporary records injected during testing. | Engagement complete or failed. | Database and filesystem confirmed clean of canary records. |
19
+
20
+ ---
21
+
22
+ ## 2. Task State Transitions
23
+
24
+ Tasks progress through a deterministic state machine:
25
+
26
+ ```
27
+ ┌─────────┐ Dependencies Met ┌─────────┐ Execution Start ┌──────────┐
28
+ │ BLOCKED │ ─────────────────────────► │ READY │ ────────────────────────► │ ACTIVE │
29
+ └─────────┘ └─────────┘ └────┬─────┘
30
+ │
31
+ ┌─────────────────────────────────────┴──────────┐
32
+ ▼ ▼
33
+ ┌─────────┐ ┌──────────┐
34
+ │ DONE │ │ FAILED │
35
+ └─────────┘ └──────────┘
36
+ ```
37
+
38
+ - **`BLOCKED`**: Prerequisites (e.g. valid auth token, route discovery) not yet satisfied.
39
+ - **`READY`**: All `depends_on` tasks have reached `DONE`.
40
+ - **`ACTIVE`**: Currently executing under a single task lease.
41
+ - **`DONE`**: Target objective fulfilled; basis artifacts recorded.
42
+ - **`FAILED`**: Execution failed or payload rejected; requires recovery or strategy adaptation.
43
+
44
+ ---
45
+
46
+ ## 3. Session Ledger Format (`scratch/pentest-session.md`)
47
+
48
+ When executing an engagement spanning more than 2 steps, initialize a session ledger in the scratch directory:
49
+
50
+ ```markdown
51
+ # Pentest Session Ledger: [Target Name]
52
+ Target URL: http://localhost:8000
53
+ Session Started: YYYY-MM-DD HH:MM:SS
54
+
55
+ ## Active Task Tree
56
+ - [x] T01 [DISCOVER]: Route inventory from src/routes/ (DONE)
57
+ - [x] T02 [ENUMERATE]: Parameter mapping on /api/v1/invoices/:id (DONE)
58
+ - [x] T03 [TEST]: BOLA check with secondary tenant token (DONE)
59
+ - [ ] T04 [EXPLOIT]: Minimal curl proof demonstrating horizontal data leakage (ACTIVE)
60
+ - [ ] T05 [VERIFY]: Re-check after authorization policy middleware applied (BLOCKED on T04)
61
+ - [ ] T06 [RECOVER]: Purge canary tenant records from test database (BLOCKED on T05)
62
+
63
+ ## Findings Ledger
64
+ ### F01: BOLA on GET /api/v1/invoices/:id
65
+ - Severity: CRITICAL
66
+ - Location: routes/invoices.js:45
67
+ - Finding: Route queries DB by `id` directly without filtering by `tenant_id` from auth context.
68
+ - Evidence: Peer B token successfully retrieved Invoice #1042 owned by Tenant A.
69
+ ```
70
+
@@ -32,7 +32,7 @@ Use when reviewing PRs, diffs, commits, or newly written feature code.
32
32
  ### Review Procedure
33
33
  1. **Scope Inspection**: Run `git diff --stat` (or `git status`) to inspect modified files and line deltas.
34
34
  2. **Test-Change Correlation**: For every modified application logic file, verify that a corresponding test was updated. If logic changed without tests, flag as missing test coverage.
35
- 3. **Deterministic Verification**: Run project linter and test suite (`ascx test` / `npm test`). Confirm exit code 0 fresh.
35
+ 3. **Deterministic Verification**: Run project linter and test suite (`ascx npm test`). Confirm exit code 0 fresh.
36
36
  4. **Severity Priority Order**:
37
37
  - **Severity 1 (Critical)**: Correctness, data corruption, auth/permission bypass, security sinks, PII leakage.
38
38
  - **Severity 2 (High)**: Action feedback failures (hanging spinners, unhandled mutations, missing error boundaries), unhandled async rejections, missing remote timeouts.
@@ -10,9 +10,9 @@ Staff-grade testing playbook and verification gates. Enforces test-first discipl
10
10
 
11
11
  ---
12
12
 
13
- ## 1. The Iron Law of TDD
13
+ ## 1. Test-Driven Development Protocol
14
14
 
15
- > **THE IRON LAW:** No production code shall be written without a failing test first.
15
+ > **CORE PROTOCOL:** No production code shall be written without a failing test first.
16
16
 
17
17
  Every feature, bugfix, or refactor must follow the Red-Green-Refactor sequence:
18
18
  1. **RED:** Write a minimal failing test. Execute it and confirm it fails for the expected reason.
@@ -33,6 +33,9 @@ Before writing tests, running suites, or claiming verification:
33
33
  1. **Mandatory Ingestion (BLOCKING GATE):** Call `read_file` on the tier reference matching your testing requirement BEFORE taking action:
34
34
  - Writing unit tests / TDD cycle ➔ `references/tdd-cycle.md`
35
35
  - Behavior testing, boundary isolation, mocks/fakes ➔ `references/test-design.md`
36
+ - Generative property invariants & fuzzing ➔ `references/property-testing.md`
37
+ - Mutation testing & assertion integrity ➔ `references/mutation-testing.md`
38
+ - Concurrency latency & performance budgets ➔ `references/performance-budgets.md`
36
39
  - Playwright browser tests, locators, page objects ➔ `references/e2e-playwright.md`
37
40
  - Acceptance criteria, UAT checklists, edge case quads ➔ `references/uat.md`
38
41
  - Bug reproduction, root-cause verification, regression proof ➔ `references/regression-proof.md`
@@ -104,6 +107,9 @@ Select the lowest testing tier that validates the requirement:
104
107
  |---|---|
105
108
  | Red-Green-Refactor mechanics & whole-suite checks | `references/tdd-cycle.md` |
106
109
  | Behavior testing, boundary isolation & mocking | `references/test-design.md` |
110
+ | Generative property invariants & boundary fuzzing | `references/property-testing.md` |
111
+ | Mutation integrity score (>= 80%) & mutant triage | `references/mutation-testing.md` |
112
+ | Latency budgets (p95 <= 150ms) & concurrency benchmarking | `references/performance-budgets.md` |
107
113
  | Playwright E2E, reconnaissance & locator hierarchy | `references/e2e-playwright.md` |
108
114
  | Given/When/Then acceptance criteria & edge case quad | `references/uat.md` |
109
115
  | 3-step bugfix verification & regression proof | `references/regression-proof.md` |
@@ -118,5 +124,6 @@ Before declaring any coding or testing task complete:
118
124
  2. **Regression Proof:** For bugfixes, confirm the test failed without the fix and passes with it.
119
125
  3. **Whole-Suite Run:** Execute the full test suite (`ascx npm test` or project test runner); confirm exit code 0.
120
126
  4. **No Assertions Weakened:** Verify no existing test assertions were deleted or commented out to simulate success.
121
- 5. **Hermetic State:** Ensure tests clean up temporary files, database records, and environment variables.
127
+ 5. **Mutation Sanity:** For critical authorization or business logic, verify tests catch condition inversion.
128
+ 6. **Hermetic State:** Ensure tests clean up temporary files, database records, and environment variables.
122
129
 
@@ -0,0 +1,55 @@
1
+ # Mutation Testing & Test Suite Integrity
2
+
3
+ Staff-grade guidelines for mutation testing and eradicating false-positive test suites. Grounded in the principles of **Stryker Mutator**.
4
+
5
+ ---
6
+
7
+ ## 1. The Fallacy of Code Coverage
8
+
9
+ Code coverage (line, branch, or statement coverage) measures only what code was executed; it does **not** measure whether assertions were made:
10
+ ```javascript
11
+ // A test with 100% line coverage and ZERO verification value:
12
+ it('calculates invoice total', () => {
13
+ const result = calculateTotal(mockCart);
14
+ // No assertions! Or weak assertion: assert.ok(result);
15
+ });
16
+ ```
17
+ Such tests give false confidence: business logic can break completely while 100% of tests continue to pass.
18
+
19
+ **Mutation testing** tests the test suite: it introduces small synthetic defects (**mutants**) into the production code. If your tests fail, the mutant is **killed** (good). If your tests pass despite the corrupted logic, the mutant **survives** (flawed test coverage).
20
+
21
+ ---
22
+
23
+ ## 2. Standard Mutant Operators
24
+
25
+ | Mutant Class | Original Code | Mutated Code | Verification Test Expectation |
26
+ |---|---|---|---|
27
+ | **Equality Operator** | `if (user.role === 'admin')` | `if (user.role !== 'admin')` | Test asserting admin access must fail immediately. |
28
+ | **Relational Boundary** | `if (balance >= price)` | `if (balance > price)` | Boundary test where `balance === price` must fail. |
29
+ | **Logical Connector** | `if (hasToken && isValid)` | `if (hasToken \|\| isValid)` | Test with valid token and invalid state must fail. |
30
+ | **Return Constant** | `return totalAmount;` | `return 0;` or `return null;` | Result consumer assertion must fail. |
31
+ | **Statement Deletion** | `await auditLog.record(event);` | `/* deleted */` | Audit persistence assertion must fail. |
32
+
33
+ ---
34
+
35
+ ## 3. The Mutation Integrity Score
36
+
37
+ $$\text{Mutation Score} = \left( \frac{\text{Killed Mutants}}{\text{Total Mutants}} \right) \times 100\%$$
38
+
39
+ - **Target Threshold**: Core business logic, pricing, authorization checks, and security boundaries must achieve a Mutation Score of $\ge 80\%$.
40
+ - **Survived Mutant Triage**:
41
+ - Every survived mutant indicates an untested boundary or missing assertion.
42
+ - Fix: Do not modify production code; write a specific failure assertion that kills the surviving mutant.
43
+
44
+ ---
45
+
46
+ ## 4. The Agentic Mutant Sanity Check
47
+
48
+ When introducing or refactoring a critical function (e.g. auth check, payment math, permissions):
49
+ 1. **Identify the core decision branch** (e.g. `if (isAuthorized) return allow();`).
50
+ 2. **Inject a manual mutant**: temporarily invert the condition (`if (!isAuthorized)`).
51
+ 3. **Run the test runner**:
52
+ - If tests still pass $\to$ **FLAG AS CRITICAL TEST DEFECT**. Your tests are not testing the logic.
53
+ - Add the missing negative test case until the mutant is killed.
54
+ 4. **Revert the mutant** and confirm the full test suite turns green.
55
+
@@ -0,0 +1,67 @@
1
+ # Performance Budgets & Concurrency Benchmarking
2
+
3
+ Staff-grade guidelines for performance testing, latency budgets, and concurrency verification. Grounded in the principles of **Grafana k6**.
4
+
5
+ ---
6
+
7
+ ## 1. Latency Budgets & Percentiles
8
+
9
+ Averages mask performance degradation. A service with an average response time of $50\text{ms}$ can still have $10\%$ of users waiting over $1,500\text{ms}$. Performance must be budgeted and measured using **percentiles**:
10
+
11
+ | Metric | Target Standard | Operational Context |
12
+ |---|---|---|
13
+ | **Unit Logic Runtime** | $\le 5\text{ms}$ | Pure algorithms, mathematical transforms, string parsers. |
14
+ | **$p_{50}$ (Median Latency)** | $\le 50\text{ms}$ | Standard read operations with warm database index. |
15
+ | **$p_{95}$ (95th Percentile)** | $\le 150\text{ms}$ | 95 out of 100 requests must complete under this budget. |
16
+ | **$p_{99}$ (Worst-case Tail)** | $\le 300\text{ms}$ | Tail latency under concurrency and database lock contention. |
17
+ | **Error Rate Threshold** | Strictly $0.00\%$ | Zero 5xx errors or dropped socket connections under target load. |
18
+
19
+ ---
20
+
21
+ ## 2. Micro-Benchmark Concurrency Harness
22
+
23
+ For critical endpoints, verify concurrency resilience using a native script before handoff:
24
+
25
+ ```javascript
26
+ import assert from 'node:assert/strict';
27
+
28
+ async function benchmarkEndpoint(url, concurrentRequests = 10, totalRequests = 50) {
29
+ const durations = [];
30
+ const runBatch = async () => {
31
+ const start = performance.now();
32
+ const res = await fetch(url);
33
+ const duration = performance.now() - start;
34
+ assert.equal(res.status, 200, `Expected 200, got ${res.status}`);
35
+ durations.push(duration);
36
+ };
37
+
38
+ // Run in chunks of `concurrentRequests`
39
+ for (let i = 0; i < totalRequests; i += concurrentRequests) {
40
+ await Promise.all(Array.from({ length: concurrentRequests }, runBatch));
41
+ }
42
+
43
+ durations.sort((a, b) => a - b);
44
+ const p50 = durations[Math.floor(durations.length * 0.50)];
45
+ const p95 = durations[Math.floor(durations.length * 0.95)];
46
+
47
+ console.log(`Benchmark: N=${totalRequests} | p50=${p50.toFixed(1)}ms | p95=${p95.toFixed(1)}ms`);
48
+ assert.ok(p95 <= 150, `p95 exceeded budget: ${p95.toFixed(1)}ms > 150ms`);
49
+ }
50
+ ```
51
+
52
+ ---
53
+
54
+ ## 3. Memory Leak & Garbage Collection Invariants
55
+
56
+ Under sustained request loops, memory footprint must reach a steady plateau rather than growing monotonically:
57
+
58
+ 1. **Heap Growth Check**:
59
+ - Record `process.memoryUsage().heapUsed` before iteration loop.
60
+ - Run $1,000$ iterations of the business operation.
61
+ - Trigger garbage collection (or sample at $N=1000$).
62
+ - Assert heap growth is bounded ($\le 10\%$ increase from baseline).
63
+ 2. **Common Culprits**:
64
+ - Global event listeners (`emitter.on()`) attached inside request handlers without removal.
65
+ - Unbounded in-memory caches or map accumulators without LRU eviction.
66
+ - Retained references inside closures of unresolved promises.
67
+
@@ -0,0 +1,72 @@
1
+ # Generative Property-Based Testing & Invariant Fuzzing
2
+
3
+ Staff-grade guidelines for property-based testing and generative fuzzing. Grounded in the principles of **Hypothesis** and **fast-check**.
4
+
5
+ ---
6
+
7
+ ## 1. Example-Based vs. Property-Based Testing
8
+
9
+ Standard unit tests validate specific, hand-picked examples:
10
+ ```javascript
11
+ // Example-based: tests 1 trivial scenario
12
+ assert.equal(parsePrice("$19.99"), 1999);
13
+ ```
14
+ Example-based tests suffer from confirmation bias: developers only test inputs they already anticipate.
15
+
16
+ **Property-based testing** flips the testing paradigm: you define universal system **invariants** (truths that must hold for ALL possible inputs), and the engine executes hundreds or thousands of randomized boundary inputs to prove or disprove the property:
17
+ ```javascript
18
+ import fc from 'fast-check';
19
+
20
+ // Property-based: tests 100+ generated inputs across extreme boundaries
21
+ fc.assert(
22
+ fc.property(fc.integer({ min: 0, max: 1000000 }), (cents) => {
23
+ const formatted = formatCurrency(cents);
24
+ return parseCurrency(formatted) === cents; // Invariant: round-trip fidelity
25
+ })
26
+ );
27
+ ```
28
+
29
+ ---
30
+
31
+ ## 2. Core Invariant Archetypes
32
+
33
+ Every complex business module should be tested against at least one of these four invariant patterns:
34
+
35
+ | Invariant Pattern | Definition | Canonical Example |
36
+ |---|---|---|
37
+ | **Round-Trip (Serialization)** | Transforming $A \to B \to A$ preserves exact identity. | `deserialize(serialize(record)) === record`<br>`base64Decode(base64Encode(data)) === data` |
38
+ | **Idempotence** | Applying an operation multiple times yields the same result as applying it once. | `format(format(input)) === format(input)`<br>`cleanHtml(cleanHtml(dirty)) === cleanHtml(dirty)` |
39
+ | **Crash Invariance (No 5xx)** | No valid or invalid input shall trigger an unhandled exception or server crash. | For any generated string $s$, `parseAddress(s)` returns a parsed object OR a safe `ValidationFailure` without throwing uncaught errors. |
40
+ | **Monotonicity & Invariance** | Mathematical or business logic ordering invariants. | Adding an item to a cart never decreases the cart subtotal (`subtotal(cart + item) >= subtotal(cart)`). |
41
+
42
+ ---
43
+
44
+ ## 3. Boundary Input Generators
45
+
46
+ When testing pure functions or data transformations, generators must evaluate pathological boundary inputs:
47
+
48
+ 1. **Numeric Boundaries**:
49
+ - `0`, `-0`, `1`, `-1`
50
+ - `Number.MIN_SAFE_INTEGER`, `Number.MAX_SAFE_INTEGER`
51
+ - `Infinity`, `-Infinity`, `NaN`
52
+ - Floating-point precision traps (`0.1 + 0.2`)
53
+ 2. **String Boundaries**:
54
+ - Empty string `""`
55
+ - Strings with null bytes (`"canary\0danger"`)
56
+ - Unicode RTL override characters (`\u202E`) and emojis
57
+ - Extremely large strings ($10^5$ characters)
58
+ - Unpaired surrogate halves (`\uD800`)
59
+ 3. **Collection & Tree Boundaries**:
60
+ - Empty arrays `[]`, single-element `[x]`, arrays with duplicates `[x, x]`.
61
+ - Deeply nested objects (depth $> 30$).
62
+ - Objects with prototype poisoning keys (`__proto__`, `constructor`).
63
+
64
+ ---
65
+
66
+ ## 4. Failure Shrinking
67
+
68
+ When a property test fails on a massive random input (e.g. an array of 500 items containing a string of 4,000 characters), the property testing runner automatically **shrinks** the failure down to the minimal counterexample that still reproduces the bug (e.g. `['\0']`).
69
+
70
+ **Operational Rule**:
71
+ When documenting a property test failure, always report the **minimal shrunk counterexample** rather than the full randomized run seed.
72
+
@@ -36,7 +36,7 @@ Never fix a bug by immediately editing production code. Follow this deterministi
36
36
  - Edit production code to eliminate the bug.
37
37
  - Run the reproduction test fresh: it must pass with exit code 0.
38
38
 
39
- ### Step 3: The Regression Proof Gate (Revert & Confirm)
39
+ ### Step 3: Regression Verification (Revert & Confirm)
40
40
  To prove that the test actually guards against the bug:
41
41
  1. Temporarily comment out or revert the fix in production code.
42
42
  2. Run the test fresh: **The test must fail.**
@@ -45,7 +45,7 @@ To prove that the test actually guards against the bug:
45
45
 
46
46
  ---
47
47
 
48
- ## 2. Claim Verification Gate
48
+ ## 2. Claim Verification Standards
49
49
 
50
50
  Every claim regarding test results or bug fixes requires concrete execution evidence:
51
51
 
@@ -1,8 +1,8 @@
1
1
  # Test-Driven Development (TDD) Cycle
2
2
 
3
- TDD is an architectural discipline for writing deterministic, verifiable software. The Iron Law of TDD governs all development:
3
+ TDD is an architectural discipline for writing deterministic, verifiable software. The core principle governs all development:
4
4
 
5
- > **THE IRON LAW:** No production code shall be written without a failing test first.
5
+ > **Core Principle:** No production code shall be written without a failing test first.
6
6
 
7
7
  ---
8
8
 
@@ -42,7 +42,7 @@ Verification records, testing matrices, and UAT notes belong in the agent conver
42
42
 
43
43
  ---
44
44
 
45
- ## 4. The Edge Case Quad
45
+ ## 4. Boundary & Edge Case Categories
46
46
 
47
47
  Never sign off on acceptance testing by verifying only the primary happy path. Every scenario must be verified against four operational vectors:
48
48
 
@@ -27,9 +27,12 @@ Every UI edit must satisfy these 15 rules without exception:
27
27
  11. **Mobile containment:** Set `overflow-x: clip` on root shells. Never leak horizontal scrolling.
28
28
  12. **Touch targets:** Minimum 44×44px hit target with $\ge$ 8px clearance for all interactive touch controls.
29
29
  13. **Contrast floor:** Meet WCAG 2.2 AA (4.5:1 normal text, 3:1 large text and UI component boundaries).
30
- 14. **Single-language purity:** Never mix languages on one surface; ban hybrid neologisms (`di-submit`, `meng-generate`).
30
+ 14. **Single-language purity:** Never mix languages on one surface; preserve monolingual consistency across headings, labels, errors, and actions.
31
31
  15. **Icon semantics:** Never use raw unicode or emojis as icons. Use dedicated SVG icons; mark decorative icons `aria-hidden="true"`.
32
32
  16. **Substance over restraint:** Stripping slop is only half the job. Replace removed ornaments with real substance: strong typographic scale contrast, full-field color anchors, and authentic interface fragments. Never leave an empty, sterile wireframe void.
33
+ 17. **Product over skill (No geek cosplay):** The real-world domain dictates aesthetics. Never inject terminal windows, ASCII art, or pseudo-telemetry consoles into civic, educational, or commercial products (`references/modes/genre-calibration.md`).
34
+ 18. **The Purpose-Gate:** Every component, widget, or scorecard must enable an actual user task. Never invent unearned widgets, sliders, or simulated feeds without real business data.
35
+ 19. **Anti-card-soup invariant:** Never wrap structural layout sections (header, nav, rails, tables) into floating rounded card islands. Use a Unified Spatial Canvas with hairline dividers (`divide-y`, `border-r`). Cards are strictly for discrete, interchangeable items (`references/divergence.md`).
33
36
 
34
37
  ---
35
38
 
@@ -37,29 +40,17 @@ Every UI edit must satisfy these 15 rules without exception:
37
40
 
38
41
  Before declaring markup, drafting redesign plans, or inspecting user code:
39
42
 
40
- 1. **Locate Skill Directory & References (MANDATORY):**
41
- Reference files do NOT reside in the user workspace root. They are located adjacent to this `SKILL.md` file:
42
- `<skill_directory>/references/<category>/<file>.md`
43
- Identify the path of this `SKILL.md` file (provided by host/tooling) and resolve all reference paths relative to it.
44
-
45
- 2. **Step 1 — Surface Mode Ingestion (MANDATORY GATE):**
46
- Classify the surface and execute `read_file` on the corresponding mode reference BEFORE inspecting files or writing code:
47
- - Dashboards, settings, data tables, developer tools ➔ `references/modes/operate.md`
48
- - Landing pages, pricing tiers, conversion flows ➔ `references/modes/persuade.md`
49
- - Documentation, changelogs, knowledge bases ➔ `references/modes/read.md`
50
- - Showcases, portfolios, interactive galleries ➔ `references/modes/experience.md`
51
- *Do NOT proceed until you have read the mode reference into context.*
52
-
53
- 3. **Step 2 — Secondary Craft Ingestion:**
54
- Execute `read_file` on at least one relevant craft reference for your task from Section 5 (e.g. `references/craft/typography.md`, `references/craft/color-surfaces.md`, or `references/divergence.md`).
55
-
56
- 4. **Step 3 — Workspace Material Inventory:**
57
- Only AFTER loading the mode reference, inspect the workspace:
58
- - **Design Tokens:** Read project CSS variables, Tailwind configuration, or existing components in `components/` or `ui/`. If `DESIGN.md` exists, read it (read-only). Never create or edit persistent checkpoint files.
59
- - **Take Material Inventory:**
60
- - **Real:** Concrete numbers, existing endpoints, actual data attributes.
61
- - **Pictures:** Actual screenshots and product visual assets.
62
- - **Absent:** Missing quotes, missing logos, or unverified metrics—these are omitted entirely.
43
+ 1. **Step 1 — Workspace Brand Audit (Brownfield vs Greenfield):**
44
+ - Check project styling configuration: `app.css`, `globals.css`, `tailwind.config.*`, or `components/ui`.
45
+ - **Brownfield Rule:** If the project already defines brand tokens (e.g. custom brand colors, established fonts, existing UI library), **DO NOT OVERRIDE THEM**. Calibrate neutrals to the brand's color temperature (single neutral family law) and respect established naming.
46
+ - **Greenfield Fallback:** If the repository is brand new with zero tokens, read `references/modes/genre-calibration.md` and select a starting palette from `references/craft/themes-catalog.md`.
47
+ 2. **Step 2 — Silent Discipline & Real Visual Benchmarks:**
48
+ - Review `references/craft/composition-patterns.md` and inspect matching `references/visuals/real-*.png` / `*-dom.json` for authentic human-designed spacing and layout hierarchies rather than enclosing sections in repetitive `1px` boxes.
49
+ - **Silent Meta-Rules:** Never emit internal framework rules, theme catalog names, or parenthetical foreign translations in user deliverables. Focus purely on technical facts.
50
+ 3. **Step 3 — Workspace Material Inventory:**
51
+ - **Real:** Concrete numbers, existing endpoints, actual data attributes from controllers/models.
52
+ - **Pictures:** Actual screenshots and product visual assets.
53
+ - **Absent:** Missing quotes, missing logos, or unverified metrics—these are omitted entirely.
63
54
 
64
55
  ---
65
56
 
@@ -79,7 +70,7 @@ Visual posture is governed by the surface type, not product branding. Every surf
79
70
  Never split the difference into cosmetic polish on a discarded look:
80
71
  - **Polish / Refinement:** Preserves layout structure, DOM hierarchy, and design tokens. Resolves contrast, missing state quad, microcopy, and lint issues.
81
72
  - **Restyle:** Preserves layout geometry. Replaces color tokens, typographic scales, corner radiuses, and elevation shadows.
82
- - **Full Redesign:** Replaces entire spatial geometry and posture. Mandatory decoupled protocol: extract data/contracts first, discard old DOM, author standalone preview (`asc preview <path>`), build fresh geometry, re-bind dynamic data.
73
+ - **Full Redesign:** Replaces entire spatial geometry and posture. Mandatory decoupled protocol: extract data/contracts first, discard old DOM, establish clear spatial posture and theme tokens, and compile directly to production files with complete layout coherence.
83
74
 
84
75
  ---
85
76
 
@@ -90,16 +81,20 @@ Never split the difference into cosmetic polish on a discarded look:
90
81
 
91
82
  | Target Domain / Task Requirement | Mandatory Reference Path |
92
83
  |---|---|
84
+ | Domain & genre calibration (Anti-geek cosplay) | `references/modes/genre-calibration.md` |
85
+ | Concrete structural layouts & anti-1px cage | `references/craft/composition-patterns.md` |
86
+ | Real-world visual benchmarks & rendered DOMs | `references/visuals/` (13 live domains) |
87
+ | Curated material themes (Greenfield reference) | `references/craft/themes-catalog.md` |
93
88
  | Waivable defaults & waiver syntax | `references/reflexes.md` |
94
89
  | Typography, line-height & tabular numbers | `references/craft/typography.md` |
95
- | Color tokens, 60-30-10 & elevation | `references/craft/color-surfaces.md` |
90
+ | Color tokens, single neutral family & elevation | `references/craft/color-surfaces.md` |
96
91
  | Micro-interactions & GPU motion | `references/craft/motion.md` |
97
92
  | Native surfaces (selection, caret, scrollbars) | `references/craft/browser-surfaces.md` |
98
- | 50% reduction, active verbs & i18n | `references/copy-i18n.md` |
93
+ | 50% reduction, active verbs & natural i18n | `references/copy-i18n.md` |
99
94
  | Responsive reflow, dvh & touch targets | `references/mobile-responsive.md` |
100
95
  | WCAG 2.2 AA contrast & keyboard operability | `references/accessibility.md` |
101
- | The Data State Quad & mutation feedback | `references/states-feedback.md` |
102
- | Anti-convergence, 3 Waves of Tells & Mirror Test | `references/divergence.md` |
96
+ | The Data State System & mutation feedback | `references/states-feedback.md` |
97
+ | Anti-convergence & layout diversity | `references/divergence.md` |
103
98
  | Structured UI audit matrix | `references/redesign-audit.md` |
104
99
 
105
100
  ---
@@ -107,8 +102,10 @@ Never split the difference into cosmetic polish on a discarded look:
107
102
  ## 6. Verification & Handoff Sweep
108
103
 
109
104
  Before completing any UI task, run this mechanical check:
110
- 1. **Reference Compliance:** Confirm constraints from the loaded `references/modes/<mode>.md` and craft references were strictly applied.
111
- 2. **State Quad:** Loading skeleton, empty state, error with retry, and populated data are all handled.
112
- 3. **Pending Feedback:** Buttons disable and display feedback during ongoing mutations.
113
- 4. **Contrast & Focus:** Verify keyboard tab flow and high-contrast `:focus-visible` styling.
114
- 5. **Lint Check:** Verify changes against `hooks/lib/known-ui-slop-patterns.json`.
105
+ 1. **Brand & Reference Compliance:** Confirm project tokens were respected (or greenfield constraints followed). Verify zero clumsy literal translations or meta-jargon leaks.
106
+ 2. **Finish Gate Sweep:** Verify zero text clipping (+30% expansion buffer), zero awkward text wraps, and 4px/8px spacing grid consistency.
107
+ 3. **Visual Verification (`asc preview`):** If a local dev server is running or an HTML prototype exists, run `asc preview <url|file> [--mobile]` to inspect the rendered visual balance before handoff.
108
+ 4. **Data States:** Loading skeleton, empty state, error with retry, and populated data are all handled.
109
+ 5. **Pending Feedback:** Buttons disable and display feedback during ongoing mutations.
110
+ 6. **Contrast & Focus:** Verify keyboard tab flow and high-contrast `:focus-visible` styling.
111
+ 7. **Lint Check:** Verify changes against `hooks/lib/known-ui-slop-patterns.json`.
@@ -4,7 +4,7 @@ Accessibility is not an afterthought or an optional overlay. It is the structura
4
4
 
5
5
  ---
6
6
 
7
- ## 1. Contrast Ratios & The Grey-on-Grey Trap
7
+ ## 1. Contrast Ratios & WCAG Compliance
8
8
 
9
9
  All text and critical visual indicators must meet WCAG 2.2 Level AA mathematical contrast floors.
10
10
 
@@ -13,7 +13,7 @@ All text and critical visual indicators must meet WCAG 2.2 Level AA mathematical
13
13
  - **Large Text ($\ge$ 18pt / 24px regular, $\ge$ 14pt bold):** Minimum `3:1` contrast ratio.
14
14
  - **UI Components & Graphical Boundaries:** Active input borders, toggle switches, and focus indicators require minimum `3:1` against adjacent background colors.
15
15
 
16
- ### 1.2 The Dark Mode Grey-on-Grey Trap
16
+ ### 1.2 Avoiding Low-Contrast Surfaces
17
17
  A frequent aesthetic failure is using low-contrast grey text for "subtle elegance":
18
18
  - **Failing example:** `text-zinc-500` (`#71717a`) on `bg-zinc-900` (`#18181b`) = **3.8:1** (Fails 4.5:1 AA for body copy).
19
19
  - **Compliant fix:** `text-zinc-400` (`#a1a1aa`) on `bg-zinc-900` = **6.2:1** (Passes AA).
@@ -89,19 +89,35 @@ An operational error message must never produce a dead end or display raw intern
89
89
 
90
90
  ---
91
91
 
92
- ## 6. Single-Language Purity & Anti-Gado-Gado
92
+ ## 6. Single-Language Consistency & Localization
93
93
 
94
- Interfaces must maintain strict language purity. Mixing two languages within the same surface causes cognitive friction and feels unpolished.
94
+ Interfaces and developer communications must maintain strict language purity without robotic or literal translation awkwardness.
95
95
 
96
96
  ### 6.1 Strict Monolingual Surface
97
97
  Choose one language for the entire surface and enforce it across headings, labels, errors, and tooltips:
98
98
  - **English UI:** All copy, actions, and timestamps in English.
99
- - **Indonesian UI:** All copy, actions, and timestamps in standard Indonesian (KBBI/PUEBI).
100
-
101
- ### 6.2 Ban Hybrid Neologisms (Indonesian Context)
102
- Never prefix Indonesian grammatical affixes (`di-`, `meng-`, `ter-`, `pe-`) onto raw English stems:
103
-
104
- | Hybrid Neologism (Banned) | Standard Indonesian | Pure English Alternative |
99
+ - **Indonesian UI:** All copy, actions, and timestamps in natural, standard Indonesian (KBBI/PUEBI).
100
+
101
+ ### 6.2 Codebase Lexicon Supremacy (Anti-Hallucinated Naming)
102
+ Before naming navigation menus, section titles, table columns, or actions in an existing codebase, inspect the project's models, controllers, and view variables:
103
+ - **Respect established domain terms:** Always adopt the exact nouns established in the repository's models, routes, and translations. Never substitute recognized project nouns with unprompted external synonyms.
104
+ - Use the actual terminology the organization and developers already use in their schema and UI.
105
+
106
+ ### 6.3 Ban Robot Translations & Meta-Jargon Parens
107
+ In localized interface and review text:
108
+ 1. **No clumsy literal translations of English layout terms:**
109
+ - Do NOT translate *drawer* into awkward calques; write natural native labels (e.g. "panel samping" or "detail").
110
+ - Do NOT translate *modal* literally; write natural functional terms (e.g. "dialog" or "popup").
111
+ - Do NOT translate *hairline border* as literal anatomy; write "garis tipis 1px" or "garis pemisah".
112
+ - Do NOT translate layout stages into literal theatrical terms; write "layout dua kolom" or "area utama".
113
+ 2. **No parenthetical English jargon leaks:**
114
+ - Never write sentences that append raw English terms in parentheses as translation glosses.
115
+ - Write clear, natural localized prose without meta-framework disclaimers.
116
+
117
+ ### 6.4 Ban Hybrid Neologisms
118
+ Never prefix local grammatical affixes onto foreign language stems:
119
+
120
+ | Hybrid Neologism (Banned) | Standard Native Alternative | Pure English Alternative |
105
121
  |---|---|---|
106
122
  | `di-submit` | `Dikirim` / `Diserahkan` | `Submitted` |
107
123
  | `meng-generate` | `Menghasilkan` / `Membuat` | `Generating` |
@@ -13,6 +13,13 @@ Grounded in: Apple HIG, Google Material Design 3, and Refactoring UI Color Strat
13
13
  - Borders: `border-border`, `border-input`, `border-primary`.
14
14
  - **Zero Raw Hex Literals in Markup:** Never write inline hex values (`#6366f1`, `#3b82f6`) or arbitrary utility classes (`bg-blue-600`) outside the root token definition.
15
15
 
16
+ - **The Single Neutral Family Law (Anti-Muddy Surfaces):**
17
+ - Never mix cool-tinted grays (e.g. Tailwind `slate-*`, with blue undertones) and warm-tinted grays (e.g. `stone-*`, with yellow/brown undertones) on the same screen. Combining `slate-900` text with `stone-50` backgrounds creates a dirty, mismatched optical surface.
18
+ - Choose one neutral temperature matching the project's primary brand:
19
+ - Warm brands (warm green, brown, amber, terracotta) $\to$ pair strictly with `stone` or neutral warm tones.
20
+ - Cool brands (navy, cobalt, cyan, indigo) $\to$ pair strictly with `slate` or cool zinc.
21
+ - Pure monochromatic / minimal brands $\to$ pair with neutral `zinc` or `gray`.
22
+
16
23
  ---
17
24
 
18
25
  ## 2. The 60-30-10 Distribution Rule
@@ -47,3 +54,28 @@ Grounded in: Apple HIG, Google Material Design 3, and Refactoring UI Color Strat
47
54
  - When placing secondary text on a colored or dark surface, tint the text using the parent background hue or foreground token (`text-primary-foreground/70`).
48
55
  - **Never use neutral gray text (`text-slate-400`) on a saturated or colored background.** It produces a muddy, dirty optical illusion.
49
56
 
57
+ ---
58
+
59
+ ## 4. Metric Displays & Scorecards
60
+
61
+ - **Integrated Layout:** Never place an isolated white box with a thin border floating inside an already white or light header canvas.
62
+ - **Anchor Into Layout Chrome:**
63
+ - Integrate scorecards directly into the identity header rail or stage banner using a unified divider (`border-l border-border/80 pl-6`) or structural inset well (`bg-muted/40`).
64
+ - **Semantic Tinting for Evaluation Scores:**
65
+ - When communicating aggregate grades (e.g. `84.20 / 100`, Rank B):
66
+ - Background: subtle semantic tint (`bg-emerald-500/10` or `bg-slate-500/10`).
67
+ - Border: matching tinted hairline (`border border-emerald-500/20`).
68
+ - Typography: tabular numbers (`font-mono tabular-nums`) with clear contrast ($Display \ge 3.5\times Body$).
69
+ - Always position the grading scale key (e.g. `A > 85, B 71-85`) in immediate secondary proximity as muted metadata.
70
+
71
+ ---
72
+
73
+ ## 5. Inline Notifications & Status Banners
74
+
75
+ - **Structured Containers:** Warning notes, disclaimers, or temporary state alerts must reside in clear semantic containers, never dumped as raw floating text between layout sections.
76
+ - **Notification Requirements:** Every alert must reside in a structured callout container:
77
+ - Container: 1px hairline border with matching light background tint (e.g. `border border-amber-500/30 bg-amber-500/10 rounded-md p-3`).
78
+ - Icon Anchor: Dedicated semantic SVG icon (alert circle, triangle) aligned with first line of text.
79
+ - Placement: Positioned immediately above or inside the data table/form it modifies, establishing unmistakable contextual binding.
80
+
81
+