tribunal-kit 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/.manifest.json +78 -0
- package/.agent/ARCHITECTURE.md +19 -244
- package/.agent/history/memory/.memory.idx +2185 -1
- package/.agent/history/memory/MEMORY.md +145 -1
- package/.agent/routing_index.json +3 -2
- package/.agent/rules/GEMINI.md +1 -1
- package/.agent/skill_topic_map.json +218 -0
- package/.agent/skills/agentic-workflows-2026/SKILL.md +76 -0
- package/.agent/skills/ai-app-hardening/SKILL.md +58 -0
- package/.agent/skills/context-engineering-pro/SKILL.md +69 -0
- package/.agent/skills/duckdb-analytical-sql/SKILL.md +55 -0
- package/.agent/skills/edge-ai-mobile/SKILL.md +46 -0
- package/.agent/skills/expo-router-v4/SKILL.md +80 -0
- package/.agent/skills/opentelemetry-observability/SKILL.md +58 -0
- package/.agent/skills/platform-engineering-opentofu/SKILL.md +67 -0
- package/.agent/skills/playwright-ai-e2e/SKILL.md +59 -0
- package/.agent/skills/property-based-testing/SKILL.md +60 -0
- package/.agent/skills/vector-search-pgvector/SKILL.md +77 -0
- package/.agent/skills/zero-trust-passkeys/SKILL.md +85 -0
- package/.agent/workflows/tribunal-full.md +13 -13
- package/README.md +79 -57
- package/SECURITY.md +3 -3
- package/bin/mcp-server.js +180 -34
- package/bin/wrapper.js +7 -4
- package/dist/cli.js +20 -0
- package/dist/commands/memory.js +3 -2
- package/dist/commands/native.js +36 -0
- package/dist/esm/index.mjs +32 -0
- package/dist/index.d.ts +50 -2
- package/package.json +15 -12
- package/scripts/sync-version.js +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: duckdb-analytical-sql
|
|
3
|
+
description: Embedded OLAP analytics, high-speed Parquet/JSON processing, in-memory analytical SQL, and DuckDB integrations in Node.js, Python, and WASM.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/schema_validator.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/schema_validator.js
|
|
10
|
+
skills:
|
|
11
|
+
- sql-pro
|
|
12
|
+
- database-design
|
|
13
|
+
- performance-profiling
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# DuckDB Analytical SQL — Embedded Analytics
|
|
17
|
+
|
|
18
|
+
## Mandatory Pre-Flight Context Inspection
|
|
19
|
+
|
|
20
|
+
Before writing analytical queries:
|
|
21
|
+
1. Direct File Querying → Query Parquet/CSV/JSON directly without importing into a traditional DB
|
|
22
|
+
2. Memory Allocation → Set explicit memory limit (`SET max_memory = '4GB'`) to prevent OOM
|
|
23
|
+
3. Vectorized Engine Usage → Use column-oriented aggregation over line-by-line loops
|
|
24
|
+
|
|
25
|
+
## Node.js DuckDB Parquet Query Pattern
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Database } from 'duckdb-async';
|
|
29
|
+
|
|
30
|
+
export async function runAnalyticalReport(parquetGlobPath: string) {
|
|
31
|
+
const db = await Database.create(':memory:');
|
|
32
|
+
|
|
33
|
+
// Set memory limits for embedded execution
|
|
34
|
+
await db.exec("SET max_memory = '2GB'; SET threads = 4;");
|
|
35
|
+
|
|
36
|
+
const rows = await db.all(`
|
|
37
|
+
SELECT
|
|
38
|
+
date_trunc('day', timestamp) as event_day,
|
|
39
|
+
event_type,
|
|
40
|
+
COUNT(*) as total_count,
|
|
41
|
+
QUANTILE_CONT(duration_ms, 0.95) as p95_latency
|
|
42
|
+
FROM read_parquet(?)
|
|
43
|
+
GROUP BY 1, 2
|
|
44
|
+
ORDER BY 1 DESC
|
|
45
|
+
LIMIT 100
|
|
46
|
+
`, [parquetGlobPath]);
|
|
47
|
+
|
|
48
|
+
return rows;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
53
|
+
|
|
54
|
+
- Verify query execution on sample Parquet dataset without loading entire file into RAM.
|
|
55
|
+
- Benchmark query throughput against memory constraints.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: edge-ai-mobile
|
|
3
|
+
description: On-device mobile AI, CoreML, Android NNAPI, ONNX Runtime Web/Mobile, local LLM execution (SLMs), and sub-10ms privacy-first edge inference.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/bundle_analyzer.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/bundle_analyzer.js
|
|
10
|
+
skills:
|
|
11
|
+
- mobile-developer
|
|
12
|
+
- browser-native-ai
|
|
13
|
+
- performance-profiling
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Edge AI & On-Device Mobile Machine Learning
|
|
17
|
+
|
|
18
|
+
## Mandatory Pre-Flight Context Inspection
|
|
19
|
+
|
|
20
|
+
Before deploying on-device AI models:
|
|
21
|
+
1. Model Quantization → Use 4-bit/8-bit quantized models (GGUF/ONNX) to fit mobile RAM budgets (<500MB)
|
|
22
|
+
2. Hardware Acceleration → Bind inference engine to Apple Neural Engine (ANE) or Android NPU
|
|
23
|
+
3. Fallback Mechanism → Fall back gracefully to cloud LLM API if local inference exceeds latency budget (>200ms)
|
|
24
|
+
|
|
25
|
+
## Mobile ONNX Edge Inference Pattern
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import * as ort from 'onnxruntime-react-native';
|
|
29
|
+
|
|
30
|
+
export async function runLocalEmbeddings(textTokens: number[]): Promise<Float32Array> {
|
|
31
|
+
const session = await ort.InferenceSession.create('model_quantized.onnx', {
|
|
32
|
+
executionProviders: ['cpu'], // Accelerates via ANE/NNAPI internally
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const tensor = new ort.Tensor('int64', new BigInt64Array(textTokens.map(BigInt)), [1, textTokens.length]);
|
|
36
|
+
const feeds = { input_ids: tensor };
|
|
37
|
+
|
|
38
|
+
const results = await session.run(feeds);
|
|
39
|
+
return results.embedding.data as Float32Array;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
44
|
+
|
|
45
|
+
- Verify local memory usage remains under 300MB during active model inference.
|
|
46
|
+
- Measure battery consumption impact.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: expo-router-v4
|
|
3
|
+
description: React Native 0.76+ New Architecture (Fabric/TurboModules), Expo Router v4 typed file-based navigation, native haptics, and biometrics.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/lint_runner.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/lint_runner.js
|
|
10
|
+
skills:
|
|
11
|
+
- mobile-developer
|
|
12
|
+
- mobile-design
|
|
13
|
+
- react-specialist
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Expo Router v4 & React Native New Architecture
|
|
17
|
+
|
|
18
|
+
## Mandatory Pre-Flight Context Inspection
|
|
19
|
+
|
|
20
|
+
Before building mobile navigation or components:
|
|
21
|
+
1. New Architecture Enforcement → Enable Fabric renderer and TurboModules in `app.json` (`"newArchEnabled": true`)
|
|
22
|
+
2. Typed Routing → Use `expo-router` typed routes for safe navigation
|
|
23
|
+
3. Safe Area & Haptics → Wrap screens in `SafeAreaView` and provide subtle `expo-haptics` feedback
|
|
24
|
+
|
|
25
|
+
## Layout Navigation Architecture (`app/_layout.tsx`)
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { Stack } from 'expo-router';
|
|
29
|
+
import { StatusBar } from 'expo-status-bar';
|
|
30
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
31
|
+
|
|
32
|
+
export default function RootLayout() {
|
|
33
|
+
return (
|
|
34
|
+
<SafeAreaProvider>
|
|
35
|
+
<StatusBar style="light" />
|
|
36
|
+
<Stack
|
|
37
|
+
screenOptions={{
|
|
38
|
+
headerStyle: { backgroundColor: '#0f172a' },
|
|
39
|
+
headerTintColor: '#f8fafc',
|
|
40
|
+
animation: 'slide_from_right',
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<Stack.Screen name="index" options={{ title: 'Feed' }} />
|
|
44
|
+
<Stack.Screen name="modal" options={{ presentation: 'modal' }} />
|
|
45
|
+
</Stack>
|
|
46
|
+
</SafeAreaProvider>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Native Haptic Touch Button Component
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import * as Haptics from 'expo-haptics';
|
|
55
|
+
import { Pressable, Text, PressableProps } from 'react-native';
|
|
56
|
+
|
|
57
|
+
interface TouchButtonProps extends PressableProps {
|
|
58
|
+
label: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function TouchButton({ label, onPress, ...props }: TouchButtonProps) {
|
|
62
|
+
return (
|
|
63
|
+
<Pressable
|
|
64
|
+
{...props}
|
|
65
|
+
onPress={(e) => {
|
|
66
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
|
67
|
+
onPress?.(e);
|
|
68
|
+
}}
|
|
69
|
+
className="px-5 py-3 bg-indigo-600 rounded-xl active:scale-95 transition-transform"
|
|
70
|
+
>
|
|
71
|
+
<Text className="text-white font-medium text-center">{label}</Text>
|
|
72
|
+
</Pressable>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
78
|
+
|
|
79
|
+
- Verify zero bridge warnings during navigation.
|
|
80
|
+
- Ensure safe area insets are respected across iOS notch and Android gesture bars.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: opentelemetry-observability
|
|
3
|
+
description: Full-stack distributed tracing, metrics, OpenTelemetry (OTel), Prometheus, Grafana Tempo, and zero-overhead observability instrumentation.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/test_runner.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/test_runner.js
|
|
10
|
+
skills:
|
|
11
|
+
- devops-engineer
|
|
12
|
+
- observability
|
|
13
|
+
- performance-profiling
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# OpenTelemetry Observability — 2026 Telemetry Standards
|
|
17
|
+
|
|
18
|
+
## Mandatory Pre-Flight Context Inspection
|
|
19
|
+
|
|
20
|
+
Before instrumenting applications:
|
|
21
|
+
1. Vendor-Neutral Telemetry → Use standard OpenTelemetry SDKs (OTLP over gRPC/HTTP)
|
|
22
|
+
2. Trace Propagation → Propagate `traceparent` W3C headers across HTTP and message queues
|
|
23
|
+
3. Sampling Policy → Implement head/tail sampling to reduce telemetry storage costs by 80%
|
|
24
|
+
|
|
25
|
+
## Custom Trace & Meter Instrumentation (TypeScript)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { trace, metrics } from '@opentelemetry/api';
|
|
29
|
+
|
|
30
|
+
const tracer = trace.getTracer('user-service', '1.0.0');
|
|
31
|
+
const meter = metrics.getMeter('user-service', '1.0.0');
|
|
32
|
+
|
|
33
|
+
const loginCounter = meter.createCounter('user_logins_total', {
|
|
34
|
+
description: 'Counts total user login attempts',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export async function handleLogin(userId: string) {
|
|
38
|
+
return tracer.startActiveSpan('handleLogin', async (span) => {
|
|
39
|
+
try {
|
|
40
|
+
span.setAttribute('user.id', userId);
|
|
41
|
+
loginCounter.add(1, { status: 'success' });
|
|
42
|
+
// Business logic...
|
|
43
|
+
span.setStatus({ code: 1 }); // OK
|
|
44
|
+
} catch (err: any) {
|
|
45
|
+
span.recordException(err);
|
|
46
|
+
span.setStatus({ code: 2, message: err.message }); // Error
|
|
47
|
+
throw err;
|
|
48
|
+
} finally {
|
|
49
|
+
span.end();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
56
|
+
|
|
57
|
+
- Verify traces connect seamlessly from frontend click to DB query.
|
|
58
|
+
- Confirm telemetry exporter overhead adds < 1ms latency to HTTP handlers.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: platform-engineering-opentofu
|
|
3
|
+
description: Infrastructure as Code (IaC) with OpenTofu/Terraform/Pulumi, automated cloud provisioning, DevSecOps pipelines, and self-service platform engineering.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/verify_all.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/security_scan.js
|
|
10
|
+
- .agent/scripts/verify_all.js
|
|
11
|
+
skills:
|
|
12
|
+
- devops-engineer
|
|
13
|
+
- platform-engineer
|
|
14
|
+
- cloud-architect
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Platform Engineering & OpenTofu IaC
|
|
18
|
+
|
|
19
|
+
## Mandatory Pre-Flight Context Inspection
|
|
20
|
+
|
|
21
|
+
Before provisioning cloud infrastructure:
|
|
22
|
+
1. OpenTofu State Locking → Use remote S3/DynamoDB or backend state locking to prevent concurrency collisions
|
|
23
|
+
2. Least Privilege IAM → Enforce strict role-based access control (RBAC) on all cloud resources
|
|
24
|
+
3. Plan Validation → Run `tofu plan` and static security analysis (tfsec/checkov) before `tofu apply`
|
|
25
|
+
|
|
26
|
+
## Production AWS VPC & ECS Module Blueprint
|
|
27
|
+
|
|
28
|
+
```hcl
|
|
29
|
+
terraform {
|
|
30
|
+
required_version = ">= 1.6.0"
|
|
31
|
+
required_providers {
|
|
32
|
+
aws = {
|
|
33
|
+
source = "hashicorp/aws"
|
|
34
|
+
version = "~> 5.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
variable "environment" {
|
|
40
|
+
type = string
|
|
41
|
+
default = "production"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_vpc" "main" {
|
|
45
|
+
cidr_block = "10.0.0.0/16"
|
|
46
|
+
enable_dns_hostnames = true
|
|
47
|
+
enable_dns_support = true
|
|
48
|
+
|
|
49
|
+
tags = {
|
|
50
|
+
Name = "vpc-${var.environment}"
|
|
51
|
+
Environment = var.environment
|
|
52
|
+
ManagedBy = "OpenTofu"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
resource "aws_subnet" "public_a" {
|
|
57
|
+
vpc_id = aws_vpc.main.id
|
|
58
|
+
cidr_block = "10.0.1.0/24"
|
|
59
|
+
availability_zone = "us-east-1a"
|
|
60
|
+
map_public_ip_on_launch = true
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
65
|
+
|
|
66
|
+
- Run `tofu validate` and security scan before applying changes.
|
|
67
|
+
- Ensure rollback plan is explicitly documented.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-ai-e2e
|
|
3
|
+
description: Modern Playwright 1.45+ E2E web testing, resilient ARIA locators, visual regression testing, network mocking, and AI-assisted flakiness detection.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/test_runner.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/test_runner.js
|
|
10
|
+
- .agent/scripts/visual_audit.js
|
|
11
|
+
skills:
|
|
12
|
+
- playwright-best-practices
|
|
13
|
+
- webapp-testing
|
|
14
|
+
- testing-patterns
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Playwright AI E2E Testing — 2026 Standards
|
|
18
|
+
|
|
19
|
+
## Mandatory Pre-Flight Context Inspection
|
|
20
|
+
|
|
21
|
+
Before writing end-to-end web tests:
|
|
22
|
+
1. ARIA Role Locators → Use accessibility roles (`getByRole`, `getByText`) over brittle CSS selectors
|
|
23
|
+
2. Auto-Waiting & Zero Sleep → Avoid `page.waitForTimeout()`; rely on Playwright built-in auto-waiting
|
|
24
|
+
3. Network Interception → Mock external third-party APIs using `page.route()` for deterministic CI runs
|
|
25
|
+
|
|
26
|
+
## Resilient E2E API Route Mocking & Interaction Test
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { test, expect } from '@playwright/test';
|
|
30
|
+
|
|
31
|
+
test.describe('Dashboard Features', () => {
|
|
32
|
+
test.beforeEach(async ({ page }) => {
|
|
33
|
+
// Intercept external analytics API to avoid flaky network calls
|
|
34
|
+
await page.route('**/api/analytics', async (route) => {
|
|
35
|
+
await route.fulfill({
|
|
36
|
+
status: 200,
|
|
37
|
+
contentType: 'application/json',
|
|
38
|
+
body: JSON.stringify({ visits: 1042, conversions: 88 }),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('user views analytics dashboard', async ({ page }) => {
|
|
44
|
+
await page.goto('/dashboard');
|
|
45
|
+
|
|
46
|
+
// Resilient ARIA locators
|
|
47
|
+
const heading = page.getByRole('heading', { name: 'Analytics' });
|
|
48
|
+
await expect(heading).toBeVisible();
|
|
49
|
+
|
|
50
|
+
const visitsText = page.getByText('1042');
|
|
51
|
+
await expect(visitsText).toBeVisible();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
57
|
+
|
|
58
|
+
- Run Playwright test suite in headless mode and verify zero flakiness.
|
|
59
|
+
- Ensure all interactive elements rely on resilient locators.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: property-based-testing
|
|
3
|
+
description: Generative input invariant testing using fast-check (TS/JS) and hypothesis (Python) to uncover hidden edge cases and boundary failures.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/test_runner.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/test_runner.js
|
|
10
|
+
- .agent/scripts/inner_loop_validator.js
|
|
11
|
+
skills:
|
|
12
|
+
- testing-patterns
|
|
13
|
+
- tdd-workflow
|
|
14
|
+
- clean-code
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Property-Based Testing — Invariant Verification
|
|
18
|
+
|
|
19
|
+
## Mandatory Pre-Flight Context Inspection
|
|
20
|
+
|
|
21
|
+
Before writing property tests:
|
|
22
|
+
1. Invariant Identification → Define mathematical properties that must hold true for ALL inputs (e.g. `reverse(reverse(list)) == list`)
|
|
23
|
+
2. Arbitrary Generator Scoping → Constrain generator bounds to domain validity (e.g. non-empty strings, positive integers)
|
|
24
|
+
3. Shrinking & Reproducibility → Store seed values for failing test runs to reproduce minimal failing inputs
|
|
25
|
+
|
|
26
|
+
## Fast-Check Arbitrary Generator & Vitest Invariant Test
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import fc from 'fast-check';
|
|
30
|
+
import { test, expect } from 'vitest';
|
|
31
|
+
|
|
32
|
+
function parseAmount(currencyStr: string): number | null {
|
|
33
|
+
const cleaned = currencyStr.replace(/[^0-9.]/g, '');
|
|
34
|
+
const num = parseFloat(cleaned);
|
|
35
|
+
return isNaN(num) ? null : num;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
test('currency parser invariant: non-negative parsed numbers', () => {
|
|
39
|
+
fc.assert(
|
|
40
|
+
fc.property(
|
|
41
|
+
fc.tuple(fc.string(), fc.double({ min: 0, max: 1000000 })),
|
|
42
|
+
([prefix, val]) => {
|
|
43
|
+
const input = `${prefix}$${val.toFixed(2)}`;
|
|
44
|
+
const parsed = parseAmount(input);
|
|
45
|
+
|
|
46
|
+
if (parsed !== null) {
|
|
47
|
+
expect(parsed).toBeGreaterThanOrEqual(0);
|
|
48
|
+
expect(Number.isFinite(parsed)).toBe(true);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
{ numRuns: 500 } // Execute 500 generative iterations
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
58
|
+
|
|
59
|
+
- Run minimum 100 iterations per property test run.
|
|
60
|
+
- Confirm shrinking mechanism isolates minimal failing counter-example on assertion failure.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vector-search-pgvector
|
|
3
|
+
description: Production vector database search using pgvector 0.8.0+, halfvec, sparsevec, Pinecone, Weaviate, hybrid sparse-dense retrieval, and iterative HNSW scanning.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/schema_validator.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/schema_validator.js
|
|
10
|
+
skills:
|
|
11
|
+
- database-architect
|
|
12
|
+
- sql-pro
|
|
13
|
+
- advanced-rag-pipelines
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Vector Search & pgvector 0.8.0+ — 2026 Database Standards
|
|
17
|
+
|
|
18
|
+
## Mandatory Pre-Flight Context Inspection
|
|
19
|
+
|
|
20
|
+
Before creating vector tables or indexes:
|
|
21
|
+
1. Index Type & Precision → Use `halfvec` (half-precision) for 50% RAM savings on HNSW indexes; use `sparsevec` for high-dimensional sparse vectors
|
|
22
|
+
2. Iterative Index Scans (pgvector 0.8.0+) → Enable iterative scanning to prevent HNSW overfiltering when combining `WHERE` clauses with vector similarity
|
|
23
|
+
3. Hybrid Search Strategy → Combine BM25 full-text search with dense vector similarity via Reciprocal Rank Fusion (RRF)
|
|
24
|
+
|
|
25
|
+
## High-Performance pgvector 0.8.0+ Schema (`halfvec` + HNSW)
|
|
26
|
+
|
|
27
|
+
```sql
|
|
28
|
+
CREATE EXTENSION IF NOT EXISTS vector;
|
|
29
|
+
|
|
30
|
+
CREATE TABLE document_chunks (
|
|
31
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
32
|
+
document_id UUID NOT NULL,
|
|
33
|
+
chunk_index INT NOT NULL,
|
|
34
|
+
content TEXT NOT NULL,
|
|
35
|
+
fts_vector tsvector GENERATED ALWAYS AS (to_tsvector('english', content)) STORED,
|
|
36
|
+
embedding halfvec(1536) NOT NULL -- 50% memory reduction vs float4 vector
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
-- HNSW index using halfvec with iterative scanning support (pgvector 0.8.0+)
|
|
40
|
+
CREATE INDEX idx_chunks_embedding_hnsw
|
|
41
|
+
ON document_chunks USING hnsw (embedding halfvec_cosine_ops)
|
|
42
|
+
WITH (m = 16, ef_construction = 64);
|
|
43
|
+
|
|
44
|
+
-- Full text search GIN index
|
|
45
|
+
CREATE INDEX idx_chunks_fts ON document_chunks USING gin (fts_vector);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Hybrid Search Query (pgvector 0.8.0+ Iterative Scan + RRF)
|
|
49
|
+
|
|
50
|
+
```sql
|
|
51
|
+
-- pgvector 0.8.0+ automatically performs iterative prober scans when filtering
|
|
52
|
+
WITH vector_search AS (
|
|
53
|
+
SELECT id, content, ROW_NUMBER() OVER (ORDER BY embedding <=> $1::halfvec) as rank
|
|
54
|
+
FROM document_chunks
|
|
55
|
+
WHERE document_id = $3 -- Iterative scan prevents overfiltering
|
|
56
|
+
LIMIT 20
|
|
57
|
+
),
|
|
58
|
+
fts_search AS (
|
|
59
|
+
SELECT id, content, ROW_NUMBER() OVER (ORDER BY ts_rank(fts_vector, websearch_to_tsquery($2)) DESC) as rank
|
|
60
|
+
FROM document_chunks
|
|
61
|
+
WHERE fts_vector @@ websearch_to_tsquery($2) AND document_id = $3
|
|
62
|
+
LIMIT 20
|
|
63
|
+
)
|
|
64
|
+
SELECT
|
|
65
|
+
COALESCE(v.id, f.id) as id,
|
|
66
|
+
COALESCE(v.content, f.content) as content,
|
|
67
|
+
COALESCE(1.0 / (60 + v.rank), 0.0) + COALESCE(1.0 / (60 + f.rank), 0.0) as rrf_score
|
|
68
|
+
FROM vector_search v
|
|
69
|
+
FULL OUTER JOIN fts_search f ON v.id = f.id
|
|
70
|
+
ORDER BY rrf_score DESC
|
|
71
|
+
LIMIT 10;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
75
|
+
|
|
76
|
+
- Verify vector index construction queries pass `EXPLAIN ANALYZE` with `halfvec`.
|
|
77
|
+
- Confirm pgvector extension version is >= 0.8.0 for iterative scanning support.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: zero-trust-passkeys
|
|
3
|
+
description: Modern passwordless authentication using WebAuthn, FIDO2 biometric passkeys, SimpleWebAuthn v13+, Conditional UI (Passkey Autofill), and Zero-Trust security.
|
|
4
|
+
tools: Read, Grep, Glob, Edit, Write
|
|
5
|
+
version: 3.0.0
|
|
6
|
+
last-updated: 2026-08-05
|
|
7
|
+
script: .agent/scripts/security_scan.js
|
|
8
|
+
scripts-binding:
|
|
9
|
+
- .agent/scripts/security_scan.js
|
|
10
|
+
skills:
|
|
11
|
+
- authentication-best-practices
|
|
12
|
+
- backend-security-expert
|
|
13
|
+
- frontend-security-expert
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Zero-Trust Passkeys & WebAuthn (SimpleWebAuthn v13+)
|
|
17
|
+
|
|
18
|
+
## Mandatory Pre-Flight Context Inspection
|
|
19
|
+
|
|
20
|
+
Before implementing auth flows:
|
|
21
|
+
1. Conditional UI (Passkey Autofill) → Use `useBrowserAutofill: true` and `autocomplete="username webauthn"` for seamless form autofill
|
|
22
|
+
2. Feature Detection & Abort Signals → Check `isConditionalMediationAvailable()` and manage cancellation via `AbortController`
|
|
23
|
+
3. Discoverable Credentials → Ensure `userVerification` and resident key options are enabled on registration
|
|
24
|
+
|
|
25
|
+
## Client-Side Passkey Autofill Pattern (SimpleWebAuthn v13 Browser)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
startAuthentication,
|
|
30
|
+
isConditionalMediationAvailable
|
|
31
|
+
} from '@simplewebauthn/browser';
|
|
32
|
+
|
|
33
|
+
export async function initConditionalPasskeyAutofill(abortSignal: AbortSignal) {
|
|
34
|
+
const isAvailable = await isConditionalMediationAvailable();
|
|
35
|
+
if (!isAvailable) return;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// 1. Fetch options from server
|
|
39
|
+
const res = await fetch('/api/auth/generate-authentication-options');
|
|
40
|
+
const options = await res.json();
|
|
41
|
+
|
|
42
|
+
// 2. Trigger browser native autofill dropdown
|
|
43
|
+
const credential = await startAuthentication({
|
|
44
|
+
optionsJSON: options,
|
|
45
|
+
useBrowserAutofill: true,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// 3. Send response to server for verification
|
|
49
|
+
await fetch('/api/auth/verify-authentication', {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: { 'Content-Type': 'application/json' },
|
|
52
|
+
body: JSON.stringify(credential),
|
|
53
|
+
});
|
|
54
|
+
} catch (err: any) {
|
|
55
|
+
if (err.name !== 'AbortError') console.error('Passkey autofill error:', err);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Server Verification Pattern (SimpleWebAuthn v13 Server)
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { verifyAuthenticationResponse, generateAuthenticationOptions } from '@simplewebauthn/server';
|
|
64
|
+
|
|
65
|
+
export async function verifyPasskeyAuth(body: any, expectedChallenge: string, userPublicKey: Uint8Array) {
|
|
66
|
+
const verification = await verifyAuthenticationResponse({
|
|
67
|
+
response: body,
|
|
68
|
+
expectedChallenge,
|
|
69
|
+
expectedOrigin: process.env.APP_ORIGIN!,
|
|
70
|
+
expectedRPID: process.env.RP_ID!,
|
|
71
|
+
credential: {
|
|
72
|
+
id: body.id,
|
|
73
|
+
publicKey: userPublicKey,
|
|
74
|
+
counter: body.counter || 0,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return verification.verified;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 🛑 Verification-Before-Completion (VBC) Protocol
|
|
83
|
+
|
|
84
|
+
- Verify input tags have `autocomplete="username webauthn"`.
|
|
85
|
+
- Test passkey autofill flow with `AbortController` cancellation.
|
|
@@ -47,36 +47,36 @@ Before launching the full 21-reviewer audit, you MUST inspect:
|
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
-
## 21 Reviewers —
|
|
50
|
+
## 21 Reviewers — Stage-Partitioned Execution (3 Waves)
|
|
51
|
+
|
|
52
|
+
To eliminate context window saturation and reviewer attention dilution, the 21 reviewers execute in 3 partitioned passes:
|
|
51
53
|
|
|
52
54
|
```
|
|
53
|
-
|
|
55
|
+
Wave 1: Core Integrity & Precedences (Pass 1)
|
|
54
56
|
├── precedence-reviewer → Checks local repo Case Law for past rejections
|
|
55
57
|
├── logic-reviewer → Hallucinated methods, impossible logic, undefined refs
|
|
56
|
-
├──
|
|
58
|
+
├── schema-reviewer → Missing input validation, loose schemas, raw req.body
|
|
57
59
|
└── resilience-reviewer → Swallowed errors, unhandled rejections, missing retries
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
Wave 2: Security, Types & Code Quality (Pass 2)
|
|
62
|
+
├── security-auditor → OWASP 2025, injection, JWT, SSRF, IDOR
|
|
60
63
|
├── dependency-reviewer → Fabricated packages, supply chain, version compatibility
|
|
61
64
|
├── type-safety-reviewer → 'any' epidemic, Zod parse vs cast, unguarded access
|
|
62
65
|
├── complexity-reviewer → Enforces the Dependency Ladder to prevent over-engineering
|
|
63
|
-
├── schema-reviewer → Missing input validation, loose schemas, raw req.body
|
|
64
66
|
└── sql-reviewer → Injection, N+1, missing indexes, unscoped mutations
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
Wave 3: Domain, UI & Performance (Pass 3)
|
|
67
69
|
├── frontend-reviewer → React 19 APIs, RSC violations, hook rules, hydration
|
|
68
|
-
├── performance-reviewer →
|
|
70
|
+
├── performance-reviewer → Core Web Vitals targets, re-render cascades, memory leaks
|
|
69
71
|
├── mobile-reviewer → Reanimated thread safety, FlashList, safe area insets
|
|
70
72
|
├── ai-code-reviewer → Model name hallucinations, prompt injection, cost explosion
|
|
71
73
|
├── test-coverage-reviewer → Happy path only, brittle selectors, missing edge cases
|
|
72
74
|
├── accessibility-reviewer → WCAG 2.2 AA, ARIA misuse, focus management, live regions
|
|
73
75
|
├── ui-ux-auditor → Generic AI aesthetics, missing hover states, contrast
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
├── db-latency-auditor → DB layer: N+1, unbounded queries, unindexed WHERE, pool config
|
|
79
|
-
└── throughput-optimizer → Server runtime: event-loop blocks, serialized awaits, memory leaks
|
|
76
|
+
├── review-animations → UI animations >300ms, origin-unaware popovers, ease-in
|
|
77
|
+
├── vitals-reviewer → Frontend CWV depth: Suspense waterfalls, paint jank
|
|
78
|
+
├── db-latency-auditor → DB layer: N+1, unbounded queries, unindexed WHERE
|
|
79
|
+
└── throughput-optimizer → Server runtime: event-loop blocks, serialized awaits
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
---
|