feat: add predevelopment design validator

This commit is contained in:
2026-08-10 23:43:13 +08:00
parent 8b26e0a762
commit b2d8f7bd68
2 changed files with 1574 additions and 0 deletions
+305
View File
@@ -0,0 +1,305 @@
# Pre-development Design Validation Contract
> Contract revision: `abg-design-validation-v1`
> Frozen input: `.agent-taskgraph/spec.md` revision `design-spec-r3`
> Executable: `tools/validate_predevelopment_design.py`
> Scope: merged Markdown design authorities only; no runtime or product authority
## 1. Purpose And Boundary
This contract defines the deterministic pre-development checks applied after
the product, content, UX, art, and audio workstreams are integrated. It makes
mechanical omissions visible before independent review. It does not select a
combat value, profession mechanic, content split, screen composition, art
style, mix priority, or other product-facing rule.
The executable answers these bounded questions:
1. Are the frozen content-envelope counts represented by unique stable IDs?
2. Do registered ID references resolve?
3. Are integration placeholders still unresolved?
4. Do authoritative documents still prescribe retired redesign concepts?
5. Is minimum page, art, and audio traceability present?
Passing this validator is necessary but not sufficient for design approval.
It cannot establish originality, decision quality, balance, readability,
production feasibility, fun, or owner acceptance. Those remain human review
gates.
## 2. Authoritative Input Set
The validator reads UTF-8 Markdown recursively from:
- `docs/product/`
- `docs/content/`
- `docs/presentation/`
The following authorities must exist:
- `docs/product/GAME_PRODUCT_CONTRACT.md`
- `docs/product/SYSTEMS_AND_BATTLE.md`
- `docs/product/ECONOMY_AND_BALANCE.md`
- `docs/product/SAVE_AND_FAILURE_CONTRACT.md`
- `docs/presentation/SCREEN_AND_STATE_MAP.md`
- `docs/presentation/UI_AND_VISUAL_SYSTEM.md`
- `docs/presentation/ART_ASSET_AND_ANIMATION_CATALOG.md`
- `docs/presentation/AUDIO_MUSIC_AND_VOICE_CATALOG.md`
`docs/content/CHARACTER_BIBLE.md` is a retired fixed-character authority and
must not remain in the merged design package. Generated recruit rules and
fixed reusable content catalogs replace it.
Reference research, reviews, prototypes, taskgraph files, and this validation
contract are deliberately outside the retired-concept scan. They may describe
old behavior as evidence or rejection without making it product authority.
## 3. Stable-ID Grammar
### 3.1 Definition Rows
An exact uppercase, hyphenated ID in the first cell of a Markdown table row is
a definition when it contains a digit or uses one of the accepted presentation
families in Section 6. The ID must be enclosed in backticks. Bare category
labels such as `EN-O` are not definitions. Example:
```markdown
| ID | Name | Mechanical decision |
|---|---|---|
| `TR-001` | Deliberate | Benefit, cost, and affected choice |
```
This rule is intentionally syntax-based:
- A repeated definition in another table is a duplicate, even if its prose is
identical.
- A table that discusses an existing ID must place that reference outside the
first cell.
- Ranges are references or coverage declarations. A range in one table row
does not manufacture the individual content rows required by the envelope.
- Every required content row needs at least three nonempty structural cells.
More specific schemas remain owned by the product and content authorities.
- `TBD`, `TBC`, `TODO`, `FIXME`, or a named binding placeholder is not content.
### 3.2 Exact Registries
The following sets are exact and contiguous:
| Registry | Stable IDs | Exact count |
|---|---|---:|
| Base professions | `PR-B01..PR-B12` | 12 |
| Regular advanced professions | `PR-A01..PR-A24` | 24 |
| Hidden hybrid professions | `PR-H01..PR-H06` | 6 |
| Mechanical recruit traits | `TR-001..TR-036` | 36 |
| Equipment | `IT-001..IT-320` or `EQ-001..EQ-320` | 320 |
| Artifacts | `AR-001..AR-060` | 60 |
| Bosses | `EN-B001..EN-B016` | 16 |
| Regions | `REG-01..REG-08` | 8 |
Equipment may retain the repository's existing `IT-###` namespace or migrate
as one integrated package to `EQ-###`. Mixing those namespaces is an error.
This compatibility choice changes no equipment behavior.
Ordinary and elite enemies use `EN-O###` and `EN-E###`. Their combined unique
count must be exactly 100. The frozen spec does not authorize this validator to
choose the ordinary/elite split, so both categories must be nonempty and each
category must be gap-free from `001`, but their individual maxima are left to
the content authority.
### 3.3 References And Ranges
Registered numeric ID references are checked across every authoritative input.
The range forms below are expanded before validation:
```text
PR-B01..PR-B12
EN-O001..060
REG-01..08
```
Both endpoints are inclusive. Prefixes must agree, the end must not precede
the start, and a range may expand to at most 1,001 identifiers. A reference to
a known numeric namespace fails when no definition exists. Diagnostics name
the unresolved IDs instead of guessing the intended target.
## 4. Integration Bindings
UX and presentation work may temporarily use named bindings while product
values are authored in parallel. None may remain in the integrated candidate.
The validator rejects:
- `TBD`, `TBC`, `TODO`, and `FIXME`
- double-brace placeholders such as `{{BINDING:deployment_capacity}}`
- named forms beginning with `BINDING:`, `BINDING(`, or `BINDING[`
`BINDING_UNRESOLVED` means the source authority is unknown or has not yet been
integrated. It does not mean the validator supplies a fallback. Integration
must replace the placeholder with an authoritative value or reference and run
the validator again.
## 5. Retired Concepts
The validator rejects positive, authoritative use of the following concepts:
- fixed cast, fixed named protagonists, or an authored set of 30 heroes
- relationship scenes/systems, affinity systems, romance, or personal arcs
- a fixed six-unit/person/member deployment rule
- a three-lane or three-band grid
- capitalized battle concepts `Directive`, `Anchor`, and `Cache`
- manual skill activation or in-battle intervention commands
A nearby explicit rejection such as `removed`, `retired`, `must not`, or `no
longer` makes a match documentary rather than authoritative. This exemption is
limited to the surrounding line. Negative wording must not be used to hide an
unrelated positive prescription on the same line.
Lowercase ordinary-language uses are not automatically retired terms. The
capitalized `Anchor` and `Cache` checks target the prior named battle/economy
concepts, while the phrase checks target the obsolete control model.
## 6. Presentation Coverage
These are structural coverage checks. They enforce traceability, not the
quality of a screen composition, drawing, animation, sound, or mix.
### 6.1 Pages And States
`SCREEN_AND_STATE_MAP.md` must define stable page rows whose IDs end in three
digits. Prefixes may follow the existing screen families or use another
consistent uppercase namespace. Each row must contain at least:
1. stable ID
2. page/state name
3. landscape composition or focal structure
4. primary action
5. states and exit behavior
At least one page row must cover each frozen workflow:
- shop/offers
- recruit/hire
- equipment/loadout
- party-line formation/reorder
- automatic battle
- result/reward/diagnosis
- failure/death/recovery
- save/cloud continuation
- settings/controls
- accessibility
- localization/language
- endgame/postgame/mastery
The screen authority as a whole must explicitly cover landscape composition,
empty state, error state, confirmation behavior, input, localization, and
accessibility. The validator checks that the contract is present; independent
review checks that the coverage is correctly applied to every relevant page.
### 6.2 Art, Animation, And VFX
`ART_ASSET_AND_ANIMATION_CATALOG.md` must explicitly reference every defined:
- base, advanced, and hidden profession ID
- region ID
- ordinary/elite enemy ID
- boss ID
Inclusive ranges are valid coverage references. The same authority must also
name modular generated recruits, equipment readability, an animation matrix,
a VFX/visual-effects language, and landscape composition. Requiring IDs makes
the promised 42 profession kits, eight region families, and 116 enemy
identities mechanically reconcilable without prescribing their visual design.
Named production definitions in this authority may use the `ART-*`, `AST-*`,
`VFX-*`, or `ANIM-*` families.
### 6.3 Music, Ambience, SFX, And Voice
`AUDIO_MUSIC_AND_VOICE_CATALOG.md` must contain at least one stable definition
in each production family:
- music: `MUS-*` or `MUSIC-*`
- ambience: `AMB-*` or `AMBIENCE-*`
- sound/UI events: `SFX-*` or `UI-*`
- voice: `VO-*`, `VOC-*`, or `VOICE-*`
All eight region IDs must be explicitly referenced. The catalog must also
cover shop offers, recruitment, equipment, party reorder, battle, pause,
speed, inspection, retreat, permanent casualty, dismissal, reward, failure,
audio accessibility, and bounded generated-recruit voice scope. Exact cue
counts and mix values remain owned by the audio authority.
## 7. Diagnostics And Exit Contract
Run from the repository root:
```sh
python3 tools/validate_predevelopment_design.py
```
Audit another checkout or integrated candidate:
```sh
python3 tools/validate_predevelopment_design.py /path/to/repository
```
Machine-readable output:
```sh
python3 tools/validate_predevelopment_design.py --json
```
Diagnostics are sorted by path, line, column, code, and message. Text output is
one error per line followed by deterministic JSON counts and one terminal:
```text
ABG_PREDEVELOPMENT_DESIGN_OK errors=0
ABG_PREDEVELOPMENT_DESIGN_FAILED errors=<n>
```
Exit status is `0` only when no diagnostic remains. Audit failures return `1`.
Argument or interpreter errors use the normal nonzero Python/argparse status.
No third-party Python package is imported.
The main diagnostic families are:
| Family | Meaning |
|---|---|
| `AUTHORITY_*` | required authority missing or unreadable |
| `REGISTRY_*`, `ENEMY_*`, `EQUIPMENT_*` | count, exact-set, sequence, or row failure |
| `ID_DUPLICATE` | a stable ID has more than one defining row |
| `REFERENCE_*` | range invalid or known ID unresolved |
| `BINDING_UNRESOLVED` | integration still depends on an unknown value |
| `RETIRED_*` | obsolete product authority remains positive |
| `PAGE_*`, `ART_*`, `AUDIO_*` | required presentation traceability is absent |
The current pre-integration branch is expected to fail. Its retired fixed-cast
package is evidence that the validator detects the redesign boundary, not a
reason to weaken any check.
## 8. Self-test And Review Evidence
The executable contains a generated valid package and isolated mutations for:
- exact-count failure
- duplicate ID
- broken reference
- unresolved binding
- retired battle concept
- missing page capability
- missing art ID coverage
- missing audio event coverage
Run:
```sh
python3 -m py_compile tools/validate_predevelopment_design.py
python3 tools/validate_predevelopment_design.py --self-test
```
The self-test terminal is:
```text
ABG_PREDEVELOPMENT_DESIGN_SELF_TEST_OK cases=9
```
Integration evidence must retain the command, revision, exit status, and full
validator output. A clean result advances the package to independent review;
it does not bypass that review or the owner gate.
File diff suppressed because it is too large Load Diff