@hobin/developer 0.1.1 → 0.1.2
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 +31 -11
- package/SOURCES.md +104 -0
- package/extensions/developer.ts +67 -24
- package/extensions/references/behavior-preserving-structural-change.md +145 -0
- package/extensions/skills.ts +1 -16
- package/extensions/state.ts +9 -1
- package/package.json +2 -1
- package/skills/abstraction-review/references/field-card.md +7 -0
- package/skills/abstraction-review/references/recipe-cards.md +67 -0
- package/skills/abstraction-review/references/repair-table.md +5 -0
- package/skills/model/SKILL.md +6 -1
- package/skills/model/references/problem-modeling.md +294 -235
- package/skills/model/references/worked-models-and-specialized-techniques.md +218 -0
- package/skills/naming-judgment/SKILL.md +5 -3
- package/skills/naming-judgment/references/domain-naming.md +202 -0
- package/skills/schedule/SKILL.md +1 -1
- package/skills/schedule/references/structural-change-timing.md +80 -13
- package/skills/signal/SKILL.md +2 -2
- package/skills/signal/references/structural-movement.md +202 -0
- package/skills/sketch/SKILL.md +35 -8
- package/skills/sketch/references/abstraction-barriers-and-closure.md +160 -0
- package/skills/sketch/references/abstraction-composition-and-state.md +184 -0
- package/skills/sketch/references/composition-generative-recursion-and-accumulators.md +196 -0
- package/skills/sketch/references/data-driven-design.md +177 -0
- package/skills/sketch/references/data-shape-template-catalog.md +241 -0
- package/skills/sketch/references/generic-operations-and-languages.md +134 -0
- package/skills/sketch/references/processes-state-and-time.md +171 -0
- package/skills/sketch/references/responsibility-and-variation.md +245 -0
- package/skills/verify/references/verifier-selection-and-pass-but-wrong.md +61 -3
- package/skills/naming-judgment/references/elements-of-clojure-naming.md +0 -74
- package/skills/signal/references/flocking-and-structural-movement.md +0 -157
- package/skills/sketch/references/design-recipe-and-abstraction-barriers.md +0 -169
|
@@ -1,274 +1,333 @@
|
|
|
1
1
|
# Problem Modeling Reference
|
|
2
2
|
|
|
3
|
-
Use this reference when
|
|
3
|
+
Use this reference when a requirement, bug, refactor, API change, or AI task
|
|
4
|
+
contains enough conditional complexity that prose and isolated examples no longer
|
|
5
|
+
show the full acceptable solution space.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
task ownership.
|
|
7
|
+
## Central Idea
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
Model only the condition space under judgment:
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
```text
|
|
12
|
+
domain and facts
|
|
13
|
+
-> predicates and rules
|
|
14
|
+
-> assumptions and forbidden cases
|
|
15
|
+
-> transitions or objectives when relevant
|
|
16
|
+
-> guarantee owners
|
|
17
|
+
-> counterexamples and verification targets
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The model is a deliberately simplified view of the world. Its value is not
|
|
21
|
+
formality by itself; it is the ability to expose ambiguity, missing cases,
|
|
22
|
+
composition failures, and unsafe replacements before code hides them.
|
|
23
|
+
|
|
24
|
+
## Lower Prose Into Logic
|
|
25
|
+
|
|
26
|
+
Translate requirement language before choosing a representation:
|
|
27
|
+
|
|
28
|
+
1. Nouns identify domains and facts: users, documents, orders, states, events.
|
|
29
|
+
2. Judgments become predicates: `canEdit`, `isValidTransition`, `isReady`.
|
|
30
|
+
3. Quantity words become scoped quantifiers: all, some, none, exactly one.
|
|
31
|
+
4. Conditional words become implications: if, only if, unless, whenever.
|
|
32
|
+
5. `P => Q` becomes the counterexample to exclude: `P && !Q`.
|
|
33
|
+
6. Finite combinations become decision spaces.
|
|
34
|
+
7. Time words become actions, transitions, safety, or progress questions.
|
|
35
|
+
8. Preferences become objectives only after hard constraints are separated.
|
|
36
|
+
9. Reasonable stakeholder choices remain open policy questions.
|
|
37
|
+
|
|
38
|
+
Words such as *valid*, *ready*, *allowed*, *all*, *any*, *never*, *always*,
|
|
39
|
+
*after*, *retry*, and *timeout* are often where the real requirement lives.
|
|
22
40
|
|
|
23
|
-
##
|
|
41
|
+
## Logic Is Not Runtime Semantics
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
A logically valid rewrite may be an invalid program rewrite. Before carrying an
|
|
44
|
+
equivalence into code, check:
|
|
45
|
+
|
|
46
|
+
- truthiness and coercion rules;
|
|
47
|
+
- short-circuiting and evaluation order;
|
|
48
|
+
- exceptions, side effects, mutation, and non-termination;
|
|
49
|
+
- equality, identity, and collection semantics;
|
|
50
|
+
- floating-point, overflow, null, and missing-value behavior;
|
|
51
|
+
- whether a set-like mathematical model is actually represented by an ordered or
|
|
52
|
+
duplicate-preserving collection.
|
|
53
|
+
|
|
54
|
+
Use the logical form to state the intended relationship, then separately prove
|
|
55
|
+
that the implementation language preserves it.
|
|
56
|
+
|
|
57
|
+
## The Ability-Guarantee Tradeoff
|
|
58
|
+
|
|
59
|
+
Every representation or tool gains guarantees by excluding abilities. A set
|
|
60
|
+
excludes duplicates and order; a read-only capability excludes writes; a narrow
|
|
61
|
+
type excludes values; a decidable model excludes expressions its checker cannot
|
|
62
|
+
handle.
|
|
63
|
+
|
|
64
|
+
For every proposed modeling or implementation constraint, state both:
|
|
26
65
|
|
|
27
66
|
```text
|
|
28
|
-
|
|
29
|
-
|
|
67
|
+
Guarantee gained: what becomes impossible or checkable
|
|
68
|
+
Ability lost: what valid expression, input, behavior, or implementation is excluded
|
|
30
69
|
```
|
|
31
70
|
|
|
32
|
-
Do not
|
|
33
|
-
|
|
71
|
+
Do not call a narrower representation better until the lost ability is known not
|
|
72
|
+
to be a product requirement.
|
|
34
73
|
|
|
35
|
-
##
|
|
74
|
+
## Choose The Model From The Uncertainty
|
|
36
75
|
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
| Problem shape | Start with | What it exposes |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| vague boolean or conditional rule | predicates, quantified sets, implication counterexamples | exact domain, scope, and failure shape |
|
|
79
|
+
| function or API composition | contracts | caller obligations and callee guarantees |
|
|
80
|
+
| refactor, upgrade, schema, or API replacement | replacement model | which old guarantees and accepted inputs must survive |
|
|
81
|
+
| finite role/status/flag combinations | decision table | missing, overlapping, or contradictory cases |
|
|
82
|
+
| entities and relationships | domain/relational model | possible instances, impossible combinations, and assumptions |
|
|
83
|
+
| state, retry, concurrency, lifecycle | transition/temporal model | valid histories, safety, progress, stale events |
|
|
84
|
+
| allocation, planning, configuration | constraints plus objective | valid solutions versus preferred solutions |
|
|
85
|
+
| hard satisfaction or counterexample search | solver encoding | satisfiability, counterexamples, or optimal solutions |
|
|
86
|
+
| stakeholder-dependent behavior | human decision surface | choices the model must not invent |
|
|
87
|
+
|
|
88
|
+
Use multiple views when the task genuinely mixes shapes. Do not model the whole
|
|
89
|
+
product merely because one rule is complicated.
|
|
90
|
+
|
|
91
|
+
For complete, runnable-shaped examples of boolean policy, relational data,
|
|
92
|
+
temporal behavior, proof boundaries, solvers, logic programming, and planning,
|
|
93
|
+
read [Worked Models And Specialized Techniques](worked-models-and-specialized-techniques.md).
|
|
94
|
+
The examples are selected by uncertainty; they are not a mandatory progression.
|
|
95
|
+
|
|
96
|
+
## Statements, Specifications, And Tests
|
|
97
|
+
|
|
98
|
+
A stronger statement implies more statements and excludes more implementations.
|
|
99
|
+
A total specification describes all required behavior; most practical tests check
|
|
100
|
+
partial specifications because complete behavior is too complex or because a
|
|
101
|
+
smaller property localizes failures better.
|
|
102
|
+
|
|
103
|
+
Combine evidence deliberately:
|
|
104
|
+
|
|
105
|
+
- examples make product cases concrete;
|
|
106
|
+
- domain properties express rules specific to the product;
|
|
107
|
+
- structural properties express reusable shapes such as valid output, idempotence,
|
|
108
|
+
monotonicity, membership, or preservation;
|
|
109
|
+
- metamorphic relations compare several executions when the exact output is hard
|
|
110
|
+
to know;
|
|
111
|
+
- generators define the valid input domain for property tests;
|
|
112
|
+
- counterexample shrinking turns a broad failure into a diagnostic case.
|
|
113
|
+
|
|
114
|
+
A strong passing property gives breadth of confidence. A weak failing property
|
|
115
|
+
may provide better localization. Prefer several meaningful partial specifications
|
|
116
|
+
over one opaque assertion that cannot explain what failed.
|
|
117
|
+
|
|
118
|
+
## Contracts And Composition
|
|
119
|
+
|
|
120
|
+
Model a callable as:
|
|
39
121
|
|
|
40
122
|
```text
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
4. Conditional words become implication: if, only if, unless, whenever.
|
|
45
|
-
5. Implications become counterexamples: P => Q means the failure shape is P && !Q.
|
|
46
|
-
6. Finite policy combinations become decision spaces.
|
|
47
|
-
7. Time words become transition or temporal questions.
|
|
48
|
-
8. Unspecified domain choices become open policy questions.
|
|
123
|
+
requires: facts callers must establish
|
|
124
|
+
ensures: facts correct execution guarantees
|
|
125
|
+
invariant: facts preserved through relevant internal steps
|
|
49
126
|
```
|
|
50
127
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
128
|
+
Contracts propagate through call graphs. If `A` calls `B`, A's established facts
|
|
129
|
+
must imply B's preconditions, and B's postconditions must be sufficient for A's
|
|
130
|
+
remaining work. This finds bugs where every individual function is locally
|
|
131
|
+
correct but their composition is not.
|
|
54
132
|
|
|
55
|
-
|
|
133
|
+
Choose a checking mechanism separately. Types are contracts over representable
|
|
134
|
+
values and are usually cheaper to check but less expressive. Runtime assertions,
|
|
135
|
+
validation, tests, properties, and proofs cover different parts of a semantic
|
|
136
|
+
contract. An unchecked contract can still aid reasoning, but it is not evidence.
|
|
56
137
|
|
|
57
|
-
|
|
138
|
+
## Safe Replacement
|
|
58
139
|
|
|
59
|
-
|
|
60
|
-
| --- | --- | --- |
|
|
61
|
-
| `predicate-logic` | hidden booleans, quantifiers, implication, rewrite/equivalence questions | predicates, domains, counterexamples, equivalence risks |
|
|
62
|
-
| `test-specification` | tests should express behavior, structural properties, or metamorphic relations | examples, properties, generators, counterexamples |
|
|
63
|
-
| `contract-property` | function/API behavior, caller/callee boundaries, valid inputs | preconditions, postconditions, invariants |
|
|
64
|
-
| `equation-invariant` | a compact formula, precedence rule, or conserved relationship is clearer than rows | formula, invariant, counterexample shape |
|
|
65
|
-
| `proof-invariant` | proof, loop correctness, or preservation across steps matters | loop invariant, proof obligation, termination condition |
|
|
66
|
-
| `data-relation` | data facts, queries, constraints, or representation replacement matter | relations, joins, violation queries, schema/model compatibility |
|
|
67
|
-
| `absence-default-semantics` | configurable, optional, nullable, defaulted, persisted, or externally supplied values may be missing | valid members, absence meanings, default owner, legacy shape, misplaced-default counterexample |
|
|
68
|
-
| `decision-space` | finite policy/case matrix, role/status/flag combinations | inputs, finite partitions, outputs, missing/conflicting cases |
|
|
69
|
-
| `domain-relation` | entities and relationships drive behavior | entities, relations, assumptions, properties |
|
|
70
|
-
| `transition-temporal` | state changes, async flows, retries, workers, lifecycle | states, actions, safety, liveness, stale events |
|
|
71
|
-
| `constraint-objective` | assignment, optimization, configuration, solver-like work | variables, constraints, objective, invalid representations |
|
|
72
|
-
| `logic-programming` | facts and rules should be queried directly or recursively | facts, rules, queries, possible worlds |
|
|
73
|
-
| `ai-delegation` | preparing a clear task for another agent or skill | facts, rules, forbidden cases, objective, verification |
|
|
74
|
-
|
|
75
|
-
## Problem Shape Router
|
|
76
|
-
|
|
77
|
-
Choose the first representation from the shape of uncertainty, not from tool
|
|
78
|
-
preference.
|
|
79
|
-
|
|
80
|
-
| Problem shape | Start with | Why |
|
|
81
|
-
| --- | --- | --- |
|
|
82
|
-
| A boolean name feels vague: valid, ready, allowed, safe, complete | `predicate-naming` | Forces the domain question behind the boolean to be explicit |
|
|
83
|
-
| The rule says all, any, none, at least one, exactly one, or at most one | `set-quantifier-model` | Separates the domain set from the required count |
|
|
84
|
-
| The rule is conditional: if, only if, unless, whenever | `implication-counterexample` | Turns a policy into the failure shape to exclude |
|
|
85
|
-
| A refactor, rewrite, schema change, or optimization must preserve meaning | `rewrite-equivalence-check` or `replacement-schema-model` | Separates logical equivalence from language/runtime semantics |
|
|
86
|
-
| A fact must remain true across calls, steps, data mutations, or loops | `equation-invariant`, `contract-model`, or `loop-invariant-proof` | Names the preserved guarantee before choosing a representation or change |
|
|
87
|
-
| Role/status/flag/action combinations are finite and reviewable | `decision-table` | Finds missing and conflicting cases |
|
|
88
|
-
| Facts and relationships drive correctness | `domain-model`, `relational-query`, or `data-constraint` | Makes possible instances and impossible fact combinations visible |
|
|
89
|
-
| Correctness depends on movement through time | `state-transition` or `temporal-model` | Distinguishes valid snapshots from valid behavior |
|
|
90
|
-
| The task is to find a satisfying value, allocation, plan, or counterexample | `constraint-objective`, `smt-counterexample`, or `logic-programming` | Models the conditions a solution must satisfy |
|
|
91
|
-
| The answer depends on stakeholder policy | `human-decision-surface` | Prevents the model from inventing product meaning |
|
|
92
|
-
|
|
93
|
-
## Modeling Tool Selection
|
|
94
|
-
|
|
95
|
-
Select tools after selecting lenses. A lens says what to look for; a tool says
|
|
96
|
-
how to represent the condition space. Use the full modeling range, not only
|
|
97
|
-
decision tables or solvers.
|
|
98
|
-
|
|
99
|
-
| Tool | Use when | Do not use when |
|
|
100
|
-
| --- | --- | --- |
|
|
101
|
-
| `predicate-naming` | important booleans hide product meaning | sequence, data relationships, or optimization are the main issue |
|
|
102
|
-
| `set-quantifier-model` | rules use all, any, none, at least one, exactly one | the domain cannot be stated |
|
|
103
|
-
| `implication-counterexample` | a rule is conditional: if P then Q | no useful `P && !Q` failure case exists |
|
|
104
|
-
| `rewrite-equivalence-check` | refactoring conditionals, predicates, sets, or quantifiers | language semantics, side effects, evaluation order, or runtime representation changes meaning |
|
|
105
|
-
| `example-test-spec` | concrete scenarios define required behavior | examples are arbitrary and miss the intended property |
|
|
106
|
-
| `structural-property-test` | behavior has a general property over many valid inputs | valid input generation or property definition is unclear |
|
|
107
|
-
| `metamorphic-relation` | exact output is hard to know but related runs should agree | no meaningful relation exists between transformed inputs |
|
|
108
|
-
| `contract-model` | the risk is at a function/API/component boundary | the main issue is stakeholder policy over many cases |
|
|
109
|
-
| `type-representation-model` | invalid states can be excluded or exposed by data shape | the language cannot express the semantic guarantee |
|
|
110
|
-
| `loop-invariant-proof` | correctness depends on every loop or proof step preserving a fact | tests provide enough evidence for the risk |
|
|
111
|
-
| `relational-query` | facts are best modeled as relations, joins, projections | behavior is mainly local branching |
|
|
112
|
-
| `data-constraint` | schema, uniqueness, existence, or update constraints matter | the rule is purely transient UI behavior |
|
|
113
|
-
| `replacement-schema-model` | changing schema/API/representation must preserve old meaning | no old abstract model must be recovered |
|
|
114
|
-
| `absence-default-model` | a value can be omitted, null, empty, defaulted, inherited, hydrated, or supplied by another boundary | the value is always required and has no legacy or external shape |
|
|
115
|
-
| `decision-table` | independent inputs can be partitioned into finite buckets and mapped to outputs/actions | inputs depend strongly on each other, side effects dominate, a loop/recursion is required, inputs are unbounded lists/complex types, or the table is too large |
|
|
116
|
-
| `equation-invariant` | a formula, precedence rule, or always-true relationship is clearer than enumerating rows | policy genuinely differs by many discrete buckets |
|
|
117
|
-
| `domain-model` | entities, relations, possible instances, and properties matter | the task is a local transform with no domain ambiguity |
|
|
118
|
-
| `state-transition` | a state can be valid but invalidly reached | current-state validity fully captures correctness |
|
|
119
|
-
| `temporal-model` | concurrency, retry, timeout, stale event, fairness, or liveness matters | finite deterministic examples cover the risk |
|
|
120
|
-
| `constraint-objective` | variables, hard constraints, and preferences must be separated | a bespoke algorithm is simple, fixed, and performance-critical |
|
|
121
|
-
| `smt-counterexample` | satisfaction, contract, arithmetic, string, bitvector, or data-structure edge cases need counterexample search | the model cannot be encoded accurately enough |
|
|
122
|
-
| `logic-programming` | facts, rules, recursive relations, or possible worlds are the program model | deterministic imperative control flow is simpler |
|
|
123
|
-
| `human-decision-surface` | reasonable stakeholders could choose different policies | the answer follows from existing rules or data |
|
|
124
|
-
| `ai-delegation-model` | another skill, tool, or agent needs a task contract | success criteria and verification cannot be stated |
|
|
125
|
-
|
|
126
|
-
For decision tables, check the four fit questions before selecting the tool:
|
|
140
|
+
To replace `old` with `new` for existing callers, require:
|
|
127
141
|
|
|
128
142
|
```text
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
3. Is a table clearer than prose, an equation, an invariant, or a state model?
|
|
132
|
-
4. Will the table stay small enough to review?
|
|
143
|
+
old.Pre => new.Pre
|
|
144
|
+
new.Post => old.Post
|
|
133
145
|
```
|
|
134
146
|
|
|
135
|
-
|
|
147
|
+
The replacement must accept at least what old accepted and guarantee at least
|
|
148
|
+
what old guaranteed. Apply this to functions, types, APIs, libraries, schemas,
|
|
149
|
+
and system specifications.
|
|
150
|
+
|
|
151
|
+
Observable behavior outside the declared contract may still be depended on in
|
|
152
|
+
real systems. Inspect actual callers, persisted data, tests, telemetry, and known
|
|
153
|
+
bugs before claiming compatibility. Logical replaceability is necessary evidence,
|
|
154
|
+
not a complete social or operational guarantee.
|
|
155
|
+
|
|
156
|
+
For representation changes, define an abstraction or refinement mapping from the
|
|
157
|
+
new representation back to the old model. A change is safe only if relevant new
|
|
158
|
+
states or behaviors map to valid old ones.
|
|
159
|
+
|
|
160
|
+
## Proof And Formal Verification Boundary
|
|
136
161
|
|
|
137
|
-
|
|
162
|
+
A proof establishes that an implementation conforms to a stated specification
|
|
163
|
+
under stated assumptions. It does not establish that the specification captures
|
|
164
|
+
everything the product needs or that environmental assumptions hold.
|
|
165
|
+
|
|
166
|
+
For proof-shaped work, write:
|
|
138
167
|
|
|
139
168
|
```text
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Output:
|
|
147
|
-
What the tool should make visible: predicate, property, counterexample,
|
|
148
|
-
table row, transition, query, constraint, objective, or human decision.
|
|
169
|
+
preconditions
|
|
170
|
+
postconditions
|
|
171
|
+
facts known after each step
|
|
172
|
+
loop/recursion invariant when control repeats
|
|
173
|
+
termination argument when total correctness matters
|
|
174
|
+
assumptions outside the model
|
|
149
175
|
```
|
|
150
176
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
language, and open policy questions.
|
|
156
|
-
- Separate meaning from implementation. Predicate names should say what is true,
|
|
157
|
-
not how it is computed.
|
|
158
|
-
- Separate predicate roles. A decision predicate can be true or false; an
|
|
159
|
-
assumption or precondition defines when a property is meaningful; a property
|
|
160
|
-
is a guarantee that must not be false in valid states.
|
|
161
|
-
- Separate assumptions from guarantees. Use assumptions for well-formedness,
|
|
162
|
-
preconditions, and product decisions that must be true before a property means
|
|
163
|
-
anything.
|
|
164
|
-
- Treat `P => Q` as a failure condition: `P && !Q`.
|
|
165
|
-
- For finite decisions, prefer explicit case coverage over prose, but only when
|
|
166
|
-
inputs form reviewable finite partitions.
|
|
167
|
-
- Prefer an equation or invariant over a decision table when a compact
|
|
168
|
-
relationship communicates the rule more clearly.
|
|
169
|
-
- For stateful behavior, distinguish current-state invariants from transition
|
|
170
|
-
rules over old and new state.
|
|
171
|
-
- For optimization, distinguish constraints that must hold from objectives that
|
|
172
|
-
choose among valid solutions.
|
|
173
|
-
- For optional, nullable, defaulted, persisted, configurable, or externally
|
|
174
|
-
supplied values, model absence before design. State valid members; whether
|
|
175
|
-
absent, `undefined`, `null`, empty, and false-like values differ; the default;
|
|
176
|
-
the owner of that default; the legacy shape; and the counterexample that
|
|
177
|
-
proves the default was enforced in the wrong layer.
|
|
178
|
-
- Preserve domain-specific unknowns as questions. Do not answer them by
|
|
179
|
-
aesthetic preference or by over-formalizing.
|
|
180
|
-
|
|
181
|
-
## Guarantee Placement
|
|
182
|
-
|
|
183
|
-
For each property, choose the cheapest trustworthy layer that can carry the
|
|
184
|
-
guarantee:
|
|
185
|
-
|
|
186
|
-
- Use `type` when the language can exclude invalid states directly.
|
|
187
|
-
- Use `contract` when the rule is semantic and must guide callers/callees.
|
|
188
|
-
- Use `runtime-validation` when invalid external input must be rejected.
|
|
189
|
-
- Use `assertion` when an internal state must already be guaranteed and cheap to
|
|
190
|
-
check.
|
|
191
|
-
- Use `unit-test` or `integration-test` when behavior has concrete examples.
|
|
192
|
-
- Use `property-test` when a domain generator can express the valid input set.
|
|
193
|
-
- Use `proof`, `model-check`, or `solver` only when exhaustive reasoning or
|
|
194
|
-
counterexample search is worth the modeling cost.
|
|
195
|
-
- Use `human` when the rule is a product decision, not a derivable fact.
|
|
196
|
-
- Use an explicit default or normalization owner when missing or legacy data
|
|
197
|
-
should be translated into a domain value before consumers rely on it.
|
|
198
|
-
|
|
199
|
-
If the chosen layer is not a test, still create a verification target explaining
|
|
200
|
-
what evidence will prove the guarantee.
|
|
201
|
-
|
|
202
|
-
## Common Failure Signals
|
|
203
|
-
|
|
204
|
-
- A natural-language `and/or` requirement has no explicit grouping.
|
|
205
|
-
- A rule uses "all", "any", "never", "always", "at least one", or "exactly one"
|
|
206
|
-
without a domain.
|
|
207
|
-
- A quantifier can be read in more than one order, such as "some resource all
|
|
208
|
-
users can access" versus "each user can access some resource."
|
|
209
|
-
- A predicate mixes decision, assumption, and property roles.
|
|
210
|
-
- A type accepts values outside the valid domain, but there is no validation or
|
|
211
|
-
precondition.
|
|
212
|
-
- A fallback expression silently becomes the owner of product or domain default
|
|
213
|
-
policy.
|
|
214
|
-
- A default value appears in multiple layers without one explicit owner.
|
|
215
|
-
- A decision table is complete internally but may not be correct product policy.
|
|
216
|
-
- A state enum exists, but allowed transitions are not represented.
|
|
217
|
-
- A representation change loses information needed to reconstruct the old model.
|
|
218
|
-
- An AI task prompt gives procedure but not facts, constraints, objective, or
|
|
219
|
-
verification.
|
|
220
|
-
|
|
221
|
-
## Verification Target Derivation
|
|
222
|
-
|
|
223
|
-
Turn model elements into verification targets:
|
|
224
|
-
|
|
225
|
-
- `predicate`: unit test, property test, contract check, or proof obligation.
|
|
226
|
-
- `forbiddenCase`: negative test, runtime validation, type exclusion, or model
|
|
227
|
-
check.
|
|
228
|
-
- `decisionSpace`: case matrix, table validation, branch coverage by meaning.
|
|
229
|
-
- `stateTransition`: transition tests, temporal model, stale event checks.
|
|
230
|
-
- `constraint`: assertion, database constraint, validation, solver check.
|
|
231
|
-
- `absenceDefault`: legacy/missing-value case, normalization contract, creation
|
|
232
|
-
default, serialization round trip, and consumer fallback boundary.
|
|
233
|
-
- `objective`: ranking/optimization evidence and accepted tradeoff.
|
|
234
|
-
- `openQuestion`: human decision before any action that depends on it, or
|
|
235
|
-
explicit acceptance of the uncertainty.
|
|
177
|
+
Check initialization, preservation, and conclusion. Use proof or formal tooling
|
|
178
|
+
only when exhaustive confidence justifies the modeling and maintenance cost.
|
|
179
|
+
Tests, runtime validation, model checking, theorem proving, and static types make
|
|
180
|
+
different guarantees; do not label one as another.
|
|
236
181
|
|
|
237
|
-
##
|
|
182
|
+
## Decision Tables
|
|
238
183
|
|
|
239
|
-
|
|
184
|
+
Use a decision table only when:
|
|
240
185
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
- Conditional rules have a counterexample shape.
|
|
246
|
-
- Decision predicates, assumptions, and properties are not collapsed into one
|
|
247
|
-
vague predicate.
|
|
248
|
-
- The selected tool explains the uncertainty it exposes.
|
|
249
|
-
- Each guarantee has an owner and an evidence target.
|
|
250
|
-
- Human policy choices remain open questions instead of guessed rules.
|
|
186
|
+
1. independent inputs map clearly to outputs;
|
|
187
|
+
2. each input can be partitioned into a small finite set;
|
|
188
|
+
3. a table is clearer than an equation, invariant, or transition model;
|
|
189
|
+
4. the expanded table remains reviewable.
|
|
251
190
|
|
|
252
|
-
|
|
191
|
+
A table is complete when no input combination is missing and sound when the same
|
|
192
|
+
input does not map to conflicting outputs. Those properties make the table valid,
|
|
193
|
+
not necessarily correct. A valid table can still encode misunderstood product
|
|
194
|
+
policy; return ambiguous rows to a human owner.
|
|
195
|
+
|
|
196
|
+
Avoid tables for strongly dependent inputs, unbounded collections, recursion,
|
|
197
|
+
long-running side effects, or rules better expressed by precedence such as
|
|
198
|
+
`flags > user settings > defaults`.
|
|
199
|
+
|
|
200
|
+
## Absence And Defaults
|
|
201
|
+
|
|
202
|
+
For optional, nullable, configurable, inherited, persisted, or externally supplied
|
|
203
|
+
values, model absence before design:
|
|
253
204
|
|
|
254
|
-
|
|
255
|
-
|
|
205
|
+
- valid members;
|
|
206
|
+
- whether missing, `undefined`, `null`, empty, and false-like values differ;
|
|
207
|
+
- the domain default and the one boundary that owns it;
|
|
208
|
+
- legacy and serialized shapes;
|
|
209
|
+
- whether normalization preserves source distinctions needed later;
|
|
210
|
+
- a counterexample showing the default applied in the wrong layer.
|
|
256
211
|
|
|
257
|
-
|
|
258
|
-
- variables/concepts: relevant entities, states, and predicates;
|
|
259
|
-
- constraints: must-hold rules and forbidden cases;
|
|
260
|
-
- objective: what to optimize or preserve;
|
|
261
|
-
- verification: counterexamples, gates, and accepted evidence.
|
|
212
|
+
A fallback expression is not harmless when it silently becomes product policy.
|
|
262
213
|
|
|
263
|
-
|
|
214
|
+
## Domains, Assumptions, And Time
|
|
264
215
|
|
|
265
|
-
|
|
216
|
+
A domain model defines possible instances, not the entire real world. Separate
|
|
217
|
+
three predicate roles:
|
|
266
218
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
219
|
+
- **decision**: may be true or false across valid instances;
|
|
220
|
+
- **property**: must hold or the model/design is wrong;
|
|
221
|
+
- **assumption**: defines the well-behaved instances for which the property is
|
|
222
|
+
meaningful.
|
|
223
|
+
|
|
224
|
+
Explore unusual valid instances even after properties pass. A checker verifies
|
|
225
|
+
consequences of the model; it cannot tell whether omitted real-world facts should
|
|
226
|
+
have been modeled.
|
|
227
|
+
|
|
228
|
+
Use a temporal model when correct snapshots are insufficient. State:
|
|
229
|
+
|
|
230
|
+
- initial states;
|
|
231
|
+
- actions and allowed next states;
|
|
232
|
+
- unchanged state for each action;
|
|
233
|
+
- safety properties that must always hold;
|
|
234
|
+
- progress/fairness properties that must eventually hold;
|
|
235
|
+
- stale, duplicated, reordered, retried, or concurrent events.
|
|
236
|
+
|
|
237
|
+
A concrete implementation refines an abstract system only when each observable
|
|
238
|
+
implementation behavior is allowed by the abstract specification, possibly after
|
|
239
|
+
an explicit refinement mapping. This catches gaps such as intermediate states
|
|
240
|
+
that users can observe even though an abstract operation looked atomic.
|
|
241
|
+
|
|
242
|
+
## Constraints, Objectives, And Solvers
|
|
243
|
+
|
|
244
|
+
For solver-shaped work, separate:
|
|
245
|
+
|
|
246
|
+
- variables and domains;
|
|
247
|
+
- hard constraints;
|
|
248
|
+
- an optional objective or ranking;
|
|
249
|
+
- acceptable equivalence among solutions;
|
|
250
|
+
- model assumptions and encoding limits.
|
|
251
|
+
|
|
252
|
+
Use the least specialized tool that is still economical to model, then specialize
|
|
253
|
+
when runtime or scale requires it. General solvers make new constraints easy but
|
|
254
|
+
can be much slower than bespoke algorithms. A solver result of `unknown` is not
|
|
255
|
+
proof of satisfaction or impossibility. Solver output is evidence only to the
|
|
256
|
+
extent that the encoding matches the product problem.
|
|
257
|
+
|
|
258
|
+
## Logic Programming And Planning
|
|
259
|
+
|
|
260
|
+
Logic programming is useful when facts, relations, and inference rules are more
|
|
261
|
+
natural than a fixed control flow. State facts, derived rules, query variables,
|
|
262
|
+
negation meaning, duplicate behavior, search order, and termination. A more
|
|
263
|
+
expressive query language may lose termination guarantees; a restricted system
|
|
264
|
+
may be the better product boundary.
|
|
265
|
+
|
|
266
|
+
For planning, model initial state, goal predicate, legal actions, transition
|
|
267
|
+
result, state invariant, and optional action cost. A generated plan is valid only
|
|
268
|
+
if every intermediate state satisfies the invariant. An optimal plan is optimal
|
|
269
|
+
only for the encoded cost function.
|
|
270
|
+
|
|
271
|
+
## Place Guarantees Deliberately
|
|
272
|
+
|
|
273
|
+
Choose the cheapest trustworthy owner:
|
|
274
|
+
|
|
275
|
+
- `type` for representable-state restrictions;
|
|
276
|
+
- `contract` for caller/callee semantics;
|
|
277
|
+
- `runtime validation` for hostile or external inputs;
|
|
278
|
+
- `database constraint` for persisted relational facts;
|
|
279
|
+
- `assertion` for internal facts already expected to hold;
|
|
280
|
+
- `example/integration test` for concrete behavior;
|
|
281
|
+
- `property test` for a generatable valid domain;
|
|
282
|
+
- `model check/solver/proof` for exhaustive or high-risk relationships;
|
|
283
|
+
- `human decision` for policy rather than derivable fact.
|
|
284
|
+
|
|
285
|
+
Every important model element needs an owner and an evidence target, even when
|
|
286
|
+
the owner is not a test.
|
|
287
|
+
|
|
288
|
+
## AI Delegation Boundary
|
|
289
|
+
|
|
290
|
+
When the model feeds another skill, tool, or agent, provide:
|
|
291
|
+
|
|
292
|
+
```text
|
|
293
|
+
Context: where the work lives and what evidence is authoritative
|
|
294
|
+
Facts: entities, states, predicates, and existing behavior
|
|
295
|
+
Rules: assumptions, must-hold constraints, and forbidden cases
|
|
296
|
+
Objective: what to change, optimize, or preserve
|
|
297
|
+
Unknowns: product decisions that remain human-owned
|
|
298
|
+
Verification: counterexamples, gates, and accepted evidence
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
An AI helper is not a solver or proof. Check its output against the model and the
|
|
302
|
+
runtime semantics.
|
|
303
|
+
|
|
304
|
+
## Stop Checks
|
|
273
305
|
|
|
274
|
-
|
|
306
|
+
The model is usable when:
|
|
307
|
+
|
|
308
|
+
- every important predicate names a domain question;
|
|
309
|
+
- quantifiers have explicit domains and unambiguous nesting;
|
|
310
|
+
- implications have counterexample shapes;
|
|
311
|
+
- assumptions, decisions, and properties are distinct;
|
|
312
|
+
- the representation's lost abilities are acceptable;
|
|
313
|
+
- stateful rules cover transitions, not only enums;
|
|
314
|
+
- replacements state old/new contract relationships;
|
|
315
|
+
- every guarantee has an owner and evidence target;
|
|
316
|
+
- unresolved policy remains visible rather than being guessed.
|
|
317
|
+
|
|
318
|
+
## Source Trace
|
|
319
|
+
|
|
320
|
+
- Hillel Wayne, *Logic for Programmers*, version 0.14.0, May 4, 2026:
|
|
321
|
+
predicates, sets, quantifiers, logical refactoring and runtime caveats, partial
|
|
322
|
+
specifications, contracts and replacement, data constraints, decision tables,
|
|
323
|
+
domains, time, system models, solvers, and logic programming.
|
|
324
|
+
- Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram
|
|
325
|
+
Krishnamurthi, *How to Design Programs, Second Edition*, MIT Press, 2018:
|
|
326
|
+
information interpretation, data definitions, representative cases, and
|
|
327
|
+
iterative refinement.
|
|
328
|
+
- Harold Abelson and Gerald Jay Sussman with Julie Sussman, *Structure and
|
|
329
|
+
Interpretation of Computer Programs*, Second Edition, MIT Press, 1996:
|
|
330
|
+
abstraction mappings, state/history, constraint propagation, and the semantic
|
|
331
|
+
cost of assignment and concurrency.
|
|
332
|
+
- Zachary Tellman, *Elements of Clojure*, 2019: narrow access, absence semantics,
|
|
333
|
+
module models, and assumptions that constrain a useful interface.
|