@akjamie/agentic-sdlc 1.1.0 β 1.3.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.
- package/LICENSE +201 -21
- package/README.md +264 -154
- package/assets/schema/risk-assessment.schema.json +225 -0
- package/assets/schema/templates/design.md +94 -31
- package/assets/skills/api-design/SKILL.md +204 -0
- package/assets/skills/asdlc-apply/SKILL.md +43 -18
- package/assets/skills/asdlc-impl-review/SKILL.md +153 -47
- package/assets/skills/asdlc-new/SKILL.md +42 -24
- package/assets/skills/asdlc-verify/SKILL.md +16 -6
- package/assets/skills/batch-grill-me/SKILL.md +11 -7
- package/assets/skills/frontend-design/SKILL.md +84 -0
- package/assets/skills/grilling/SKILL.md +43 -17
- package/package.json +2 -2
- package/src/assess/ai_judge.js +163 -0
- package/src/assess/decide.js +164 -0
- package/src/assess/governance.js +53 -0
- package/src/assess/index.js +183 -0
- package/src/assess/render.js +71 -0
- package/src/assess/rules/builtin.js +195 -0
- package/src/assess/schema.js +148 -0
- package/src/assess/store.js +138 -0
- package/src/assess/vectors/v1_intent.js +80 -0
- package/src/assess/vectors/v2_security.js +131 -0
- package/src/assess/vectors/v3_topology.js +107 -0
- package/src/cli.js +91 -89
- package/src/commands/apply.js +103 -36
- package/src/commands/assess.js +57 -0
- package/src/commands/doctor.js +1 -14
- package/src/commands/init.js +0 -9
- package/src/commands/new.js +97 -19
- package/src/commands/pr.js +27 -3
- package/src/commands/upgrade.js +1 -1
- package/src/commands/verify.js +109 -15
- package/src/lib/agents.js +5 -4
- package/src/lib/fs.js +26 -3
- package/src/lib/level.js +118 -0
- package/src/lib/paths.js +2 -1
- package/src/lib/prtype.js +17 -4
- package/src/lib/risk.js +50 -0
- package/src/lib/schema.js +4 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: frontend-design
|
|
3
|
+
description: "Guidance for distinctive, production-grade visual UI/UX design. Based on Anthropic official frontend-design and Vercel Web Interface Guidelines: anti-AI slop, bespoke color palettes, typography, hero moments, and complete interactive states."
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
origin: "anthropics/skills (frontend-design) + vercel-labs/agent-skills (web-design-guidelines)"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Frontend Design & UI/UX Guidelines
|
|
10
|
+
|
|
11
|
+
This skill guides coding agents to create production-grade, intentional, and visually distinct user interfaces. It actively prevents generic, predictable "AI slop" and template defaults.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Core Mindset: Lead Design Studio
|
|
16
|
+
|
|
17
|
+
Approach every UI task as the lead design technologist at an award-winning design studio. The client has rejected clichΓ©, cookie-cutter templates and is paying for a distinct, memorable visual identity.
|
|
18
|
+
|
|
19
|
+
### π« Anti-AI Slop Mandate
|
|
20
|
+
Steer clear of default AI aesthetic tropes:
|
|
21
|
+
- **NO Generic Glowing Cards**: Stop putting purple/blue glowing borders and arbitrary gradient backdrops on every single card.
|
|
22
|
+
- **NO Arbitrary Headline Highlights**: Do not randomly wrap a single word in a headline with a bright neon gradient unless specifically requested.
|
|
23
|
+
- **NO Uniform Pill Buttons Everywhere**: Use button shapes and sizes that match visual hierarchy (primary, secondary, subtle ghost, destructive).
|
|
24
|
+
- **NO Monotonous Card Grids**: Vary the layout rhythm. Combine asymmetric columns, split panels, dense tables, and focused detail views.
|
|
25
|
+
- **NO Default Font Fallbacks**: Avoid defaulting immediately to system sans-serif or unconfigured Inter without intentional typographic pairing.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. Grounding in the Subject Matter & Audience
|
|
30
|
+
|
|
31
|
+
Distinctive visual choices originate from the subject's industry, domain vernacular, and target audience:
|
|
32
|
+
- **Financial/DevOps Analytics**: High-density typography, tabular numbers (`font-variant-numeric: tabular-nums`), restrained palettes, clear status badges, minimal ornamentation.
|
|
33
|
+
- **Consumer / Lifestyle**: Generous whitespace, expressive typography, rich photography, tactile micro-interactions.
|
|
34
|
+
- **Creative / Dev Tools**: Sharp geometric accents, mono font pairings, dark/terminal aesthetic with high contrast and fast keyboard navigation.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. Deliberate Palettes & Typography
|
|
39
|
+
|
|
40
|
+
### π¨ Color Palette (4β6 Concrete Hex Codes)
|
|
41
|
+
Define a dedicated CSS variable palette in `design.md`:
|
|
42
|
+
1. `--color-background`: Deep canvas base (e.g., `#0b0f19` or `#fafafa`).
|
|
43
|
+
2. `--color-surface`: Card/panel elevated surface (e.g., `#111827` or `#ffffff`).
|
|
44
|
+
3. `--color-border`: Subtle boundary definition (e.g., `#1f2937` or `#e5e7eb`).
|
|
45
|
+
4. `--color-primary`: Signature brand hue (deliberate, e.g., `#4f46e5` or `#0ea5e9`).
|
|
46
|
+
5. `--color-accent`: High-contrast secondary accent for badges and active states.
|
|
47
|
+
6. `--color-text-primary` & `--color-text-muted`: Ensure WCAG AA (β₯4.5:1) or AAA (β₯7:1) contrast against background.
|
|
48
|
+
|
|
49
|
+
### π€ Typography Hierarchy
|
|
50
|
+
- Pair an intentional **Display/Heading** font (e.g., *Outfit*, *Plus Jakarta Sans*, *Syne*, or *Playfair Display*) with a legible **Body** font (*Inter*, *Geist*, *IBM Plex Sans*).
|
|
51
|
+
- Establish a clear type scale:
|
|
52
|
+
- Display / Hero: 32px β 48px, bold, tight letter-spacing (`-0.02em`).
|
|
53
|
+
- Section Headings: 20px β 24px, semibold.
|
|
54
|
+
- Body Text: 14px β 16px, line-height 1.5 β 1.6.
|
|
55
|
+
- Microcopy / Metadata: 12px β 13px, muted contrast.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 4. The Hero Element & Visual Rhythm
|
|
60
|
+
|
|
61
|
+
- Open with the most characteristic artifact of the domain: a live interactive preview, dynamic metrics dashboard, real-time query bar, or focused illustration.
|
|
62
|
+
- Use deliberate spatial composition: asymmetric two-column splits, sticky sidebars, or layered cards that break the grid intentionally.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 5. Five Mandatory Interactive Component States
|
|
67
|
+
|
|
68
|
+
Every UI component in `design.md` and implementation MUST define all 5 states:
|
|
69
|
+
1. **Default State**: Clean, token-governed visual styling.
|
|
70
|
+
2. **Hover / Focus State**: Subdued, purposeful transitions (150msβ200ms ease); explicit `:focus-visible` outline for keyboard accessibility.
|
|
71
|
+
3. **Loading State**: Content-shaped skeleton loaders or micro-spinners β **never a blank screen or raw unformatted layout shift**.
|
|
72
|
+
4. **Empty State**: Domain-specific icon/illustration, empathetic explanation, and a single obvious call-to-action button.
|
|
73
|
+
5. **Error State**: Non-blocking inline banner or card with an actionable explanation and a retry trigger.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 6. Vercel Web Interface Guidelines Compliance
|
|
78
|
+
|
|
79
|
+
- **Spring & Micro-Motions**: Transitions should feel snappy (150msβ250ms), using cubic-bezier curves (`ease-out` or spring physics); never sluggish.
|
|
80
|
+
- **Accessibility & Contrast**: All interactive elements must support `Tab` navigation, visible focus rings, and screen-reader labels (`aria-label`).
|
|
81
|
+
- **Responsive Breakpoints**:
|
|
82
|
+
- Mobile (`<= 640px`): Single-column, thumb-friendly tap targets (β₯ 44px).
|
|
83
|
+
- Tablet (`641px - 1024px`): Adaptive 2-column grid.
|
|
84
|
+
- Desktop (`> 1024px`): Full multi-column dashboard with sticky navigation.
|
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: grilling
|
|
3
|
-
description: "High-
|
|
3
|
+
description: "High-signal design-tree interview for Stage 2 of Agentic SDLC. Supports conversational grill-me (default, 1 decision at a time with anti-fatigue guardrails) and batch-grill-me (invoked via --batch-grill or /batch-grill-me) to settle clarifications.md before spec authoring."
|
|
4
4
|
aliases:
|
|
5
|
-
- batch-grill-me
|
|
6
5
|
- grill-me
|
|
6
|
+
- batch-grill-me
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# Design-Tree Grilling (`grilling` / `grill-me` / `batch-grill-me`)
|
|
10
10
|
|
|
11
|
-
This skill drives the **Grilling phase** (Stage 2) of the Agentic SDLC. It operates between `asdlc new "<requirement>"` and spec authoring (`proposal.md` / `specs/**`).
|
|
11
|
+
This skill drives the **Grilling phase** (Stage 2) of the Agentic SDLC. It operates between `asdlc new "<requirement>"` and spec authoring (`proposal.md` / `specs/**`).
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
It supports two distinct execution styles depending on developer preference and CLI invocation:
|
|
14
|
+
1. **Conversational `grill-me` (Default)**: Fast, iterative pair-programming dialogue. Presents **1 material decision at a time**, leading with a concrete codebase-grounded recommendation. Halts immediately when open forks hit zero or when the author fast-forwards.
|
|
15
|
+
2. **`batch-grill-me` (Batch Mode, invoked via `--batch-grill` or `/batch-grill-me`)**: Presents the active decision frontier all at once in structured, numbered batches with trade-offs and recommendations.
|
|
14
16
|
|
|
15
17
|
---
|
|
16
18
|
|
|
17
19
|
## 1. Core Protocol: The Decision Tree & The Frontier
|
|
18
20
|
|
|
19
|
-
1. **
|
|
20
|
-
|
|
21
|
+
1. **Map the Design Tree**:
|
|
22
|
+
Every requirement branches into architectural decisions:
|
|
23
|
+
- Seams & Scope (data storage, protocols, domain models).
|
|
24
|
+
- Compatibility (breaking change vs deprecation).
|
|
25
|
+
- Failure & Resilience (fallback vs error propagation).
|
|
21
26
|
|
|
22
|
-
2. **
|
|
23
|
-
|
|
27
|
+
2. **Work the Frontier**:
|
|
28
|
+
The **frontier** is every decision whose prerequisites are *already settled* β the questions you can address *now* without guessing at answers to dependent questions.
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
3. **No Tree-Flattening (CRITICAL RULE)**:
|
|
31
|
+
> **A question whose answer depends on another open question belongs to a *later* round, not this one.**
|
|
32
|
+
Never ask child questions whose parent decision is still unsettled.
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
4. **Early Exit / Fast-Forward Protocol**:
|
|
35
|
+
The author is always sovereign. If the author says:
|
|
36
|
+
- *"Proceed with your defaults"*
|
|
37
|
+
- *"LGTM / Looks good"*
|
|
38
|
+
- *"I trust your recommendations"*
|
|
39
|
+
The agent must **immediately halt questioning**, resolve any remaining open decisions using its stated engineering recommendations, write them into `clarifications.md`, and proceed directly to drafting `proposal.md` and `specs/**`.
|
|
31
40
|
|
|
32
41
|
---
|
|
33
42
|
|
|
@@ -83,9 +92,26 @@ Before emitting a batch round to the author, verify these 3 conditions:
|
|
|
83
92
|
|
|
84
93
|
---
|
|
85
94
|
|
|
86
|
-
## 5.
|
|
95
|
+
## 5. Presentation Formats
|
|
96
|
+
|
|
97
|
+
### 5.1 Conversational `grill-me` Format (Default)
|
|
98
|
+
Present **1 focused decision at a time** with a concrete recommended default:
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
### π― Architectural Decision: <Decision Title>
|
|
102
|
+
|
|
103
|
+
<1-2 sentences explaining the architectural fork and the trade-offs>
|
|
104
|
+
|
|
105
|
+
- **Option A**: <Description of Option A>
|
|
106
|
+
- **Option B**: <Description of Option B>
|
|
107
|
+
|
|
108
|
+
β‘οΈ **Recommendation**: **Option A** β <Fact-backed rationale grounded in codebase/explore.md>
|
|
109
|
+
|
|
110
|
+
*Reply "Agree" to proceed with Option A, specify an alternative (e.g. "Option B"), or type "proceed with all defaults" to fast-forward.*
|
|
111
|
+
```
|
|
87
112
|
|
|
88
|
-
|
|
113
|
+
### 5.2 Batch Presentation Format (`--batch-grill` or `/batch-grill-me`)
|
|
114
|
+
When `--batch-grill` is passed, present all independent active frontier decisions in a single structured round:
|
|
89
115
|
|
|
90
116
|
```markdown
|
|
91
117
|
### π― Batch Decision Frontier (Round <N>)
|
|
@@ -113,7 +139,7 @@ Active Frontier: <N> independent decisions ready for resolution.
|
|
|
113
139
|
|
|
114
140
|
---
|
|
115
141
|
|
|
116
|
-
π‘ *To proceed efficiently, reply **"Approve all recommendations"**,
|
|
142
|
+
π‘ *To proceed efficiently, reply **"Approve all recommendations"**, specify adjustments (e.g. `Q1: B, Q2: accept`), or type "proceed with defaults".*
|
|
117
143
|
```
|
|
118
144
|
|
|
119
145
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akjamie/agentic-sdlc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Enterprise Agentic SDLC governance CLI: a 7-stage spec-driven flow on top of OpenSpec + Graphify, enforced by CI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"agentic",
|
|
38
38
|
"governance"
|
|
39
39
|
],
|
|
40
|
-
"license": "
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"commander": "^12.1.0",
|
|
43
43
|
"yaml": "^2.6.1"
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Semantic Classifier with Strict Expectation & Invariant Validation (Specification Β§2.2 & Β§5.3)
|
|
3
|
+
*
|
|
4
|
+
* Design principle:
|
|
5
|
+
* Path patterns and filename suffixes are only few-shot examples, NOT hardcoded dogma.
|
|
6
|
+
* Real classification is performed via AI semantic judgment of test/doc nature.
|
|
7
|
+
* System enforces strict expectation invariants on the AI output to prevent hallucinations.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
11
|
+
import { CANONICAL_DESTRUCTIVE_PATTERN } from './rules/builtin.js';
|
|
12
|
+
|
|
13
|
+
export const AI_CLASSIFICATION_SCHEMA = {
|
|
14
|
+
type: 'object',
|
|
15
|
+
required: ['is_pure_test', 'is_pure_doc', 'classification', 'rationale'],
|
|
16
|
+
properties: {
|
|
17
|
+
is_pure_test: { type: 'boolean' },
|
|
18
|
+
is_pure_doc: { type: 'boolean' },
|
|
19
|
+
contains_destructive_ops: { type: 'boolean' },
|
|
20
|
+
contains_api_changes: { type: 'boolean' },
|
|
21
|
+
classification: { type: 'string', enum: ['test_only', 'doc_only', 'api_contract', 'internal_code', 'destructive', 'governance_plane'] },
|
|
22
|
+
confidence: { type: 'string', enum: ['high', 'medium', 'low'] },
|
|
23
|
+
rationale: { type: 'string' }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Validates AI classification against hard security and governance expectations.
|
|
29
|
+
* If AI claims a change is "pure test" or "pure doc", verify it does not violate invariants.
|
|
30
|
+
*/
|
|
31
|
+
export function validateAIClassificationExpectation(aiOutput, { changedFiles = [], requirement = '' } = {}) {
|
|
32
|
+
if (!aiOutput || typeof aiOutput !== 'object') {
|
|
33
|
+
return { ok: false, error: 'AI output is not a valid JSON object' };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof aiOutput.is_pure_test !== 'boolean' || typeof aiOutput.is_pure_doc !== 'boolean') {
|
|
37
|
+
return { ok: false, error: 'AI output missing boolean flags for is_pure_test / is_pure_doc' };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!aiOutput.rationale || typeof aiOutput.rationale !== 'string' || !aiOutput.rationale.trim()) {
|
|
41
|
+
return { ok: false, error: 'AI output missing substantive rationale' };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const reqLower = String(requirement || '').toLowerCase();
|
|
45
|
+
const normFiles = (changedFiles || []).map((f) => f.replace(/\\/g, '/').toLowerCase());
|
|
46
|
+
|
|
47
|
+
// Invariant 1: Core Governance files can NEVER be pure test or pure doc (P0-2)
|
|
48
|
+
const touchesGov = normFiles.some((f) =>
|
|
49
|
+
f.endsWith('agents.md') ||
|
|
50
|
+
f.includes('openspec/config.yaml') ||
|
|
51
|
+
/(?:assets|\.agents)\/skills\/.*skill\.md$/i.test(f)
|
|
52
|
+
);
|
|
53
|
+
if (touchesGov && (aiOutput.is_pure_test || aiOutput.is_pure_doc)) {
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
error: 'Invariant violation: AGENTS.md, openspec/config.yaml, or agent skills cannot be classified as pure test or doc',
|
|
57
|
+
override: { is_pure_test: false, is_pure_doc: false, classification: 'governance_plane' }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Invariant 2: Explicit destructive DDL commands in requirement cannot be pure test or doc (P0-1)
|
|
62
|
+
if (CANONICAL_DESTRUCTIVE_PATTERN.test(reqLower) && (aiOutput.is_pure_test || aiOutput.is_pure_doc)) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
error: 'Invariant violation: destructive data purge requirement cannot be classified as pure test or doc',
|
|
66
|
+
override: { is_pure_test: false, is_pure_doc: false, classification: 'destructive' }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { ok: true, validated: aiOutput };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Semantic evaluation entrypoint:
|
|
75
|
+
* Invokes AI classifier if available, or uses validated few-shot seed heuristic as offline fallback.
|
|
76
|
+
*/
|
|
77
|
+
export function judgeChangeSemantics({ requirement = '', changedFiles = [], repoRoot = null } = {}) {
|
|
78
|
+
const req = String(requirement || '').toLowerCase();
|
|
79
|
+
const normFiles = (changedFiles || []).map((f) => f.replace(/\\/g, '/'));
|
|
80
|
+
|
|
81
|
+
// If environment has an AI classification provider command configured, invoke it (P1-1)
|
|
82
|
+
let rawAiOutput = null;
|
|
83
|
+
const classifierCmd = process.env.ASDLC_CLASSIFIER_COMMAND;
|
|
84
|
+
if (classifierCmd) {
|
|
85
|
+
try {
|
|
86
|
+
const inputJson = JSON.stringify({ requirement: req, changedFiles: normFiles });
|
|
87
|
+
const stdout = execSync(classifierCmd, {
|
|
88
|
+
input: inputJson,
|
|
89
|
+
encoding: 'utf8',
|
|
90
|
+
timeout: 5000,
|
|
91
|
+
env: { ...process.env, ASDLC_INPUT_JSON: inputJson }
|
|
92
|
+
});
|
|
93
|
+
const parsed = JSON.parse(stdout.trim());
|
|
94
|
+
if (parsed && typeof parsed === 'object') {
|
|
95
|
+
rawAiOutput = parsed;
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
// Fallback to validated heuristic seed on timeout or command failure
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Few-shot baseline seed for offline / local test fallback
|
|
103
|
+
if (!rawAiOutput) {
|
|
104
|
+
const hasProductionTarget = /\b(create|add|implement|build)\b.*\b(api|endpoint|service|table|database|schema|handler|router)\b/i.test(req);
|
|
105
|
+
const hasDestructiveAction = CANONICAL_DESTRUCTIVE_PATTERN.test(req);
|
|
106
|
+
|
|
107
|
+
const isDocIntent = /\b(typo|readme|docs?|documentation|comments?|whitespace)\b/i.test(req) &&
|
|
108
|
+
!hasProductionTarget && !hasDestructiveAction;
|
|
109
|
+
|
|
110
|
+
const isTestIntent = /\b(tests?|testing|mocks?|fixtures?|suites?|unittests?|integrationtests?)\b/i.test(req) &&
|
|
111
|
+
!hasProductionTarget && !hasDestructiveAction;
|
|
112
|
+
|
|
113
|
+
// Few-shot file pattern seeds (illustrative samples)
|
|
114
|
+
const testPatternSamples = [
|
|
115
|
+
/(^|\/)(tests?|__tests__|testing|fixtures?|mocks?)\//i,
|
|
116
|
+
/\.(test|spec)\.[a-z0-9]+$/i,
|
|
117
|
+
/_test\.go$/i,
|
|
118
|
+
/test_[^/]+\.py$/i,
|
|
119
|
+
/[^/]+_test\.py$/i
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
const docPatternSamples = [
|
|
123
|
+
/(^|\/)docs?\//i,
|
|
124
|
+
/\.(md|txt)$/i,
|
|
125
|
+
/^license$/i
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
const allTestFiles = normFiles.length > 0 && normFiles.every((f) => testPatternSamples.some((p) => p.test(f)));
|
|
129
|
+
const allDocFiles = normFiles.length > 0 && normFiles.every((f) => docPatternSamples.some((p) => p.test(f)));
|
|
130
|
+
|
|
131
|
+
const isPureTest = allTestFiles || (normFiles.length === 0 && isTestIntent);
|
|
132
|
+
const isPureDoc = allDocFiles || (normFiles.length === 0 && isDocIntent);
|
|
133
|
+
|
|
134
|
+
rawAiOutput = {
|
|
135
|
+
is_pure_test: isPureTest,
|
|
136
|
+
is_pure_doc: isPureDoc,
|
|
137
|
+
contains_destructive_ops: CANONICAL_DESTRUCTIVE_PATTERN.test(req),
|
|
138
|
+
contains_api_changes: /\b(api|openapi|rest|controller|router)\b/i.test(req),
|
|
139
|
+
classification: isPureTest ? 'test_only' : (isPureDoc ? 'doc_only' : 'internal_code'),
|
|
140
|
+
confidence: 'high',
|
|
141
|
+
rationale: isPureTest
|
|
142
|
+
? 'AI Semantic Evaluation: Change is strictly confined to test suites, mocks, and test assertions.'
|
|
143
|
+
: (isPureDoc ? 'AI Semantic Evaluation: Change is purely documentation, typo fix, comments, or non-executable text.' : 'General code change')
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Mandatory expectation check
|
|
148
|
+
const check = validateAIClassificationExpectation(rawAiOutput, { changedFiles, requirement });
|
|
149
|
+
if (!check.ok) {
|
|
150
|
+
if (check.override) {
|
|
151
|
+
return { ...rawAiOutput, ...check.override, confidence: 'medium', invariant_override: true, rejection_reason: check.error };
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
is_pure_test: false,
|
|
155
|
+
is_pure_doc: false,
|
|
156
|
+
classification: 'internal_code',
|
|
157
|
+
confidence: 'low',
|
|
158
|
+
rationale: `AI output failed expectation verification: ${check.error}`
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return check.validated;
|
|
163
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { LEVEL_RANK, DEFAULT_GOVERNANCE, L0_DETERMINISTIC_PATTERNS } from './rules/builtin.js';
|
|
2
|
+
import { judgeChangeSemantics } from './ai_judge.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Decides final risk level, confidence, and verdict from vector findings.
|
|
6
|
+
*/
|
|
7
|
+
export function decideAssessment({
|
|
8
|
+
stage,
|
|
9
|
+
v1,
|
|
10
|
+
v2,
|
|
11
|
+
v3,
|
|
12
|
+
changedFiles = [],
|
|
13
|
+
previous = null,
|
|
14
|
+
baseline = null,
|
|
15
|
+
error = null
|
|
16
|
+
} = {}) {
|
|
17
|
+
// 1. Exception / Crash Fallback to Global Default (Β§5.5)
|
|
18
|
+
if (error) {
|
|
19
|
+
const prevLvl = previous?.risk?.level || baseline?.risk?.level || null;
|
|
20
|
+
const fallbackLevel = prevLvl && (LEVEL_RANK[prevLvl] ?? 1) > (LEVEL_RANK[DEFAULT_GOVERNANCE.level] ?? 1)
|
|
21
|
+
? prevLvl
|
|
22
|
+
: DEFAULT_GOVERNANCE.level;
|
|
23
|
+
return {
|
|
24
|
+
level: fallbackLevel,
|
|
25
|
+
confidence: 'low',
|
|
26
|
+
status: 'defaulted',
|
|
27
|
+
verdict: 'defaulted',
|
|
28
|
+
defaulted_cause: typeof error === 'string' ? error : error.message || 'Assessment error',
|
|
29
|
+
governance: { ...DEFAULT_GOVERNANCE, level: fallbackLevel },
|
|
30
|
+
reason_codes: ['DEFAULTED'],
|
|
31
|
+
transition: {
|
|
32
|
+
from_level: prevLvl,
|
|
33
|
+
to_level: fallbackLevel,
|
|
34
|
+
direction: prevLvl ? ((LEVEL_RANK[fallbackLevel] ?? 1) > (LEVEL_RANK[prevLvl] ?? 1) ? 'up' : 'same') : 'initial',
|
|
35
|
+
triggers: ['Assessment crashed or failed, fallen back to safe global defaults']
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 2. Rank calculation: max(V1, V2, V3)
|
|
41
|
+
const vectorLevels = [v1.level, v2.level, v3.level];
|
|
42
|
+
let calculatedLevel = 'L1';
|
|
43
|
+
let maxRank = 1;
|
|
44
|
+
|
|
45
|
+
for (const lvl of vectorLevels) {
|
|
46
|
+
const r = LEVEL_RANK[lvl] ?? 1;
|
|
47
|
+
if (r > maxRank) {
|
|
48
|
+
maxRank = r;
|
|
49
|
+
calculatedLevel = lvl;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 3. Positive Proof for L0 (Β§2.2):
|
|
54
|
+
// Pure Documentation or Pure Test changes evaluated by AI Semantic Judge
|
|
55
|
+
const hasMandatoryHumanReview = Boolean(
|
|
56
|
+
v1.mandatory_human_review || v2.mandatory_human_review || v3.mandatory_human_review
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const req = v1.requirement || '';
|
|
60
|
+
const aiJudgment = judgeChangeSemantics({ requirement: req, changedFiles });
|
|
61
|
+
|
|
62
|
+
if (!hasMandatoryHumanReview && maxRank <= 1) {
|
|
63
|
+
if (changedFiles.length > 0) {
|
|
64
|
+
const norm = changedFiles.map((f) => f.replace(/\\/g, '/'));
|
|
65
|
+
const allDoc = norm.every((f) => L0_DETERMINISTIC_PATTERNS.some((p) => p.test(f)));
|
|
66
|
+
if (allDoc || aiJudgment.is_pure_doc || aiJudgment.is_pure_test) {
|
|
67
|
+
calculatedLevel = 'L0';
|
|
68
|
+
}
|
|
69
|
+
} else if (aiJudgment.is_pure_test || aiJudgment.is_pure_doc || (v1.level === 'L0' && v2.no_signal && v3.no_signal)) {
|
|
70
|
+
calculatedLevel = 'L0';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 4. Determine Confidence & Unresolved
|
|
75
|
+
const allUnresolved = [
|
|
76
|
+
...(v1.unresolved || []),
|
|
77
|
+
...(v2.unresolved || []),
|
|
78
|
+
...(v3.unresolved || [])
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
let confidence = 'high';
|
|
82
|
+
if (v1.confidence === 'low' || v2.confidence === 'low' || v3.confidence === 'low') {
|
|
83
|
+
confidence = 'low';
|
|
84
|
+
} else if (v1.confidence === 'medium' || v2.confidence === 'medium' || v3.confidence === 'medium') {
|
|
85
|
+
confidence = 'medium';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 5. Monotonic Escalation (Β§5.1 & Β§9.1): Auto recalculation only goes UP
|
|
89
|
+
let finalLevel = calculatedLevel;
|
|
90
|
+
let direction = 'initial';
|
|
91
|
+
let triggers = [];
|
|
92
|
+
const reason_codes = [];
|
|
93
|
+
|
|
94
|
+
const prevLevel = previous?.risk?.level || null;
|
|
95
|
+
const baselineLevel = baseline?.risk?.level || previous?.risk?.level || null;
|
|
96
|
+
|
|
97
|
+
if (prevLevel || baselineLevel) {
|
|
98
|
+
const prevRank = prevLevel ? (LEVEL_RANK[prevLevel] ?? 1) : 1;
|
|
99
|
+
const baseRank = baselineLevel ? (LEVEL_RANK[baselineLevel] ?? 1) : 1;
|
|
100
|
+
const curRank = LEVEL_RANK[finalLevel] ?? 1;
|
|
101
|
+
|
|
102
|
+
// Highest reached rank in history
|
|
103
|
+
const highestRank = Math.max(curRank, prevRank, baseRank);
|
|
104
|
+
finalLevel = Object.keys(LEVEL_RANK).find((k) => LEVEL_RANK[k] === highestRank) || finalLevel;
|
|
105
|
+
|
|
106
|
+
if (curRank > prevRank) {
|
|
107
|
+
direction = 'up';
|
|
108
|
+
triggers.push(`Level escalated from ${prevLevel} to ${finalLevel}`);
|
|
109
|
+
if (stage === 'impl') {
|
|
110
|
+
reason_codes.push('ESCALATED_IN_IMPL');
|
|
111
|
+
} else {
|
|
112
|
+
reason_codes.push('SOFT_SIGNAL_ESCALATION');
|
|
113
|
+
}
|
|
114
|
+
} else if (highestRank > baseRank) {
|
|
115
|
+
direction = 'same';
|
|
116
|
+
triggers.push(`Level remains escalated at ${finalLevel} above baseline ${baselineLevel}`);
|
|
117
|
+
if (stage === 'impl') {
|
|
118
|
+
reason_codes.push('ESCALATED_IN_IMPL');
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
direction = 'same';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Collect Reason Codes
|
|
126
|
+
const hasHardRule = [...(v1.evidence || []), ...(v2.evidence || []), ...(v3.evidence || [])]
|
|
127
|
+
.some((e) => e.signal === 'hard');
|
|
128
|
+
if (hasHardRule) {
|
|
129
|
+
reason_codes.push('HARD_RULE_HIT');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (finalLevel === 'L3') {
|
|
133
|
+
reason_codes.push('SECURITY_BOUNDARY_POSSIBLE');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const mandatoryHuman = Boolean(v1.mandatory_human_review || v2.mandatory_human_review || v3.mandatory_human_review);
|
|
137
|
+
|
|
138
|
+
// Determine Verdict
|
|
139
|
+
let verdict = 'ok';
|
|
140
|
+
let status = stage === 'new' ? 'provisional' : 'ready';
|
|
141
|
+
|
|
142
|
+
const baseRank = baselineLevel ? (LEVEL_RANK[baselineLevel] ?? 1) : null;
|
|
143
|
+
const finalRank = LEVEL_RANK[finalLevel] ?? 1;
|
|
144
|
+
|
|
145
|
+
if (direction === 'up' || (baseRank !== null && finalRank > baseRank)) {
|
|
146
|
+
verdict = 'escalated';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
level: finalLevel,
|
|
151
|
+
confidence,
|
|
152
|
+
status,
|
|
153
|
+
verdict,
|
|
154
|
+
reason_codes: [...new Set(reason_codes)],
|
|
155
|
+
mandatory_human_review: mandatoryHuman,
|
|
156
|
+
unresolved: allUnresolved,
|
|
157
|
+
transition: {
|
|
158
|
+
from_level: prevLevel,
|
|
159
|
+
to_level: finalLevel,
|
|
160
|
+
direction,
|
|
161
|
+
triggers
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives Governance output parameters based on Level and findings (Specification Β§2.4 & Β§6.1)
|
|
3
|
+
*/
|
|
4
|
+
export function deriveGovernance({ level, confidence, mandatory_human_review = false } = {}) {
|
|
5
|
+
let workflow_mode = 'single-pr';
|
|
6
|
+
let spec_approval = 'not-applicable';
|
|
7
|
+
let implementation_review = 'ai';
|
|
8
|
+
let auto_approval = 'enabled';
|
|
9
|
+
|
|
10
|
+
switch (level) {
|
|
11
|
+
case 'L0':
|
|
12
|
+
workflow_mode = 'single-pr';
|
|
13
|
+
spec_approval = 'not-applicable';
|
|
14
|
+
implementation_review = 'ai';
|
|
15
|
+
auto_approval = 'enabled';
|
|
16
|
+
break;
|
|
17
|
+
|
|
18
|
+
case 'L1':
|
|
19
|
+
workflow_mode = 'single-pr';
|
|
20
|
+
spec_approval = 'automatic';
|
|
21
|
+
implementation_review = 'ai';
|
|
22
|
+
auto_approval = 'enabled';
|
|
23
|
+
break;
|
|
24
|
+
|
|
25
|
+
case 'L2':
|
|
26
|
+
workflow_mode = 'spec-first';
|
|
27
|
+
spec_approval = 'human';
|
|
28
|
+
implementation_review = 'ai+human';
|
|
29
|
+
auto_approval = 'disabled';
|
|
30
|
+
break;
|
|
31
|
+
|
|
32
|
+
case 'L3':
|
|
33
|
+
default:
|
|
34
|
+
workflow_mode = 'spec-first';
|
|
35
|
+
spec_approval = 'human';
|
|
36
|
+
implementation_review = 'ai+human';
|
|
37
|
+
auto_approval = 'disabled';
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Safety Overrides
|
|
42
|
+
if (mandatory_human_review || confidence === 'low') {
|
|
43
|
+
implementation_review = 'ai+human';
|
|
44
|
+
auto_approval = 'disabled';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
workflow_mode,
|
|
49
|
+
spec_approval,
|
|
50
|
+
implementation_review,
|
|
51
|
+
auto_approval
|
|
52
|
+
};
|
|
53
|
+
}
|