@akjamie/agentic-sdlc 1.5.0 → 1.6.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/README.md +42 -18
- package/assets/config/config.yaml +1 -1
- package/assets/policy/policy.yaml +6 -0
- package/assets/schema/schema.yaml +168 -168
- package/assets/skills/asdlc-approve/SKILL.md +1 -1
- package/assets/skills/asdlc-archive/SKILL.md +17 -13
- package/assets/skills/asdlc-doctor/SKILL.md +8 -8
- package/assets/skills/asdlc-impl-review/SKILL.md +2 -14
- package/assets/skills/asdlc-init/SKILL.md +11 -18
- package/assets/skills/asdlc-pr/SKILL.md +13 -8
- package/assets/skills/asdlc-review/SKILL.md +7 -7
- package/assets/skills/asdlc-spec-review/SKILL.md +2 -14
- package/package.json +2 -1
- package/src/assess/ai_judge.js +36 -3
- package/src/assess/rules/builtin.js +2 -2
- package/src/assess/vectors/v2_security.js +24 -1
- package/src/assess/vectors/v3_topology.js +29 -11
- package/src/commands/apply.js +1 -1
- package/src/commands/approve.js +2 -3
- package/src/commands/archive.js +116 -64
- package/src/commands/doctor.js +22 -19
- package/src/commands/init.js +24 -50
- package/src/commands/pr.js +106 -25
- package/src/commands/test.js +90 -21
- package/src/commands/update.js +1 -11
- package/src/commands/verify.js +94 -14
- package/src/lib/agents.js +2 -2
- package/src/lib/cliutil.js +57 -7
- package/src/lib/git.js +10 -4
- package/src/lib/graphify.js +22 -11
- package/src/lib/level.js +63 -9
- package/src/lib/openspec.js +61 -31
- package/src/lib/paths.js +0 -2
- package/src/lib/policy.js +4 -0
- package/src/lib/schema.js +32 -11
- package/src/lib/tdd.js +29 -9
- package/assets/ci/asdlc-ai-review.yml +0 -65
- package/assets/githooks/post-merge +0 -22
- package/assets/githooks/pre-push +0 -17
|
@@ -38,7 +38,7 @@ This skill can be invoked:
|
|
|
38
38
|
2. **Automatically on PRs** carrying the `asdlc:impl-review` label via PR automation workflows:
|
|
39
39
|
|
|
40
40
|
```yaml
|
|
41
|
-
# GitHub Actions example
|
|
41
|
+
# GitHub Actions / PR Automation example
|
|
42
42
|
- name: AI Implementation Review
|
|
43
43
|
if: contains(github.event.pull_request.labels.*.name, 'asdlc:impl-review')
|
|
44
44
|
env:
|
|
@@ -46,19 +46,7 @@ This skill can be invoked:
|
|
|
46
46
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
47
47
|
REPO: ${{ github.repository }}
|
|
48
48
|
run: |
|
|
49
|
-
#
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
```groovy
|
|
53
|
-
// Jenkinsfile example
|
|
54
|
-
stage('Implementation AI Review') {
|
|
55
|
-
when { expression { env.IS_IMPL == 'true' } }
|
|
56
|
-
steps {
|
|
57
|
-
withCredentials([string(credentialsId: 'github-token', variable: 'GH_TOKEN')]) {
|
|
58
|
-
sh "${env.ASDLC} impl-review --pr ${env.PR_NUMBER} --repo ${env.REPO}"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
49
|
+
# Independent Review Agent session executes: /asdlc:impl-review $PR_NUMBER $REPO
|
|
62
50
|
```
|
|
63
51
|
|
|
64
52
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: asdlc-init
|
|
3
|
-
description: "Initialize an enterprise repository for Agentic SDLC: setup OpenSpec, Graphify code AST graph, governance policies,
|
|
3
|
+
description: "Initialize an enterprise repository for Agentic SDLC: setup OpenSpec, Graphify code AST graph, governance policies, and bundled skills."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# /asdlc:init - Repository Initialization & Tooling Setup
|
|
@@ -11,14 +11,13 @@ This skill executes **Stage 1 (Init)** of the Agentic SDLC. It transitions an un
|
|
|
11
11
|
|
|
12
12
|
## What this skill does
|
|
13
13
|
|
|
14
|
-
1. **Detects Environment**: Inspects the repository type (Node, Python, Go, Java) and active agent toolchains (`.agents`, `.claude`, `.opencode`, Cursor, etc.).
|
|
15
|
-
2. **
|
|
16
|
-
3. **Executes `asdlc init`**: Runs the CLI initialization command to
|
|
17
|
-
-
|
|
14
|
+
1. **Detects Environment**: Inspects the repository type (Node, Python, Go, Java, Rust) and active agent toolchains (`.agents`, `.claude`, `.opencode`, Cursor, etc.).
|
|
15
|
+
2. **Zero-Intrusion Integration**: Bundles the OpenSpec engine directly inside `asdlc`—zero extraneous `package.json` or `node_modules` are introduced into non-Node repositories.
|
|
16
|
+
3. **Executes `asdlc init`**: Runs the CLI initialization command to configure:
|
|
17
|
+
- Zero-intrusion bundled OpenSpec runtime with stateless schema validation
|
|
18
18
|
- Graphify code knowledge graph engine
|
|
19
19
|
- Enterprise managed schema (`agentic-repo-change`)
|
|
20
20
|
- Platform governance policy (`.sdlc/policy.yaml`)
|
|
21
|
-
- Git hook guards (`.githooks/` for pre-push and post-merge)
|
|
22
21
|
- Bundled IDE skills (`grilling`, `asdlc-apply`, and `/asdlc:*` suite)
|
|
23
22
|
- Context routing layer (`AGENTS.md`)
|
|
24
23
|
4. **Validates Health**: Automatically runs `asdlc doctor` to ensure zero configuration drifts.
|
|
@@ -27,28 +26,22 @@ This skill executes **Stage 1 (Init)** of the Agentic SDLC. It transitions an un
|
|
|
27
26
|
|
|
28
27
|
## Workflow Sequence
|
|
29
28
|
|
|
30
|
-
### Step 1:
|
|
31
|
-
Ask the user if they want automated Jenkins CI gate pipeline generation:
|
|
32
|
-
- Standard: `asdlc init`
|
|
33
|
-
- With Jenkins CI: `asdlc init --ci jenkins`
|
|
34
|
-
|
|
35
|
-
### Step 2: Execute Initialization
|
|
29
|
+
### Step 1: Execute Initialization
|
|
36
30
|
Run in the repository root:
|
|
37
31
|
|
|
38
32
|
```powershell
|
|
39
|
-
asdlc init
|
|
33
|
+
asdlc init
|
|
40
34
|
```
|
|
41
35
|
|
|
42
36
|
Parse output and verify:
|
|
43
|
-
- `installed openspec` (
|
|
37
|
+
- `installed openspec` (zero-intrusion bundled runtime)
|
|
44
38
|
- `installed managed schema v1`
|
|
45
39
|
- `wrote governance config (openspec/config.yaml)`
|
|
46
|
-
- `installed .githooks`
|
|
47
40
|
- `installed bundled skills -> .agents/skills/`
|
|
48
41
|
- `built graphify code graph -> graphify-out/`
|
|
49
42
|
- `refreshed AGENTS.md`
|
|
50
43
|
|
|
51
|
-
### Step
|
|
44
|
+
### Step 2: Run Environment Health Check
|
|
52
45
|
Execute:
|
|
53
46
|
|
|
54
47
|
```powershell
|
|
@@ -58,11 +51,11 @@ asdlc doctor
|
|
|
58
51
|
Verify that all checks are `[PASS]`:
|
|
59
52
|
- Node version >= 20.19
|
|
60
53
|
- OpenSpec CLI present
|
|
61
|
-
- Managed schema installed centrally
|
|
54
|
+
- Managed schema installed centrally (or bundled stateless)
|
|
62
55
|
- `.sdlc/policy.yaml` present
|
|
63
56
|
- `AGENTS.md` routing valid
|
|
64
57
|
|
|
65
|
-
### Step
|
|
58
|
+
### Step 3: Next Steps Orientation
|
|
66
59
|
Inform the developer:
|
|
67
60
|
> "Repository successfully initialized with Agentic SDLC governance! To start your first feature, run:
|
|
68
61
|
> `/asdlc:new \"<your feature requirement>\"`"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: asdlc-pr
|
|
3
|
-
description: "Open a Spec or Implementation PR: pre-flight checks (lint vs verify),
|
|
3
|
+
description: "Open a Spec or Implementation PR: pre-flight checks (lint vs verify), smart staging, auto-extract title/body, and attach labels (asdlc:spec-review vs asdlc:impl-review) for independent review agents."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# /asdlc:pr - Automated Pull Request Engine (Spec & Implementation)
|
|
7
7
|
|
|
8
|
-
This skill opens a **Spec PR** (Stage 3) or an **Implementation PR** (Stage 6.5) with deterministic pre-flight quality gates and distinct labels
|
|
8
|
+
This skill opens a **Spec PR** (Stage 3) or an **Implementation PR** (Stage 6.5) with deterministic pre-flight quality gates, smart staging guards, and distinct labels routing to independent review agent sessions.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -22,10 +22,10 @@ asdlc pr <CHANGE_ID> <targetBranch>
|
|
|
22
22
|
|
|
23
23
|
## Dual-PR Lifecycle & Pre-flight Gates
|
|
24
24
|
|
|
25
|
-
| PR Type | Phase & Moment | Pre-Flight Guard | Auto Labels |
|
|
25
|
+
| PR Type | Phase & Moment | Pre-Flight Guard | Auto Labels | Review Automation Trigger |
|
|
26
26
|
| :--- | :--- | :--- | :--- | :--- |
|
|
27
|
-
| **Spec PR** | Stage 3 (After drafting proposal & specs) | **`asdlc lint <ID>`**<br>(0 blocking BDD/AC issues) | `asdlc:spec-review`<br>`spec` | Runs `asdlc lint` +
|
|
28
|
-
| **Impl PR** | Stage 6.5 (After TDD apply & tasks complete) | **`asdlc verify <ID>`**<br>(12 deterministic gates pass) | `asdlc:impl-review`<br>`impl` | Runs `asdlc verify` +
|
|
27
|
+
| **Spec PR** | Stage 3 (After drafting proposal & specs) | **`asdlc lint <ID>`**<br>(0 blocking BDD/AC issues) | `asdlc:spec-review`<br>`spec` | Runs `asdlc lint` + routes to **Independent Spec AI Review** (`asdlc-spec-review`) |
|
|
28
|
+
| **Impl PR** | Stage 6.5 (After TDD apply & tasks complete) | **`asdlc verify <ID>`**<br>(12 deterministic gates pass) | `asdlc:impl-review`<br>`impl` | Runs `asdlc verify` + routes to **Independent Impl AI Review** (`asdlc-impl-review`) |
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -49,11 +49,16 @@ asdlc pr <CHANGE_ID> <targetBranch>
|
|
|
49
49
|
- **Spec PR**: derives clean title (`spec(<slug>): <title>`) and embeds proposal intent.
|
|
50
50
|
- **Impl PR**: derives title (`impl(<slug>): <title>`) and embeds completed tasks, TDD evidence, and spec intent.
|
|
51
51
|
|
|
52
|
-
4. **
|
|
52
|
+
4. **Smart Staging & Commit**:
|
|
53
|
+
- Instead of a blind `git add -A`, `asdlc pr` applies a deterministic safety filter:
|
|
54
|
+
- Automatically skips untracked sensitive credentials (`.env*`, `*.pem`, `*.key`, `*.p12`, secrets).
|
|
55
|
+
- Automatically skips crash dumps and logs (`*.hprof`, `*.dmp`, `core.*`, `*.log`).
|
|
56
|
+
- Automatically skips oversized untracked binaries (`> 50MB`).
|
|
57
|
+
- Emits visible `[WARN]` diagnostics without breaking unattended automation.
|
|
58
|
+
- Safely stages legitimate tracked edits and untracked code/spec files, commits with standard prefix, and pushes branch to origin.
|
|
53
59
|
|
|
54
60
|
5. **Creation Strategy & Self-Healing Label Guarantee**:
|
|
55
|
-
- **JIT Label Provisioning**: Before creating or editing the PR, `asdlc pr` provisions required governance labels on remote (`asdlc:spec-review` + `spec` or `asdlc:impl-review` + `impl`).
|
|
61
|
+
- **JIT Label Provisioning**: Before creating or editing the PR, `asdlc pr` provisions required governance labels on remote (`asdlc:spec-review` + `spec` or `asdlc:impl-review` + `impl`).
|
|
56
62
|
- **Tier 1 (CLI)**: Executes `gh pr create` with both labels (`--label asdlc:spec-review,spec`). If a PR for the branch already exists, detects it and runs `gh pr edit --add-label` to ensure labels are attached.
|
|
57
63
|
- **Tier 2 (Direct REST API)**: Pre-creates labels via GitHub API and attaches them to the PR issue.
|
|
58
64
|
- **Tier 3 (Browser Fallback)**: Generates a 1-click comparison URL pre-filled with branch and label query parameters.
|
|
59
|
-
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: asdlc-review
|
|
3
|
-
description: "
|
|
3
|
+
description: "Independent fresh-context spec review helper. Primary reviews run via asdlc-spec-review and asdlc-impl-review agent sessions."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# /asdlc:review - Independent Spec Review
|
|
6
|
+
# /asdlc:review - Independent Spec Review Helper
|
|
7
7
|
|
|
8
8
|
> [!NOTE]
|
|
9
|
-
> **
|
|
10
|
-
> Spec
|
|
11
|
-
>
|
|
9
|
+
> **Independent Agent Session Review**:
|
|
10
|
+
> Spec and implementation reviews are executed by dedicated **Independent Review Agent Sessions** (`asdlc-spec-review` and `asdlc-impl-review`) adhering to the **Player ≠ Referee** principle.
|
|
11
|
+
> This skill (`asdlc-review`) is retained as a local fresh-context dry-run helper to inspect changes and generate or preview `review.md`.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
When invoked, it switches into the **Independent Reviewer** role (Player ≠ Referee). The reviewer MUST NOT be the authoring agent of the change.
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
## Review Dimensions
|
|
18
18
|
|
|
19
|
-
Every change is evaluated along six dimensions:
|
|
19
|
+
Every change is evaluated along six core dimensions:
|
|
20
20
|
|
|
21
21
|
1. **Completeness**: Are all user journeys covered? Are edge cases, error conditions, and nil/empty inputs handled?
|
|
22
22
|
2. **Ambiguity**: Are requirements clear and unambiguous? Does each use strict normative language (`SHALL` / `MUST`) rather than passive voice?
|
|
@@ -27,7 +27,7 @@ This skill can be invoked:
|
|
|
27
27
|
2. **Automatically on PRs** carrying the `asdlc:spec-review` label via PR automation workflows:
|
|
28
28
|
|
|
29
29
|
```yaml
|
|
30
|
-
# GitHub Actions example
|
|
30
|
+
# GitHub Actions / PR Automation example
|
|
31
31
|
- name: AI Spec Review
|
|
32
32
|
if: contains(github.event.pull_request.labels.*.name, 'asdlc:spec-review')
|
|
33
33
|
env:
|
|
@@ -35,19 +35,7 @@ This skill can be invoked:
|
|
|
35
35
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
36
36
|
REPO: ${{ github.repository }}
|
|
37
37
|
run: |
|
|
38
|
-
#
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```groovy
|
|
42
|
-
// Jenkinsfile example
|
|
43
|
-
stage('Spec AI Review') {
|
|
44
|
-
when { expression { env.IS_IMPL != 'true' } }
|
|
45
|
-
steps {
|
|
46
|
-
withCredentials([string(credentialsId: 'github-token', variable: 'GH_TOKEN')]) {
|
|
47
|
-
sh "${env.ASDLC} spec-review --pr ${env.PR_NUMBER} --repo ${env.REPO}"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
38
|
+
# Independent Review Agent session executes: /asdlc:spec-review $PR_NUMBER $REPO
|
|
51
39
|
```
|
|
52
40
|
|
|
53
41
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akjamie/agentic-sdlc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@fission-ai/openspec": "1.13.2",
|
|
42
43
|
"commander": "^12.1.0",
|
|
43
44
|
"yaml": "^2.6.1"
|
|
44
45
|
}
|
package/src/assess/ai_judge.js
CHANGED
|
@@ -80,6 +80,38 @@ export function validateAIClassificationExpectation(aiOutput, { changedFiles = [
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Invariant 4 (Escalate-Only Ratchet): When no substantive files exist yet (stage new / spec),
|
|
84
|
+
// author-agent self-assessment CANNOT claim pure_doc / pure_test unless the requirement text
|
|
85
|
+
// itself deterministically indicates test or documentation work without code/API/security intent.
|
|
86
|
+
if (substantiveFiles.length === 0 && reqLower.trim() && (aiOutput.is_pure_test || aiOutput.is_pure_doc)) {
|
|
87
|
+
const hasDocSignal = /(?:\b(?:docs?|documentation|readme|typo|typos|comments?|whitespace|changelog|markdown|license)\b|文档|注释|错别字|说明文档)/i.test(reqLower);
|
|
88
|
+
const hasTestSignal = /(?:\b(?:unit\s+tests?|integration\s+tests?|e2e\s+tests?|test\s+suites?|test\s+cases?|tests?|testing|mocks?|fixtures?)\b|单元测试|集成测试|测试用例)/i.test(reqLower);
|
|
89
|
+
|
|
90
|
+
// Substantive code refactoring or implementation cannot be claimed as pure doc (e.g. "重构订单状态机并补充注释" is code, not doc)
|
|
91
|
+
const hasCodeRefactorOrMutation = /(?:\b(?:refactor|rewrite|redesign|state\s+machine)\b|重构|重写|状态机)/i.test(reqLower) ||
|
|
92
|
+
/\b(?:implement|build|create)\b.*\b(?:api|endpoint|service|controller|router|table|database|schema|handler)\b/i.test(reqLower) ||
|
|
93
|
+
/(?:实现|开发|创建|新增)\b.*(?:接口|服务|路由|数据表|表结构|控制器)/i.test(reqLower) ||
|
|
94
|
+
CANONICAL_DESTRUCTIVE_PATTERN.test(reqLower);
|
|
95
|
+
|
|
96
|
+
// Evaluate doc claim independently (prevents truth table bypass if both is_pure_doc and is_pure_test are set)
|
|
97
|
+
if (aiOutput.is_pure_doc && (!hasDocSignal || hasCodeRefactorOrMutation)) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
error: 'Invariant violation: agent assessment cannot downgrade code/architecture requirement to L0 doc_only',
|
|
101
|
+
override: { is_pure_test: false, is_pure_doc: false, classification: 'internal_code' }
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Evaluate test claim independently
|
|
106
|
+
if (aiOutput.is_pure_test && (!hasTestSignal || CANONICAL_DESTRUCTIVE_PATTERN.test(reqLower) || /(?:\b(?:refactor|rewrite|redesign)\b|重构|重写)/i.test(reqLower) || hasCodeRefactorOrMutation)) {
|
|
107
|
+
return {
|
|
108
|
+
ok: false,
|
|
109
|
+
error: 'Invariant violation: agent assessment cannot downgrade destructive or refactoring requirement to L0 test_only',
|
|
110
|
+
override: { is_pure_test: false, is_pure_doc: false, classification: 'internal_code' }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
83
115
|
return { ok: true, validated: aiOutput };
|
|
84
116
|
}
|
|
85
117
|
|
|
@@ -132,13 +164,14 @@ export function judgeChangeSemantics({ requirement = '', changedFiles = [], repo
|
|
|
132
164
|
|
|
133
165
|
// 3. Validated baseline heuristic seed (deterministic fallback for standalone CLI execution)
|
|
134
166
|
if (!rawAiOutput) {
|
|
135
|
-
const hasProductionTarget = /\b(create|add|implement|build)\b.*\b(api|endpoint|service|table|database|schema|handler|router)\b/i.test(req)
|
|
167
|
+
const hasProductionTarget = /\b(create|add|implement|build)\b.*\b(api|endpoint|service|table|database|schema|handler|router)\b/i.test(req) ||
|
|
168
|
+
/(?:创建|新增|实现|开发)\b.*(?:接口|服务|路由|数据表|表结构|控制器)/i.test(req);
|
|
136
169
|
const hasDestructiveAction = CANONICAL_DESTRUCTIVE_PATTERN.test(req);
|
|
137
170
|
|
|
138
|
-
const isDocIntent =
|
|
171
|
+
const isDocIntent = /(?:\b(?:typo|typos|readme|docs?|documentation|comments?|whitespace|markdown|license|changelog)\b|错别字|文档|注释|说明文档)/i.test(req) &&
|
|
139
172
|
!hasProductionTarget && !hasDestructiveAction;
|
|
140
173
|
|
|
141
|
-
const isTestIntent =
|
|
174
|
+
const isTestIntent = /(?:\b(?:tests?|testing|mocks?|fixtures?|suites?|unittests?|integrationtests?)\b|单元测试|集成测试|测试用例)/i.test(req) &&
|
|
142
175
|
!hasProductionTarget && !hasDestructiveAction;
|
|
143
176
|
|
|
144
177
|
// Few-shot file pattern seeds (illustrative samples)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const HARNESS_RULES_VERSION = '2026.10.0';
|
|
2
|
-
export const ENGINE_VERSION = '1.
|
|
2
|
+
export const ENGINE_VERSION = '1.6.0';
|
|
3
3
|
|
|
4
4
|
export const RISK_LEVELS = {
|
|
5
5
|
L0: 'L0',
|
|
@@ -28,7 +28,7 @@ export const DEFAULT_GOVERNANCE = {
|
|
|
28
28
|
auto_approval: 'disabled'
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export const CANONICAL_DESTRUCTIVE_PATTERN =
|
|
31
|
+
export const CANONICAL_DESTRUCTIVE_PATTERN = /(?:\b(?:drop\s+(?:table|column|database|index|schema)|truncate\s+(?:table|database)?|purge\s+(?:data|table|database)|hard\s+delete|clean\s+database|destroy\s+database)\b|删表|删除[^\n,。;]{0,12}(?:表|库|数据库)|清空[^\n,。;]{0,10}表|清理历史[^\n,。;]{0,12}(?:表|数据|账务|记录)|物理删除|销毁[^\n,。;]{0,10}(?:库|数据库|表)|截断[^\n,。;]{0,8}表|抹除[^\n,。;]{0,10}数据)/i;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Hard Signal Rules (§5.2):
|
|
@@ -52,7 +52,7 @@ export function evaluateV2Security({ requirement = '', changedFiles = [], repoRo
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// 2. Check Requirement Semantics for Security/Financial/Regulatory
|
|
55
|
+
// 2. Check Requirement Semantics for Security/Financial/Regulatory (English + Chinese)
|
|
56
56
|
const highRiskCompounds = [
|
|
57
57
|
'access token', 'refresh token', 'bearer token', 'session token', 'auth token', 'security token',
|
|
58
58
|
'jwt', 'oauth', 'private key', 'secret key', 'password hash', 'password encryption',
|
|
@@ -60,11 +60,21 @@ export function evaluateV2Security({ requirement = '', changedFiles = [], repoRo
|
|
|
60
60
|
'refund ledger', 'clearing settlement', 'credit card'
|
|
61
61
|
];
|
|
62
62
|
|
|
63
|
+
const cjkHighRiskCompounds = [
|
|
64
|
+
'清结算', '资金清算', '账务清算', '资金账本', '核心账务', '对账', '打款', '提现',
|
|
65
|
+
'私钥', '密钥轮换', '密码哈希', '密码加密', '鉴权绕过', '越权', '隐私合规', '实名认证', '数据脱敏'
|
|
66
|
+
];
|
|
67
|
+
|
|
63
68
|
const genericSecWords = [
|
|
64
69
|
'auth', 'authentication', 'password', 'credential', 'crypto',
|
|
65
70
|
'payment', 'payout', 'refund', 'billing', 'ledger', 'wallet', 'clearing'
|
|
66
71
|
];
|
|
67
72
|
|
|
73
|
+
const cjkGenericSecWords = [
|
|
74
|
+
'支付', '结算', '账务', '账本', '钱包', '计费', '账单', '退款',
|
|
75
|
+
'鉴权', '认证', '权限', '密钥', '令牌', '加密', '登录态'
|
|
76
|
+
];
|
|
77
|
+
|
|
68
78
|
let compoundHit = null;
|
|
69
79
|
for (const compound of highRiskCompounds) {
|
|
70
80
|
const re = new RegExp(`\\b${compound.replace(/-/g, '[-\\s]')}\\b`, 'i');
|
|
@@ -73,6 +83,14 @@ export function evaluateV2Security({ requirement = '', changedFiles = [], repoRo
|
|
|
73
83
|
break;
|
|
74
84
|
}
|
|
75
85
|
}
|
|
86
|
+
if (!compoundHit) {
|
|
87
|
+
for (const cjkCompound of cjkHighRiskCompounds) {
|
|
88
|
+
if (req.includes(cjkCompound)) {
|
|
89
|
+
compoundHit = cjkCompound;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
76
94
|
|
|
77
95
|
const matchedGenerics = [];
|
|
78
96
|
for (const word of genericSecWords) {
|
|
@@ -81,6 +99,11 @@ export function evaluateV2Security({ requirement = '', changedFiles = [], repoRo
|
|
|
81
99
|
matchedGenerics.push(word);
|
|
82
100
|
}
|
|
83
101
|
}
|
|
102
|
+
for (const cjkWord of cjkGenericSecWords) {
|
|
103
|
+
if (req.includes(cjkWord)) {
|
|
104
|
+
matchedGenerics.push(cjkWord);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
84
107
|
|
|
85
108
|
const aiJudgment = judgeChangeSemantics({ requirement: req, changedFiles });
|
|
86
109
|
const isDocOrTest = aiJudgment.is_pure_test || aiJudgment.is_pure_doc;
|
|
@@ -166,29 +166,47 @@ export function evaluateV3Topology({ requirement = '', changedFiles = [], repoRo
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
// 3. Check Requirement Semantics for Architecture / Schema / Infra
|
|
169
|
+
// 3. Check Requirement Semantics for Architecture / Schema / Infra (English + Chinese)
|
|
170
170
|
const topoKeywords = [
|
|
171
171
|
'api', 'endpoint', 'openapi', 'swagger', 'grpc', 'protobuf', 'graphql', 'webhook',
|
|
172
172
|
'fastapi', 'springboot', 'spring boot', 'controller', 'rest api', 'router',
|
|
173
173
|
'database', 'migration', 'schema', 'db table', 'database table', 'sql table', 'ddl', 'model', 'docker', 'k8s', 'helm'
|
|
174
174
|
];
|
|
175
175
|
|
|
176
|
+
const cjkTopoKeywords = [
|
|
177
|
+
'接口', '路由', '协议', '网关', '控制器', '出入参', '字段变更',
|
|
178
|
+
'数据库', '数据表', '表结构', '数据库迁移', '索引变更', '容器编排'
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
let matchedTopoKw = null;
|
|
176
182
|
for (const kw of topoKeywords) {
|
|
177
183
|
const re = new RegExp(`\\b${kw.replace(/-/g, '[-\\s]')}\\b`, 'i');
|
|
178
184
|
if (re.test(req)) {
|
|
179
|
-
|
|
180
|
-
if (level === 'L1') {
|
|
181
|
-
level = 'L2';
|
|
182
|
-
}
|
|
183
|
-
evidence.push({
|
|
184
|
-
id: 'V3_TOPOLOGY_KEYWORD',
|
|
185
|
-
kind: 'task_statement',
|
|
186
|
-
signal: 'soft',
|
|
187
|
-
summary: `Requirement touches cross-boundary architectural keyword: '${kw}'`
|
|
188
|
-
});
|
|
185
|
+
matchedTopoKw = kw;
|
|
189
186
|
break;
|
|
190
187
|
}
|
|
191
188
|
}
|
|
189
|
+
if (!matchedTopoKw) {
|
|
190
|
+
for (const cjkKw of cjkTopoKeywords) {
|
|
191
|
+
if (req.includes(cjkKw)) {
|
|
192
|
+
matchedTopoKw = cjkKw;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (matchedTopoKw) {
|
|
199
|
+
no_signal = false;
|
|
200
|
+
if (level === 'L1') {
|
|
201
|
+
level = 'L2';
|
|
202
|
+
}
|
|
203
|
+
evidence.push({
|
|
204
|
+
id: 'V3_TOPOLOGY_KEYWORD',
|
|
205
|
+
kind: 'task_statement',
|
|
206
|
+
signal: 'soft',
|
|
207
|
+
summary: `Requirement touches cross-boundary architectural keyword: '${matchedTopoKw}'`
|
|
208
|
+
});
|
|
209
|
+
}
|
|
192
210
|
|
|
193
211
|
return {
|
|
194
212
|
level,
|
package/src/commands/apply.js
CHANGED
|
@@ -41,7 +41,7 @@ export function applyGuard(changeId, opts = {}) {
|
|
|
41
41
|
|
|
42
42
|
const locked = [`openspec/changes/${slug}/proposal.md`, `openspec/changes/${slug}/specs`];
|
|
43
43
|
|
|
44
|
-
const levelInfo = readEffectiveLevel(repoRoot, slug);
|
|
44
|
+
const levelInfo = readEffectiveLevel(repoRoot, slug, { baseRef: branch });
|
|
45
45
|
if (levelInfo?.tampered) {
|
|
46
46
|
fail(`cannot apply '${slug}': declared level in .openspec.yaml (${levelInfo.declaredLevel}) is lower than recorded history (${levelInfo.maxHistoryLevel}). Manual level downgrading is strictly forbidden.`, {
|
|
47
47
|
code: 'LEVEL_TAMPERED',
|
package/src/commands/approve.js
CHANGED
|
@@ -3,7 +3,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
3
3
|
import { exists, readText, writeText } from '../lib/fs.js';
|
|
4
4
|
import { changeDir } from '../lib/paths.js';
|
|
5
5
|
import { requireRepo, toChangeSlug } from '../lib/cliutil.js';
|
|
6
|
-
import { headSha, git, isGitRepo, lastCommitTouching, changeOnRef } from '../lib/git.js';
|
|
6
|
+
import { headSha, git, isGitRepo, lastCommitTouching, changeOnRef, safeCommit } from '../lib/git.js';
|
|
7
7
|
import { loadPolicy } from '../lib/policy.js';
|
|
8
8
|
import { classifyPR } from '../lib/prtype.js';
|
|
9
9
|
import { fail } from '../lib/errors.js';
|
|
@@ -126,8 +126,7 @@ export function mergeChange(changeId, opts = {}) {
|
|
|
126
126
|
if (opts.commit !== false) {
|
|
127
127
|
try {
|
|
128
128
|
execFileSync('git', ['add', `openspec/changes/${slug}/.openspec.yaml`, `openspec/changes/${slug}/review.md`], { cwd: repoRoot, stdio: 'ignore' });
|
|
129
|
-
|
|
130
|
-
'commit', '-m', `chore(approve): spec approved @ ${approvedSha.slice(0, 8)} (${slug})`], { cwd: repoRoot, stdio: 'ignore' });
|
|
129
|
+
safeCommit(repoRoot, `chore(approve): spec approved @ ${approvedSha.slice(0, 8)} (${slug})`);
|
|
131
130
|
log.ok('committed approval stamp');
|
|
132
131
|
} catch {
|
|
133
132
|
log.warn('nothing to commit (already stamped)');
|