@chenmk/superflow 0.2.4 → 0.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/README.md +4 -1
- package/README.zh-CN.md +1 -0
- package/assets/manifest.json +3 -1
- package/assets/prompts/superflow-clarify.md +6 -0
- package/assets/prompts/superflow-pipeline.md +8 -0
- package/assets/scripts/superflow-archive-command-hook.sh +80 -0
- package/assets/scripts/superflow-delivery-check.sh +23 -4
- package/assets/skills/superflow-archive/SKILL.md +5 -0
- package/assets/skills/superflow-clarify/SKILL.md +26 -7
- package/assets/skills/superflow-design/SKILL.md +46 -5
- package/assets/skills/superflow-docs/SKILL.md +27 -0
- package/assets/skills/superflow-implement/SKILL.md +17 -0
- package/assets/skills/superflow-pipeline/SKILL.md +47 -0
- package/assets/skills/superflow-pipeline/references/api-design-template.md +11 -0
- package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +44 -0
- package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +48 -0
- package/assets/skills/superflow-pipeline/references/money-precision-algorithms.md +85 -0
- package/assets/skills/superflow-pipeline/references/quality-gate.md +3 -0
- package/assets/skills/superflow-pipeline/references/reviewer-checklist.md +17 -1
- package/assets/skills/superflow-pipeline/references/superpower-technical-design-template.md +90 -0
- package/assets/skills/superflow-pipeline/references/test-execution-template.md +26 -0
- package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +231 -0
- package/assets/skills/superflow-verify/SKILL.md +23 -1
- package/assets/skills-en/superflow-archive/SKILL.md +6 -0
- package/assets/skills-en/superflow-clarify/SKILL.md +26 -7
- package/assets/skills-en/superflow-design/SKILL.md +45 -4
- package/assets/skills-en/superflow-docs/SKILL.md +27 -0
- package/assets/skills-en/superflow-implement/SKILL.md +10 -0
- package/assets/skills-en/superflow-pipeline/SKILL.md +38 -0
- package/assets/skills-en/superflow-pipeline/references/api-design-template.md +13 -0
- package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +28 -0
- package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +33 -0
- package/assets/skills-en/superflow-pipeline/references/money-precision-algorithms.md +96 -0
- package/assets/skills-en/superflow-pipeline/references/quality-gate.md +26 -0
- package/assets/skills-en/superflow-pipeline/references/reviewer-checklist.md +15 -0
- package/assets/skills-en/superflow-pipeline/references/superpower-technical-design-template.md +95 -0
- package/assets/skills-en/superflow-pipeline/references/test-execution-template.md +30 -0
- package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +231 -0
- package/assets/skills-en/superflow-verify/SKILL.md +24 -1
- package/dist/app/commands/archive.js +7 -3
- package/dist/app/commands/archive.js.map +1 -1
- package/dist/app/commands/change-guard.js +27 -0
- package/dist/app/commands/change-guard.js.map +1 -0
- package/dist/app/commands/design.js +2 -20
- package/dist/app/commands/design.js.map +1 -1
- package/dist/app/commands/init.js +1 -5
- package/dist/app/commands/init.js.map +1 -1
- package/dist/app/commands/update.js +2 -5
- package/dist/app/commands/update.js.map +1 -1
- package/dist/app/commands/verify.js +7 -3
- package/dist/app/commands/verify.js.map +1 -1
- package/dist/domains/config/context.js +1 -5
- package/dist/domains/config/context.js.map +1 -1
- package/dist/domains/deps.js +1 -5
- package/dist/domains/deps.js.map +1 -1
- package/dist/domains/hook.js +1 -0
- package/dist/domains/hook.js.map +1 -1
- package/dist/platform/assets.js +9 -0
- package/dist/platform/assets.js.map +1 -0
- package/package.json +3 -2
- package/scripts/release-notes-check.js +102 -0
|
@@ -14,6 +14,10 @@ do not mark archived until the user confirms final closeout.
|
|
|
14
14
|
- `phase: archive`.
|
|
15
15
|
- `verify_result: pass`.
|
|
16
16
|
- `verification_report` points to an existing report.
|
|
17
|
+
- Every checkbox in `tasks.md` is checked.
|
|
18
|
+
- The verification report contains `Verification Result: PASS` and
|
|
19
|
+
`Archive Readiness: PASS`.
|
|
20
|
+
- `branch_status: handled` and `verified_at` are recorded.
|
|
17
21
|
- `superflow-state.sh recover <change-dir>` gives a coherent archive recovery action.
|
|
18
22
|
|
|
19
23
|
## Procedure
|
|
@@ -42,6 +46,8 @@ do not mark archived until the user confirms final closeout.
|
|
|
42
46
|
the user explicitly accepts the boundary.
|
|
43
47
|
- Do not use archive to hide missing API, DB, hook, SQL, test-report, or real
|
|
44
48
|
integration evidence.
|
|
49
|
+
- Never call `openspec archive` directly to bypass the lifecycle gate. The
|
|
50
|
+
installed archive-command hook blocks that path when native hooks are active.
|
|
45
51
|
- In a standard `openspec/changes/<name>` layout, archive must use OpenSpec
|
|
46
52
|
archive semantics so delta specs are merged and the change is moved to
|
|
47
53
|
`openspec/changes/archive/`. State-only archive is only a fallback for
|
|
@@ -50,6 +50,15 @@ any full SDD document or implementation prompt is generated.
|
|
|
50
50
|
external input. If semantics are unclear, mark the feature blocked instead of
|
|
51
51
|
inventing a fallback.
|
|
52
52
|
- Process one feature at a time, in product-document order.
|
|
53
|
+
- When the pipeline selected embedded deep-clarification mode, investigate facts
|
|
54
|
+
from the repository, source documents, configuration, tests, logs, and tools
|
|
55
|
+
before asking. Ask the user only about an unresolved decision that needs owner
|
|
56
|
+
intent; do not ask for facts that can be found locally.
|
|
57
|
+
- In embedded deep-clarification mode, ask exactly one decision question at a
|
|
58
|
+
time. Include the recommended answer and its important consequence, wait for
|
|
59
|
+
the answer, then record the result before asking the next question. Do not
|
|
60
|
+
create SDD artifacts or implementation prompts while a current-feature
|
|
61
|
+
decision remains pending.
|
|
53
62
|
- For long PRDs, Lark/Feishu exports, screenshots, or mixed product docs, do
|
|
54
63
|
not read the whole document and generate all tasks in one pass. First create
|
|
55
64
|
a source index, then process one bounded section or feature at a time. Each
|
|
@@ -85,6 +94,10 @@ Create or update these files in the active OpenSpec change directory:
|
|
|
85
94
|
- Business semantic evidence when status/enum/sync/default behavior is involved:
|
|
86
95
|
source-of-truth field, enum mapping, consumer interpretation, business basis,
|
|
87
96
|
explicitly rejected fallback/default choices, and unresolved owner questions.
|
|
97
|
+
- Deep-clarification decision evidence when this mode is active: each question,
|
|
98
|
+
recommendation, user decision, consequence, and the resulting
|
|
99
|
+
`confirmed`/`candidate`/`pending`/`rejected` entry in
|
|
100
|
+
`.sdd/handoff/brainstorm-summary.md`.
|
|
88
101
|
|
|
89
102
|
Use the detailed workflow in:
|
|
90
103
|
|
|
@@ -127,14 +140,20 @@ Use the detailed workflow in:
|
|
|
127
140
|
If a proposed default, fallback, old-value retention, or null conversion is
|
|
128
141
|
not explicitly approved by the requirement or owner, mark it rejected and do
|
|
129
142
|
not include it in the design.
|
|
130
|
-
11.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
11. If embedded deep-clarification mode is active, resolve one decision at a
|
|
144
|
+
time. For each question, state the recommended answer and consequence, wait
|
|
145
|
+
for the programmer response, then update
|
|
146
|
+
`.sdd/handoff/brainstorm-summary.md` under `confirmed`, `candidate`,
|
|
147
|
+
`pending`, or `rejected`. Stop asking once only repository-verifiable facts
|
|
148
|
+
remain.
|
|
149
|
+
12. Ask only any remaining current-feature clarification questions.
|
|
150
|
+
13. Wait for programmer confirmation.
|
|
151
|
+
14. Draft a rough API contract: path, action, core request, core response. Field types can be approximate.
|
|
152
|
+
15. Wait for programmer confirmation of the rough API.
|
|
153
|
+
16. Produce a precise API section with field names, types, requiredness, defaults, enums, errors, examples, and curl.
|
|
154
|
+
17. Mark the feature as `frozen` only when understanding, rough API, precise API,
|
|
136
155
|
and validation data needs are confirmed or explicitly blocked.
|
|
137
|
-
|
|
156
|
+
18. Only after the current feature is frozen or blocked, move to the next
|
|
138
157
|
indexed feature. Do not batch-confirm multiple features from memory or a
|
|
139
158
|
compressed chat summary.
|
|
140
159
|
|
|
@@ -54,15 +54,56 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
|
|
|
54
54
|
adapter/protocol translator/device gateway into a business-entry
|
|
55
55
|
orchestrator, stop and return to `$superflow-docs` unless the OpenSpec/SDD
|
|
56
56
|
contract explicitly grants that ownership with approval evidence.
|
|
57
|
-
6. For
|
|
57
|
+
6. For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment
|
|
58
|
+
gateways, cloud services, or other external integrations, include
|
|
59
|
+
`External Integration Configuration And Deployment Contract`. Inventory
|
|
60
|
+
every endpoint, app/tenant/project ID, Topic, Tag, Consumer Group,
|
|
61
|
+
namespace, webhook, ACL/role, feature switch, timeout, and credential
|
|
62
|
+
reference. Prove the source and injection/provisioning method for local,
|
|
63
|
+
test, and production environments, plus owner, creation timing, readiness
|
|
64
|
+
check, rollback, and unresolved blockers. Runtime values and server-side
|
|
65
|
+
resources must not exist only as hard-coded annotations/constants. Test
|
|
66
|
+
auto-creation or pre-existing resources must not be treated as proof that
|
|
67
|
+
production will provision them. Missing production provisioning evidence
|
|
68
|
+
blocks design completion.
|
|
69
|
+
7. For concurrent requests, batch issue/activation/renewal, duplicate callbacks,
|
|
70
|
+
duplicate consumption, or repeated external delivery, include
|
|
71
|
+
`Concurrency And Idempotency Ownership`. Use a stable business idempotency
|
|
72
|
+
key and an application-layer atomic claim in a short transaction; persist
|
|
73
|
+
`PENDING` before the external call, release database locks before calling
|
|
74
|
+
externally, model success/failure/uncertain states, and reuse the original
|
|
75
|
+
business code on retry. A unique index is not the default and may only be an
|
|
76
|
+
optional fallback with proven natural uniqueness, historical cleanup,
|
|
77
|
+
NULL/soft-delete semantics, and a conflict contract. Check-then-insert,
|
|
78
|
+
process-local locks, and random IDs alone are blocked.
|
|
79
|
+
8. For field/status/enum/sync changes, include `Field And Status Reverse
|
|
58
80
|
Impact` and prove writers, readers, filters, derived sync paths, consumers,
|
|
59
81
|
and tests. Direct setter-only design is blocked.
|
|
60
|
-
|
|
82
|
+
9. For amount, fee, discount, deduction, refund, sharing, payment, invoice,
|
|
83
|
+
balance, electricity fee, service fee, package settlement, proration,
|
|
84
|
+
allocation, reconciliation, or financial display changes,
|
|
85
|
+
include `Money Precision Boundary`. Prove calculation-state fields,
|
|
86
|
+
settlement/display-state fields, rounding boundary, scale, rounding mode,
|
|
87
|
+
allocation/reconciliation rule, and tests covering half-cent or residual
|
|
88
|
+
cases. If the design rounds money before later slicing, proration,
|
|
89
|
+
aggregation, discounting, or allocation, stop and redesign the calculation
|
|
90
|
+
boundary. When an additive identity has an authoritative total, the design
|
|
91
|
+
must calculate only N-1 components independently and derive the final
|
|
92
|
+
complement as `authoritative total - sum(other components)`. Independently
|
|
93
|
+
calculating and rounding all components before rebuilding the total is
|
|
94
|
+
blocked. A claimed exception must name the actual source of truth and owner
|
|
95
|
+
evidence. Read
|
|
96
|
+
`../superflow-pipeline/references/money-precision-algorithms.md` and also
|
|
97
|
+
freeze the exact representation, currency/minor-unit boundary, rounding
|
|
98
|
+
level and policy source, deterministic residual strategy with stable
|
|
99
|
+
tie-breaker, and positive/zero/negative evidence. For FX changes, freeze the
|
|
100
|
+
directional rate metadata and one canonical conversion path.
|
|
101
|
+
10. Record state:
|
|
61
102
|
```bash
|
|
62
103
|
../superflow-pipeline/scripts/superflow-state.sh set <change-dir> technical_design docs/superpowers/specs/YYYY-MM-DD-<change-id>-technical-design.md
|
|
63
104
|
../superflow-pipeline/scripts/superflow-state.sh set <change-dir> design_doc design.md
|
|
64
105
|
```
|
|
65
|
-
|
|
106
|
+
11. Update `design.md` with `Superpowers Technical Design Handoff`, update
|
|
66
107
|
`sdd-quality-gate.md` with the technical design path and hash, then run
|
|
67
108
|
`../superflow-pipeline/scripts/superflow-handoff.sh <change-dir> --refresh`.
|
|
68
109
|
If the guard reports a stale or missing hash, record the printed hash in
|
|
@@ -70,7 +111,7 @@ Superpowers own source-level HOW without weakening OpenSpec/SDD contracts.
|
|
|
70
111
|
`--refresh` again. Do not set `design_doc` to the Superpowers document;
|
|
71
112
|
`design_doc` is the OpenSpec/SDD contract design, while `technical_design`
|
|
72
113
|
is the Superpowers HOW document.
|
|
73
|
-
|
|
114
|
+
12. Run:
|
|
74
115
|
```bash
|
|
75
116
|
../superflow-pipeline/scripts/superflow-yaml-validate.sh <change-dir>
|
|
76
117
|
../superflow-pipeline/scripts/superflow-guard.sh <change-dir> design --apply
|
|
@@ -76,6 +76,28 @@ For complex requirements, verify these before writing docs:
|
|
|
76
76
|
If the docs only prove that a value exists, is non-null, or lets the request
|
|
77
77
|
succeed, stop and return to `$superflow-clarify`. If fallback/default/keep-old-value
|
|
78
78
|
behavior is proposed without explicit requirement or owner approval, stop.
|
|
79
|
+
- For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment gateways,
|
|
80
|
+
cloud services, or other external integrations, `api.md` and
|
|
81
|
+
`sdd-quality-gate.md` must include `External Integration Configuration And
|
|
82
|
+
Deployment Contract`. Inventory endpoints, app/tenant/project IDs,
|
|
83
|
+
Topic/Tag/Consumer Group, namespace, webhook, ACL/role, feature switches,
|
|
84
|
+
timeout, and credential references across local, test, and production
|
|
85
|
+
environments. Record injection/provisioning method, runtime owner,
|
|
86
|
+
provisioning owner/time, readiness evidence, rollback, secret handling, and
|
|
87
|
+
blockers. Environment-dependent values must not be hard-coded; test
|
|
88
|
+
auto-creation or existing test resources do not prove production readiness.
|
|
89
|
+
Missing production provisioning evidence blocks document freeze.
|
|
90
|
+
- For amount, fee, discount, deduction, refund, sharing, payment, invoice,
|
|
91
|
+
balance, electricity/service fee, package settlement, proration, allocation,
|
|
92
|
+
reconciliation, or financial display changes, `sdd-quality-gate.md` must
|
|
93
|
+
declare `Money Precision Boundary` as blocking. `tests.md` and the
|
|
94
|
+
`test-report.md` skeleton must reserve half-cent, residual, or multi-detail
|
|
95
|
+
cases and reconciliation evidence. Do not freeze docs that allow intermediate
|
|
96
|
+
money to be rounded before later slicing, aggregation, discounting, or
|
|
97
|
+
allocation. For additive identities, docs must name the authoritative total,
|
|
98
|
+
independently calculated N-1 components, and the final complement formula:
|
|
99
|
+
`authoritative total - sum(other components)`. Do not allow every component
|
|
100
|
+
to be calculated and rounded independently before rebuilding the total.
|
|
79
101
|
- For low-freedom implementation handoff, docs include the five hard gates:
|
|
80
102
|
field semantic contract, write-through persistence closure, real-entry call
|
|
81
103
|
chain, no-fallback/no-guessing boundary, and pre-coding agent self-check. If
|
|
@@ -293,6 +315,11 @@ Use references only as needed:
|
|
|
293
315
|
`RED failure evidence`, `GREEN pass evidence`, `interface automation evidence`, `DB evidence`,
|
|
294
316
|
`log evidence`, `manual/blocking cases`, and `Partially verified boundary`.
|
|
295
317
|
Each section must reference concrete `tests.md` case IDs.
|
|
318
|
+
- For money-related changes, `test-report.md` must also include `Money Precision
|
|
319
|
+
Boundary` evidence: original calculation inputs and precision, actual rounding
|
|
320
|
+
boundary and mode, half-cent/residual/multi-detail cases, and reconciliation
|
|
321
|
+
of original, discount, actual/refund, and allocated totals. Evidence must show
|
|
322
|
+
which total was authoritative and which complement was derived by subtraction.
|
|
296
323
|
- `sdd-quality-gate.md` must include blocking checks for:
|
|
297
324
|
executable tests frozen, RED/GREEN expectations present, interface automation
|
|
298
325
|
commands present, DB/log assertions present, and mock/skipped cases excluded
|
|
@@ -60,6 +60,14 @@ Every implementation prompt must include these sections:
|
|
|
60
60
|
DTO, converter, SQL, scheduled job, MQ, callback, and sibling repo references.
|
|
61
61
|
- Field semantic contract: source field, source meaning, target field, target
|
|
62
62
|
meaning, equivalence, evidence anchor, forbidden usage, and owner for unknowns.
|
|
63
|
+
- Money precision boundary when monetary behavior changes: calculation-state
|
|
64
|
+
source and intermediate precision, settlement/display boundary, scale and
|
|
65
|
+
rounding mode, forbidden early rounding, deterministic residual allocation,
|
|
66
|
+
authoritative total, complement derivation as `authoritative total -
|
|
67
|
+
sum(other components)`, and half-cent or multi-detail reconciliation evidence.
|
|
68
|
+
It also inherits `money-precision-algorithms.md`: exact representation,
|
|
69
|
+
currency/provider minor units, rounding policy source, stable residual
|
|
70
|
+
tie-breaker, signed-value evidence, and conditional FX metadata.
|
|
63
71
|
- Write-loop verification: business action, setter/assignment, converter, mapper
|
|
64
72
|
insert/update, DB column, downstream reader, consumer entry, SQL check, test
|
|
65
73
|
case.
|
|
@@ -99,6 +107,8 @@ Block prompt generation or execution when any of these are missing:
|
|
|
99
107
|
- handoff files and matching hash;
|
|
100
108
|
- technical_design for full workflow;
|
|
101
109
|
- field/status reverse impact matrix when risky fields or states are touched;
|
|
110
|
+
- money precision boundary when monetary calculation, settlement, allocation,
|
|
111
|
+
reconciliation, or financial display is touched;
|
|
102
112
|
- architecture boundary and call-direction matrix for cross-service or external
|
|
103
113
|
flows;
|
|
104
114
|
- executable tests.md commands for L3/L4 or real-entry requirements;
|
|
@@ -37,6 +37,11 @@ hotfix:
|
|
|
37
37
|
|
|
38
38
|
## Routing
|
|
39
39
|
|
|
40
|
+
- When the user explicitly asks for rigorous questioning, or a bounded feature
|
|
41
|
+
has unresolved owner decisions, mutually exclusive approaches, an unclear
|
|
42
|
+
source of truth, unclear acceptance behavior, or cross-system responsibility,
|
|
43
|
+
use `superflow-clarify` in embedded deep-clarification mode. This is a mode
|
|
44
|
+
inside the normal clarify phase, not a separate command the user must remember.
|
|
40
45
|
- New or unclear requirement: use superflow-clarify.
|
|
41
46
|
- Confirmed requirement needing full docs: use openspec-propose, then
|
|
42
47
|
superflow-docs.
|
|
@@ -49,6 +54,29 @@ hotfix:
|
|
|
49
54
|
- Urgent small behavior repair: use superflow-hotfix, unless API, DB, cross-repo,
|
|
50
55
|
status, SQL, SDK, or real-entry gates are involved.
|
|
51
56
|
|
|
57
|
+
## Embedded Deep Clarification
|
|
58
|
+
|
|
59
|
+
When the router selects embedded deep clarification, follow these rules inside
|
|
60
|
+
`superflow-clarify`:
|
|
61
|
+
|
|
62
|
+
- Do not activate it for a clear, bounded hotfix or tweak whose intended behavior
|
|
63
|
+
and acceptance result are already evidenced. Do not turn routine work into an
|
|
64
|
+
interview.
|
|
65
|
+
- Establish facts from the requirement, repository, configuration, tests, logs,
|
|
66
|
+
or available tools before asking the user. Ask only for a decision the user or
|
|
67
|
+
owner must make.
|
|
68
|
+
- Ask exactly one decision question at a time. State the recommended option and
|
|
69
|
+
its important consequence, then wait for the answer before the next question.
|
|
70
|
+
- After each answer, update `.sdd/handoff/brainstorm-summary.md` with
|
|
71
|
+
`confirmed`, `candidate`, `pending`, and `rejected` entries. Do not rely on
|
|
72
|
+
chat memory for a resolved decision.
|
|
73
|
+
- Do not create or change proposal, spec, design, tasks, tests, or implementation
|
|
74
|
+
artifacts until all decisions that affect the current feature are confirmed or
|
|
75
|
+
explicitly marked blocked.
|
|
76
|
+
- Exit deep clarification once only repository-verifiable facts remain and the
|
|
77
|
+
user confirms the current feature understanding. Continue through the existing
|
|
78
|
+
clarify workflow without invoking an external skill dependency.
|
|
79
|
+
|
|
52
80
|
## Required Artifacts
|
|
53
81
|
|
|
54
82
|
For a full change, the docs phase must create or refresh:
|
|
@@ -120,6 +148,15 @@ The workflow must preserve these gates:
|
|
|
120
148
|
removal rules.
|
|
121
149
|
- Field/status reverse impact analysis for IDs, statuses, enums, payment,
|
|
122
150
|
online/offline, sync markers, external state, or persisted behavior.
|
|
151
|
+
- Money Precision Boundary for monetary calculation, settlement, allocation,
|
|
152
|
+
reconciliation, or financial display. Preserve calculation-state precision
|
|
153
|
+
until the confirmed final boundary, forbid early rounding, define scale and
|
|
154
|
+
rounding mode plus deterministic residual handling, and require half-cent or
|
|
155
|
+
multi-detail reconciliation evidence across design, prompts, review, tests,
|
|
156
|
+
and verify. When an additive identity has an authoritative total, calculate
|
|
157
|
+
only N-1 components independently and derive the final complement as
|
|
158
|
+
`authoritative total - sum(other components)`; never round every component
|
|
159
|
+
independently and rebuild the authoritative total.
|
|
123
160
|
- Architecture boundary and call-direction analysis for multi-repo, service,
|
|
124
161
|
SDK, MQ, scheduler, callback, gateway, adapter, device, or third-party flows.
|
|
125
162
|
- SQL risk review before implementation for DB changes.
|
|
@@ -169,3 +206,4 @@ Use the reference files in this skill directory as templates:
|
|
|
169
206
|
- references/dirty-worktree.md
|
|
170
207
|
- references/subagent-progress.md
|
|
171
208
|
- references/superpower-technical-design-template.md
|
|
209
|
+
- references/money-precision-algorithms.md
|
|
@@ -11,6 +11,14 @@ Use api.md as the canonical contract before implementation.
|
|
|
11
11
|
- Frontend mapping: screen field, API field, DTO/VO field, DB field, test case.
|
|
12
12
|
- External dependency contract: SDK version, topic/path, parameter source,
|
|
13
13
|
sample request/response, timeout and retry behavior.
|
|
14
|
+
- External Integration Configuration And Deployment Contract for third-party
|
|
15
|
+
platforms/tools, SDKs, MQ/Kafka, callbacks, payment providers, cloud
|
|
16
|
+
services, or other external integrations. Inventory endpoint,
|
|
17
|
+
app/tenant/project IDs, Topic/Tag/Consumer Group, namespace, webhook,
|
|
18
|
+
ACL/role, feature switches, timeout, and credential references for local,
|
|
19
|
+
test, and production; record injection/provisioning method, runtime owner,
|
|
20
|
+
provisioning owner/time, readiness evidence, rollback, secret handling, and
|
|
21
|
+
blockers.
|
|
14
22
|
- File contract when upload/download/export is involved: Content-Type,
|
|
15
23
|
Content-Disposition, filename rule, body format, frontend detection rule.
|
|
16
24
|
- Compatibility and migration notes.
|
|
@@ -20,3 +28,8 @@ Use api.md as the canonical contract before implementation.
|
|
|
20
28
|
|
|
21
29
|
Do not allow design, tasks, tests, or prompts to proceed if API changes are only
|
|
22
30
|
summarized as core fields, same as existing endpoint, or to be added later.
|
|
31
|
+
Environment-dependent external configuration and server-side resources must
|
|
32
|
+
not exist only as hard-coded annotations, constants, or business code. Test
|
|
33
|
+
auto-creation, existing historical resources, or successful local startup do
|
|
34
|
+
not prove production readiness; missing production provisioning evidence
|
|
35
|
+
blocks release.
|
|
@@ -24,6 +24,32 @@ review-checklist.md, sdd-quality-gate.md, test-report.md, and technical design.
|
|
|
24
24
|
- Do not change forbidden files or root aggregate docs from a worker batch.
|
|
25
25
|
- Use TDD: record RED failure before GREEN success.
|
|
26
26
|
- Do not mark mock-only or unit-only evidence as real integration.
|
|
27
|
+
- For third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment
|
|
28
|
+
providers, cloud services, or other external integrations, inherit
|
|
29
|
+
`External Integration Configuration And Deployment Contract`. Cover
|
|
30
|
+
local/test/production sources and provisioning, injection/creation,
|
|
31
|
+
runtime/provisioning owners and timing, readiness evidence, rollback, secret
|
|
32
|
+
handling, and blockers. Do not hard-code environment-dependent values or
|
|
33
|
+
infer production readiness from test auto-creation.
|
|
34
|
+
- For concurrent requests, batch issue/activation/renewal, duplicate callbacks
|
|
35
|
+
or consumption, and repeated external delivery, inherit `Concurrency And
|
|
36
|
+
Idempotency Ownership`. Define a stable business idempotency key,
|
|
37
|
+
application-layer atomic claim owner, short transaction boundary,
|
|
38
|
+
PENDING/SUCCESS/FAILED state machine, retry reuse of the original business
|
|
39
|
+
code, external-call boundary, and uncertain-result reconciliation. Release
|
|
40
|
+
database locks before external calls. A unique index is not the default and
|
|
41
|
+
may only be an optional fallback with explicit natural uniqueness,
|
|
42
|
+
historical cleanup, NULL/soft-delete behavior, and conflict handling.
|
|
43
|
+
- For monetary changes, inherit `Money Precision Boundary`, retain
|
|
44
|
+
calculation-state precision until the confirmed settlement/display boundary,
|
|
45
|
+
record scale and rounding mode, forbid early rounding before slicing or
|
|
46
|
+
allocation, and define deterministic residual handling. For additive
|
|
47
|
+
identities, calculate only N-1 components independently and derive the final
|
|
48
|
+
complement as `authoritative total - sum(other components)`; do not calculate
|
|
49
|
+
and round every component independently.
|
|
50
|
+
- Inherit `money-precision-algorithms.md`: exact decimal construction, currency
|
|
51
|
+
and provider minor units, rounding policy source, deterministic residual
|
|
52
|
+
tie-breaker, signed-value tests, and conditional FX conversion metadata.
|
|
27
53
|
|
|
28
54
|
## Implementation Steps
|
|
29
55
|
|
|
@@ -44,5 +70,7 @@ log check, and hook commands.
|
|
|
44
70
|
- Real-entry evidence
|
|
45
71
|
- DB/log evidence
|
|
46
72
|
- Hook evidence
|
|
73
|
+
- Money precision evidence: half-cent/residual/multi-detail cases and
|
|
74
|
+
reconciliation of original, discount, actual, and allocated totals
|
|
47
75
|
- Deviations
|
|
48
76
|
- Blockers
|
|
@@ -23,6 +23,35 @@ Superpowers technical design is canonical for source-level HOW and execution.
|
|
|
23
23
|
- Field semantic contract checked.
|
|
24
24
|
- Write-loop checked.
|
|
25
25
|
- No-fallback boundary confirmed.
|
|
26
|
+
- External Integration Configuration And Deployment Contract copied from the
|
|
27
|
+
API, quality gate, and technical design for third-party platforms/tools,
|
|
28
|
+
SDKs, MQ/Kafka, callbacks, payment providers, cloud services, or other
|
|
29
|
+
external integrations. Cover local/test/production sources and provisioning,
|
|
30
|
+
injection/creation, runtime/provisioning owners and timing, readiness
|
|
31
|
+
evidence, rollback, secret handling, and blockers. Do not hard-code
|
|
32
|
+
environment-dependent external values or treat test auto-creation as
|
|
33
|
+
production readiness evidence.
|
|
34
|
+
- Concurrency And Idempotency Ownership copied from the technical design for
|
|
35
|
+
concurrent requests, batch issue/activation/renewal, duplicate callbacks or
|
|
36
|
+
consumption, and repeated external delivery. Define a stable business
|
|
37
|
+
idempotency key, application-layer atomic claim owner, short transaction
|
|
38
|
+
boundary, PENDING/SUCCESS/FAILED state machine, retry reuse of the original
|
|
39
|
+
business code, external-call boundary, and uncertain-result reconciliation.
|
|
40
|
+
Release database locks before external calls. A unique index is not the
|
|
41
|
+
default; it is only an optional fallback with explicit natural uniqueness,
|
|
42
|
+
historical cleanup, NULL/soft-delete behavior, and conflict handling.
|
|
43
|
+
- Money Precision Boundary copied from the technical design when monetary
|
|
44
|
+
behavior changes. Keep calculation-state precision until the confirmed
|
|
45
|
+
settlement/display boundary, record scale and rounding mode, forbid early
|
|
46
|
+
rounding, and define deterministic residual allocation. For additive
|
|
47
|
+
identities, name the authoritative total, calculate only N-1 components
|
|
48
|
+
independently, and derive the complement as `authoritative total - sum(other
|
|
49
|
+
components)`. Do not calculate and round every component independently.
|
|
50
|
+
- Read `money-precision-algorithms.md`; inherit exact decimal construction,
|
|
51
|
+
currency and provider minor units, rounding level/mode/policy source,
|
|
52
|
+
residual strategy and stable tie-breaker, pre/post-round audit, and
|
|
53
|
+
positive/zero/negative tests. FX changes also inherit base/quote metadata,
|
|
54
|
+
rate source/time, canonical path, and target settlement rounding.
|
|
26
55
|
- RED test executed.
|
|
27
56
|
- Allowed and forbidden files confirmed.
|
|
28
57
|
- Blockers listed.
|
|
@@ -32,3 +61,7 @@ Superpowers technical design is canonical for source-level HOW and execution.
|
|
|
32
61
|
Do not claim completion until build/test, real-entry execution, DB/log evidence,
|
|
33
62
|
test-report update, and SuperBridge Flow hook scripts pass or are marked blocked
|
|
34
63
|
with concrete reasons.
|
|
64
|
+
|
|
65
|
+
For monetary changes, completion also requires half-cent, residual, or
|
|
66
|
+
multi-detail allocation tests and reconciliation evidence proving that original,
|
|
67
|
+
discount, actual, and allocated totals satisfy the contract identities.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Money Precision Algorithm Baseline
|
|
2
|
+
|
|
3
|
+
Money correctness is a contract across representation, currency units,
|
|
4
|
+
calculation, rounding, allocation, FX, persistence, and audit. Apply this
|
|
5
|
+
baseline to monetary design, implementation prompts, review, and verification.
|
|
6
|
+
An evidenced legal, tax, settlement, or provider contract takes precedence.
|
|
7
|
+
|
|
8
|
+
## Exact representation and units
|
|
9
|
+
|
|
10
|
+
- Use an exact decimal type such as Java `BigDecimal`, JSR 354
|
|
11
|
+
`MonetaryAmount`, or integer minor units coupled with an explicit currency.
|
|
12
|
+
Never represent or calculate money with binary `float` or `double`.
|
|
13
|
+
- Construct decimals from strings, exact integers, or exact database values,
|
|
14
|
+
never from a `double`.
|
|
15
|
+
- Every amount contract declares currency, unit, and scale. Never assume two
|
|
16
|
+
decimal places. Distinguish ISO 4217 minor units, internal calculation scale,
|
|
17
|
+
settlement scale, and provider-specific minor units.
|
|
18
|
+
- Convert to integer minor units only at an adapter boundary, with provider
|
|
19
|
+
rule, range, and overflow checks.
|
|
20
|
+
- Persist money as `DECIMAL` or `NUMERIC`. Code, DDL, mapper, and API
|
|
21
|
+
precision/scale must agree. Implicit database conversion is not a business
|
|
22
|
+
rounding policy.
|
|
23
|
+
|
|
24
|
+
## Rounding policy matrix
|
|
25
|
+
|
|
26
|
+
Every rounding point declares its business level, input precision, output
|
|
27
|
+
scale, rounding mode, currency or cash increment, and policy source. Do not
|
|
28
|
+
apply global `HALF_UP`, or mix line-level and aggregate-level rounding inside
|
|
29
|
+
one identity without an explicit reconciliation rule.
|
|
30
|
+
|
|
31
|
+
- Division declares precision and rounding mode. Use `UNNECESSARY` as an
|
|
32
|
+
assertion where an exact result is required.
|
|
33
|
+
- Retain rate, quantity, product, ratio, and FX precision until a contracted
|
|
34
|
+
settlement boundary.
|
|
35
|
+
- Negative values change the meaning of modes such as `CEILING` and `FLOOR`.
|
|
36
|
+
Test refunds and reversals explicitly instead of inferring from positives.
|
|
37
|
+
- Freeze either line-level or invoice-level tax rounding as the authoritative
|
|
38
|
+
path. Route any permitted alternative through an explicit adjustment rule.
|
|
39
|
+
|
|
40
|
+
## Authoritative totals and complement derivation
|
|
41
|
+
|
|
42
|
+
For `total = component 1 + ... + component N`, identify the authoritative
|
|
43
|
+
total, calculate only N-1 components independently, and derive the final
|
|
44
|
+
component as `authoritative total - sum(other components)`. Never calculate and
|
|
45
|
+
round all components independently and then rebuild the authoritative total.
|
|
46
|
+
|
|
47
|
+
## Allocation and residual units
|
|
48
|
+
|
|
49
|
+
Calculate high-precision ideal shares, then quantize at the settlement unit:
|
|
50
|
+
|
|
51
|
+
1. Express the authoritative target in integer settlement units.
|
|
52
|
+
2. Calculate ideal shares and base allocations.
|
|
53
|
+
3. Compute `residual units = target units - sum(base allocation units)`.
|
|
54
|
+
4. Assign one unit at a time until the residual reaches zero.
|
|
55
|
+
5. Use a declared strategy and stable tie-breaker such as a business key.
|
|
56
|
+
|
|
57
|
+
Prefer the largest-remainder method for neutral proportional allocation. Apply
|
|
58
|
+
the same absolute ordering symmetrically to refunds and negative totals.
|
|
59
|
+
Largest-value or last-row policies are allowed only when the contract requires
|
|
60
|
+
them. Never depend on database natural order. Prove conservation, stable order,
|
|
61
|
+
and idempotence.
|
|
62
|
+
|
|
63
|
+
## FX conversion
|
|
64
|
+
|
|
65
|
+
- Treat an FX rate as directional data with base/quote currencies, source,
|
|
66
|
+
timestamp, validity, and precision.
|
|
67
|
+
- Never truncate or round the rate early. Do not synthesize an inverse when a
|
|
68
|
+
canonical directional rate exists.
|
|
69
|
+
- Freeze one conversion path. For triangulation, use the contracted reference
|
|
70
|
+
currency and operation order, then round only at the target settlement unit.
|
|
71
|
+
- Round-trip conversion is a tolerance check, not an exact identity.
|
|
72
|
+
|
|
73
|
+
## Audit and verification
|
|
74
|
+
|
|
75
|
+
Record raw inputs, formula/version, currency/unit, pre-round value, policy,
|
|
76
|
+
post-round value, residual, and residual recipient. Record FX metadata when
|
|
77
|
+
applicable. Test positive, zero, negative/refund, half-unit, non-terminating
|
|
78
|
+
division, multi-detail, tied remainders, overflow, and repeated execution.
|
|
79
|
+
|
|
80
|
+
Required invariants: authoritative total equals component sum; allocations
|
|
81
|
+
equal the settlement target; identical inputs, policy version, and stable order
|
|
82
|
+
produce identical outputs; persistence, API, and provider conversions do not
|
|
83
|
+
silently change money.
|
|
84
|
+
|
|
85
|
+
## Primary references
|
|
86
|
+
|
|
87
|
+
- ISO 4217: <https://www.iso.org/iso-4217-currency-codes.html>
|
|
88
|
+
- JSR 354: <https://www.jcp.org/en/jsr/detail?id=354>
|
|
89
|
+
- Java `BigDecimal`: <https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/math/BigDecimal.html>
|
|
90
|
+
- MySQL `DECIMAL`: <https://dev.mysql.com/doc/refman/en/fixed-point-types.html>
|
|
91
|
+
- PostgreSQL `numeric`: <https://www.postgresql.org/docs/15/datatype-numeric.html>
|
|
92
|
+
- Stripe minor units: <https://docs.stripe.com/api/payment_intents/object>
|
|
93
|
+
- Adyen minor units: <https://docs.adyen.com/development-resources/currency-codes/>
|
|
94
|
+
- EU conversion rules: <https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX%3A31997R1103>
|
|
95
|
+
- HMRC VAT rounding: <https://www.gov.uk/hmrc-internal-manuals/vat-trader-records/vatrec12030>
|
|
96
|
+
- SAP allocation residuals: <https://help.sap.com/docs/PRODUCT_ID/56471df1959f4cfd9e3bf7a6d2d5be42/56a2dfe71e8b2ea1e10000000a42189c.html>
|
|
@@ -16,6 +16,32 @@
|
|
|
16
16
|
- Field/status reverse impact matrix exists when risky fields or states change.
|
|
17
17
|
- Architecture boundary and call-direction matrix exists for cross-service or
|
|
18
18
|
external flows.
|
|
19
|
+
- External Integration Configuration And Deployment Contract exists for
|
|
20
|
+
third-party platforms/tools, SDKs, MQ/Kafka, callbacks, payment providers,
|
|
21
|
+
cloud services, or other external integrations. It inventories environment
|
|
22
|
+
sources and provisioning for endpoints, app/tenant/project IDs,
|
|
23
|
+
Topic/Tag/Consumer Group, namespace, webhook, ACL/role, switches, timeouts,
|
|
24
|
+
and credential references; names runtime/provisioning owners, timing,
|
|
25
|
+
readiness evidence, rollback, secret handling, and blockers; and forbids
|
|
26
|
+
environment-dependent hard-coded values. Test auto-creation, existing test
|
|
27
|
+
resources, or local startup do not prove production readiness.
|
|
28
|
+
- Concurrency And Idempotency Ownership exists for concurrent requests, batch
|
|
29
|
+
issue/activation/renewal, duplicate callbacks/consumption, or repeated
|
|
30
|
+
external delivery. It defines the business idempotency key,
|
|
31
|
+
application-layer atomic claim owner, short transaction boundary,
|
|
32
|
+
PENDING/SUCCESS/FAILED state machine, retry code reuse, external-call
|
|
33
|
+
boundary, and uncertain-result reconciliation. A unique index is not the
|
|
34
|
+
default; it is only an optional fallback with explicit natural uniqueness,
|
|
35
|
+
historical cleanup, NULL/soft-delete behavior, and conflict handling.
|
|
36
|
+
- Money precision boundary exists when amount, fee, discount, deduction,
|
|
37
|
+
refund, sharing, payment, invoice, balance, electricity fee, service fee,
|
|
38
|
+
package settlement, proration, allocation, reconciliation, or financial
|
|
39
|
+
display changes. It must separate calculation state from settlement/display
|
|
40
|
+
state, forbid early rounding, and include half-cent, residual, or
|
|
41
|
+
multi-detail allocation evidence. For additive identities, it must name the
|
|
42
|
+
authoritative total and derive the final complement as `authoritative total -
|
|
43
|
+
sum(other components)` instead of calculating and rounding every component
|
|
44
|
+
independently.
|
|
19
45
|
- SQL risk review exists for DB changes.
|
|
20
46
|
- No fallback or guesswork is allowed without explicit owner approval.
|
|
21
47
|
|
|
@@ -5,6 +5,21 @@
|
|
|
5
5
|
- Is handoff_hash current and repeated in prompts/report?
|
|
6
6
|
- Did Superpowers technical design cover source-level HOW?
|
|
7
7
|
- Were field/status and architecture-boundary risks checked?
|
|
8
|
+
- For monetary changes, were calculation and settlement states separated, were
|
|
9
|
+
scale and rounding mode explicit, and was early rounding rejected?
|
|
10
|
+
- Do half-cent, residual, and multi-detail tests prove deterministic allocation
|
|
11
|
+
and reconciliation of original, discount, actual/refund, and allocated totals?
|
|
12
|
+
- For additive identities, is the authoritative total explicit, with only N-1
|
|
13
|
+
components calculated independently and the final complement derived as
|
|
14
|
+
`authoritative total - sum(other components)`?
|
|
15
|
+
- Reject designs that calculate and round every component independently before
|
|
16
|
+
rebuilding an authoritative total.
|
|
17
|
+
- Are exact decimal construction, currency and provider minor units, rounding
|
|
18
|
+
level/policy source, and persistence precision explicit?
|
|
19
|
+
- Does allocation use a declared residual strategy and stable tie-breaker, with
|
|
20
|
+
positive, zero, negative/refund, tied-remainder, and idempotence evidence?
|
|
21
|
+
- For FX, are base/quote, source/time, canonical path, and target settlement
|
|
22
|
+
rounding explicit, without early rate rounding or synthesized inverses?
|
|
8
23
|
- Are SQL changes reviewed and tied to total version SQL when needed?
|
|
9
24
|
- Are RED/GREEN evidence and real-entry evidence present?
|
|
10
25
|
- Are mock-only results clearly labeled?
|