From 5b7105d42374d95060c2678bd8cf9537909ec0fc Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Thu, 29 Oct 2026 05:57:01 +0300 Subject: [PATCH] feat: add experimental wealth-ledger-sdd-lab OpenSpec schema (#61) --- .../schemas/wealth-ledger-sdd-lab/check.cjs | 294 ++++++++ .../schemas/wealth-ledger-sdd-lab/schema.yaml | 671 ++++++++++++++++++ .../templates/data-mapping.md | 29 + .../wealth-ledger-sdd-lab/templates/design.md | 58 ++ .../templates/docs-impact.md | 18 + .../templates/failure-model.md | 26 + .../wealth-ledger-sdd-lab/templates/nfr.md | 14 + .../templates/observability.md | 24 + .../templates/process-record.md | 57 ++ .../templates/proposal.md | 36 + .../templates/qa-analysis.md | 34 + .../templates/research.md | 28 + .../templates/security-analysis.md | 26 + .../wealth-ledger-sdd-lab/templates/spec.md | 18 + .../templates/system-analysis.md | 50 ++ .../wealth-ledger-sdd-lab/templates/tasks.md | 18 + .../templates/test-cases.md | 16 + .../templates/ux-design.md | 40 ++ 18 files changed, 1457 insertions(+) create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/check.cjs create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/schema.yaml create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/data-mapping.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/design.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/docs-impact.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/failure-model.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/nfr.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/observability.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/process-record.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/proposal.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/qa-analysis.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/research.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/security-analysis.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/spec.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/system-analysis.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/tasks.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/test-cases.md create mode 100644 openspec/schemas/wealth-ledger-sdd-lab/templates/ux-design.md diff --git a/openspec/schemas/wealth-ledger-sdd-lab/check.cjs b/openspec/schemas/wealth-ledger-sdd-lab/check.cjs new file mode 100644 index 0000000..834874a --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/check.cjs @@ -0,0 +1,294 @@ +#!/usr/bin/env node +// Deterministic checks for wealth-ledger-sdd-lab changes. OpenSpec CLI 1.13.1 has no conditional +// artifacts, gate records or archive policy, so this file covers only what the CLI cannot. +// It is the single source for profile, ordering, gate and readiness rules; schema.yaml points here. +// Semantic quality (contradictions, invented facts, design fit) stays with reviewers. +// +// Usage: node check.cjs [--root ] +// plan — artifact consistency while planning; missing gates are notes, not errors. +// apply — plan + every apply blocker is an error. +// archive — apply + all tasks done, G4 approved, lab retrospective. +// Exit: 0 ok, 1 violations, 2 invocation/environment error. +"use strict"; +const fs = require("node:fs"); +const path = require("node:path"); + +const SA_MODULES = ["data-mapping", "failure-model", "nfr", "observability"]; +// Primary file of each conditional artifact, relative to the change directory. +const PRIMARY = { + research: "research.md", + "ux-design": "ux-design.md", + "system-analysis": "system-analysis/system-analysis.md", + "data-mapping": "system-analysis/data-mapping.md", + "failure-model": "system-analysis/failure-model.md", + nfr: "system-analysis/nfr.md", + observability: "system-analysis/observability.md", + "security-analysis": "security-analysis.md", + "test-cases": "test-cases", + "docs-impact": "docs-impact.md", +}; +const CONDITIONAL = Object.keys(PRIMARY); +// A selected conditional input must exist before any of these files is written. +const BEFORE_SOLUTION = ["design.md", "qa-analysis.md", "tasks.md"]; +const DOWNSTREAM = { + research: ["specs", ...BEFORE_SOLUTION], + "ux-design": BEFORE_SOLUTION, + "system-analysis": BEFORE_SOLUTION, + ...Object.fromEntries(SA_MODULES.map((id) => [id, BEFORE_SOLUTION])), + "security-analysis": BEFORE_SOLUTION, + "test-cases": ["tasks.md"], + "docs-impact": ["tasks.md"], +}; +// Gate that may approve each artifact. Complex changes approve system analysis at G2 (contract-first). +const SA_IDS = ["system-analysis", ...SA_MODULES]; +const allowedGates = (id, complex, hasG2) => { + if (id === "proposal") return ["G1"]; + if (id === "change-profile") return ["G1", "G2", "G3"]; // later profile changes need a recorded decision + if (id === "specs") return hasG2 ? ["G2"] : ["G3"]; + if (SA_IDS.includes(id)) return complex ? ["G2"] : hasG2 ? ["G2", "G3"] : ["G3"]; + return ["G3"]; +}; +const NOT_APPROVED = new Set(["research", "process-record"]); // input context / the log itself +const REF = /`([a-z0-9][a-z0-9/-]*)`\s*[—–-]\s*`([^`]+)`/g; + +const fail = (msg) => { console.error(msg); process.exit(2); }; +const args = process.argv.slice(2); +const [mode, changeName] = args; +if (!["plan", "apply", "archive"].includes(mode) || !changeName) { + fail("Usage: node check.cjs [--root ]"); +} +const rootIdx = args.indexOf("--root"); +if (rootIdx > 0 && !args[rootIdx + 1]) fail("--root needs a path"); +const root = path.resolve(rootIdx > 0 ? args[rootIdx + 1] : path.join(__dirname, "..", "..")); +const changeDir = path.join(root, "changes", changeName); +if (!fs.existsSync(changeDir)) fail(`Change directory not found: ${changeDir}`); + +const errors = []; +const warnings = []; +const notes = []; +const rel = (p) => path.relative(changeDir, p); +const read = (p) => fs.readFileSync(p, "utf8"); +const at = (p) => path.join(changeDir, p); +const walk = (dir) => fs.existsSync(dir) + ? fs.readdirSync(dir, { withFileTypes: true }).flatMap((e) => + e.isDirectory() ? walk(path.join(dir, e.name)) : [path.join(dir, e.name)]) + : []; +const present = (p) => p === "test-cases" || p === "specs" + ? walk(at(p)).some((f) => f.endsWith(".md")) + : fs.existsSync(at(p)); +const mdFiles = walk(changeDir).filter((f) => f.endsWith(".md")); +const strip = (s) => (s ?? "").replace(/`/g, "").trim(); +// Columns: fixed count, the last cell keeps any `|` it contains. +const tableRows = (text, heading, columns) => { + const section = text.split(/^## /m).find((s) => s.startsWith(heading)); + if (!section) return null; + return section.split("\n").filter((l) => /^\|/.test(l)).slice(2).map((l) => { + const parts = l.replace(/^\|/, "").replace(/\|\s*$/, "").split("|"); + return [...parts.slice(0, columns - 1), parts.slice(columns - 1).join("|")].map((c) => c.trim()); + }); +}; + +finishIfMissing(); +const record = read(at("process-record.md")); + +// 1. Unfilled templates. +for (const f of mdFiles) { + if (read(f).includes(" + +## Source and Target + +| Mapping | Source (owner) | Target (owner) | Direction | Trigger | +| --- | --- | --- | --- | --- | + +## Field Mapping + +| Target field | Source field(s) | Transformation | Unit / currency / scale | Nullability | Default | Validation | On failure | +| --- | --- | --- | --- | --- | --- | --- | --- | + +## Invariants + + + +## Double-counting and Classification Risks + + + +## Transformation Errors + +## Open Questions diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/design.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/design.md new file mode 100644 index 0000000..0ba5533 --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/design.md @@ -0,0 +1,58 @@ +# Engineering Design + + + +## Inputs + + + +## Architecture Drivers + + + +## Technical Goals / Non-Goals + +## Implementation Impact Map + +| Area | Affected | Outcome or N/A reason | +| --- | --- | --- | +| main | | | +| frontend | | | +| backend | | | + +## Decisions + + + +## Components and Responsibilities + +## Data / Storage Changes + +## Contract Implementation + + + +## Cross-cutting Implementation + +## UI Implementation + + + +## Developer Verification Strategy + +## Migration / Rollout / Rollback + +## Solution Assessment + + + +## Risks / Trade-offs + +## ADR Candidates diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/docs-impact.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/docs-impact.md new file mode 100644 index 0000000..715218d --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/docs-impact.md @@ -0,0 +1,18 @@ +# Documentation Impact + + + +## Summary + +## Documentation Changes + +| Action | Target | Category | Resulting AS-IS | Source | Verification | +| --- | --- | --- | --- | --- | --- | + +## Diagram Promotion + +## ADR Decision + +## Glossary / Navigation Impact + +## No-Change Rationale diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/failure-model.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/failure-model.md new file mode 100644 index 0000000..fb0e81e --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/failure-model.md @@ -0,0 +1,26 @@ +# Failure Model + + + +## Failure Scenarios + +| ID | Boundary / step | Failure | Detection | Required system behavior | Observable result | Requirement | +| --- | --- | --- | --- | --- | --- | --- | + +## Timeouts and Retries + +## Idempotency and Duplicate Handling + + + +## Ordering and Concurrency + +## Partial Failure and Compensation + +## Recovery Behavior + +## Compatibility During Failure + +## Open Questions diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/nfr.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/nfr.md new file mode 100644 index 0000000..586c35b --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/nfr.md @@ -0,0 +1,14 @@ +# Non-Functional Requirements + + + +| ID | Category | Requirement | Threshold | Measurement / evidence | Rationale / source | +| --- | --- | --- | --- | --- | --- | + +## Constraints Without Thresholds + + + +## Open Questions diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/observability.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/observability.md new file mode 100644 index 0000000..e328a2f --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/observability.md @@ -0,0 +1,24 @@ +# Observability + + + +## Semantic Events + +| Event | Trigger | Required attributes | Consumer / purpose | +| --- | --- | --- | --- | + +## Logs, Metrics and Traces + +## Correlation + +## SLI and Alert Conditions + +| SLI | Definition | Target | Alert condition | +| --- | --- | --- | --- | + +## Diagnostic Scenarios + + + +## Open Questions diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/process-record.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/process-record.md new file mode 100644 index 0000000..28617c4 --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/process-record.md @@ -0,0 +1,57 @@ +# Process Record + +**Mode:** +**Class:** +**Issue:** + +## Change Profile + + + +| Artifact | Selected | Reason | +| --- | --- | --- | +| research | | | +| ux-design | | | +| system-analysis | | | +| data-mapping | | | +| failure-model | | | +| nfr | | | +| observability | | | +| security-analysis | | | +| test-cases | | | +| docs-impact | | | + +## Gate Log + + + +| Gate | Date | Scope | Validation | Findings | Decision | +| --- | --- | --- | --- | --- | --- | + +## Descoped Work + + + +| Task | Reason | Gate | +| --- | --- | --- | + +## Lab Journal + + + +| Stage | Role / subagent | Unique findings | Decisions | Risks found / excluded | Handoff issues | Skills | Cost | Transferable | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | + +## Retrospective + + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/proposal.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/proposal.md new file mode 100644 index 0000000..8dc2c74 --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/proposal.md @@ -0,0 +1,36 @@ +# Proposal + + + +## Why + +## What Changes + +## Scope + +### In Scope + +### Out of Scope / Non-Goals + +## Capabilities + +### New Capabilities + +### Modified Capabilities + +## Impact + +## Success Criteria + +## Evidence + + + +## Assumptions / Dependencies + +## Open Decisions + + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/qa-analysis.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/qa-analysis.md new file mode 100644 index 0000000..3ef55db --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/qa-analysis.md @@ -0,0 +1,34 @@ +# QA Analysis + + + +## Risk Assessment + +| Risk | Affected requirements | Likelihood | Impact | Verification depth | +| --- | --- | --- | --- | --- | + +## Coverage Matrix + + + +| Requirement | Check | Level | Test cases | +| --- | --- | --- | --- | + +## Negative and Boundary Focus + +## Cross-system Verification + +## Test Data and Environment Needs + +## Manual / Exploratory Scope + +## Automation Candidates + +## Regression Impact + +## Gaps / Blockers + + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/research.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/research.md new file mode 100644 index 0000000..0bd7c2d --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/research.md @@ -0,0 +1,28 @@ +# Product Research + + + +## Problem Statement + +## Target Audience + +## Research Questions + +## Existing Solutions and Alternatives + +| Option | What it does | Strengths | Weaknesses | Source | +| --- | --- | --- | --- | --- | + +## Evidence & Sources + +## Assumptions + +## Risks + +## Conclusions + +## Recommendation + + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/security-analysis.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/security-analysis.md new file mode 100644 index 0000000..6c39a93 --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/security-analysis.md @@ -0,0 +1,26 @@ +# Security Analysis + + + +## Scope + +## Assets + +## Trust Boundaries + +## Threats + +| ID | Threat (STRIDE) | Attack scenario | Asset / boundary | Existing control | Likelihood / impact | +| --- | --- | --- | --- | --- | --- | + +## Recommended Mitigations + +| Threat | Mitigation | Owner artifact (specs / system-analysis / design) | +| --- | --- | --- | + +## Residual Risks + +## Validation Requirements + + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/spec.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/spec.md new file mode 100644 index 0000000..b838743 --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/spec.md @@ -0,0 +1,18 @@ + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/system-analysis.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/system-analysis.md new file mode 100644 index 0000000..0467d0c --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/system-analysis.md @@ -0,0 +1,50 @@ +# System Analysis + + + +## Requirement Coverage + +| Requirement | Flow / contract | Module | +| --- | --- | --- | + +## System Context and Boundaries + +## As-Is / To-Be + +## Impact Analysis + +## Systems and Responsibilities + +## Data Ownership + +| Data | Source of truth | Writers | Readers | +| --- | --- | --- | --- | + +## Interaction Flows + + + +## Contracts + + + +| Contract | Producer → Consumer | File | Compatibility | Published source | +| --- | --- | --- | --- | --- | + +## Error Semantics + + + +## Compatibility / Migration + +## Detailed Modules + + + +## Open Questions diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/tasks.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/tasks.md new file mode 100644 index 0000000..9402737 --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/tasks.md @@ -0,0 +1,18 @@ +# Tasks + + + +## 1. + +## Docs Impact + + diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/test-cases.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/test-cases.md new file mode 100644 index 0000000..4e8b8ae --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/test-cases.md @@ -0,0 +1,16 @@ +# Test Cases — + + + +### TC- + +- **Verifies:** `capability` — `Requirement heading` / Scenario +- **Risk / Priority:** +- **Preconditions:** +- **Test Data:** +- **Steps:** + 1. +- **Expected Results:** +- **Automation Candidate:** diff --git a/openspec/schemas/wealth-ledger-sdd-lab/templates/ux-design.md b/openspec/schemas/wealth-ledger-sdd-lab/templates/ux-design.md new file mode 100644 index 0000000..8dc07de --- /dev/null +++ b/openspec/schemas/wealth-ledger-sdd-lab/templates/ux-design.md @@ -0,0 +1,40 @@ +# UX Design + + + +## User Goals + +## User Flows + + + +## Information Architecture and Screen Structure + +## Interaction Behavior + +## UI States + +| Screen / region | Loading | Empty | Error | Success | Partial / stale | +| --- | --- | --- | --- | --- | --- | + +## Validation Feedback + +## Responsive Behavior + +## Accessibility + + + +## Design System Reuse + +## Materials + + + +| Material ID | Relative path / reference | Screen/state and purpose | SHA-256 | +| --- | --- | --- | --- | + +## Open UX Questions