@hobin/developer 0.1.8 → 0.1.10
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 +215 -372
- package/REFERENCE_ROUTING.md +243 -0
- package/extensions/compaction-language.ts +303 -0
- package/extensions/developer.ts +607 -20
- package/extensions/machine.ts +45 -0
- package/extensions/references/behavior-preserving-structural-change.md +87 -8
- package/extensions/skills.ts +330 -52
- package/extensions/state.ts +227 -2
- package/package.json +9 -3
- package/skills/abstraction-review/SKILL.md +37 -23
- package/skills/abstraction-review/reference-policy.json +66 -0
- package/skills/abstraction-review/references/field-card.md +113 -168
- package/skills/abstraction-review/references/repair-table.md +66 -80
- package/skills/abstraction-review/references/worked-examples.md +79 -256
- package/skills/model/SKILL.md +31 -13
- package/skills/model/reference-policy.json +96 -0
- package/skills/model/references/contract-and-replacement-models.md +112 -0
- package/skills/model/references/logic-query-semantics.md +89 -0
- package/skills/model/references/planning-models.md +75 -0
- package/skills/model/references/problem-modeling.md +143 -276
- package/skills/model/references/proof-obligations.md +71 -0
- package/skills/model/references/relational-constraint-models.md +110 -0
- package/skills/model/references/solver-result-boundaries.md +83 -0
- package/skills/model/references/temporal-behavior-models.md +106 -0
- package/skills/naming-judgment/SKILL.md +17 -4
- package/skills/naming-judgment/reference-policy.json +29 -0
- package/skills/naming-judgment/references/domain-naming.md +29 -10
- package/skills/schedule/SKILL.md +16 -6
- package/skills/schedule/reference-policy.json +29 -0
- package/skills/schedule/references/structural-change-timing.md +81 -18
- package/skills/signal/SKILL.md +17 -6
- package/skills/signal/reference-policy.json +29 -0
- package/skills/signal/references/structural-movement.md +87 -14
- package/skills/sketch/SKILL.md +38 -42
- package/skills/sketch/reference-policy.json +212 -0
- package/skills/sketch/references/accumulator-invariants.md +125 -0
- package/skills/sketch/references/closure-and-conventional-interfaces.md +87 -0
- package/skills/sketch/references/composition-by-wishes.md +69 -0
- package/skills/sketch/references/data-driven-design.md +99 -22
- package/skills/sketch/references/data-shape-template-catalog.md +58 -19
- package/skills/sketch/references/design-levels-and-boundaries.md +133 -0
- package/skills/sketch/references/earned-abstraction.md +75 -0
- package/skills/sketch/references/generative-recursion.md +122 -0
- package/skills/sketch/references/generic-dispatch-systems.md +75 -0
- package/skills/sketch/references/language-semantics.md +82 -0
- package/skills/sketch/references/meaning-preserving-conversions.md +69 -0
- package/skills/sketch/references/process-shape-and-resources.md +157 -0
- package/skills/sketch/references/representation-barriers.md +73 -0
- package/skills/sketch/references/responsibility-and-collaboration.md +108 -0
- package/skills/sketch/references/runtime-and-compilation.md +84 -0
- package/skills/sketch/references/selection-and-creation.md +76 -0
- package/skills/sketch/references/state-history-and-order.md +126 -0
- package/skills/sketch/references/type-transitions.md +54 -0
- package/skills/sketch/references/variation-roles.md +59 -0
- package/skills/verify/SKILL.md +17 -6
- package/skills/verify/reference-policy.json +30 -0
- package/skills/verify/references/verifier-selection-and-pass-but-wrong.md +152 -192
- package/SOURCES.md +0 -104
- package/skills/abstraction-review/references/recipe-cards.md +0 -322
- package/skills/model/references/worked-models-and-specialized-techniques.md +0 -218
- package/skills/sketch/references/abstraction-barriers-and-closure.md +0 -160
- package/skills/sketch/references/abstraction-composition-and-state.md +0 -184
- package/skills/sketch/references/composition-generative-recursion-and-accumulators.md +0 -196
- package/skills/sketch/references/generic-operations-and-languages.md +0 -134
- package/skills/sketch/references/processes-state-and-time.md +0 -171
- package/skills/sketch/references/responsibility-and-variation.md +0 -245
|
@@ -4,6 +4,10 @@ Use this reference when duplication, parallel branches, repeated tests, code
|
|
|
4
4
|
smells, or a model-code mismatch suggests movement but does not yet justify an
|
|
5
5
|
abstraction or implementation plan.
|
|
6
6
|
|
|
7
|
+
It extends `signal` at comparison and falsification: choose one pair, expose one
|
|
8
|
+
difference with one behavior-preserving observation move, then classify. It does
|
|
9
|
+
not promote the resulting candidate or continue a refactoring sequence.
|
|
10
|
+
|
|
7
11
|
## Central Question
|
|
8
12
|
|
|
9
13
|
What is actually moving in the evidence, and what smallest observation could
|
|
@@ -31,10 +35,12 @@ was appropriate for a previous requirement may become awkward only after new
|
|
|
31
35
|
evidence arrives.
|
|
32
36
|
|
|
33
37
|
A simple concrete implementation with temporary duplication can be a strong
|
|
34
|
-
baseline when it is understandable and protected by relevant examples.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
baseline when it is understandable and protected by relevant examples. Before
|
|
39
|
+
simplifying parallel cases, ask whether the data definition and problem model are
|
|
40
|
+
stable enough that the repeated responsibilities are known; model discrepancy is
|
|
41
|
+
not abstraction evidence. Visible duplication without current pressure is not an
|
|
42
|
+
instruction to refactor. Return `no-signal` when the behavior is cheap to change
|
|
43
|
+
and no accepted claim is being inhibited.
|
|
38
44
|
|
|
39
45
|
## Select The Comparison
|
|
40
46
|
|
|
@@ -68,7 +74,34 @@ Revealing result: what would support or reject the suspected structure
|
|
|
68
74
|
```
|
|
69
75
|
|
|
70
76
|
If the relevant evidence is missing, return `needs-evidence`. Do not rewrite
|
|
71
|
-
tests merely so a proposed refactor can remain green.
|
|
77
|
+
tests merely so a proposed refactor can remain green. “Behavior-preserving” must
|
|
78
|
+
name the relevant semantics: reassociation, traversal order, effects, failure
|
|
79
|
+
versus divergence, or a new complexity class can make an apparently structural
|
|
80
|
+
alignment observable.
|
|
81
|
+
|
|
82
|
+
## Catalog Moves Are Experiments
|
|
83
|
+
|
|
84
|
+
Use familiar tidyings as candidate observation moves, not automatic cleanup:
|
|
85
|
+
|
|
86
|
+
- flatten a nested condition to a guard only when the condition governs all of
|
|
87
|
+
the remaining body and return/failure behavior is equivalent;
|
|
88
|
+
- delete suspected dead code only after static and scoped runtime evidence;
|
|
89
|
+
silence in telemetry is bounded negative evidence, not proof of absence;
|
|
90
|
+
- normalize one symmetry only when representational difference does not encode a
|
|
91
|
+
product, ordering, or failure difference;
|
|
92
|
+
- introduce a wished interface over the old implementation as a reversible
|
|
93
|
+
compatibility seam, not as proof of a durable public abstraction;
|
|
94
|
+
- change reading or cohesion order only while preserving declaration, data, and
|
|
95
|
+
evaluation dependencies;
|
|
96
|
+
- introduce explaining names or explicit parameters only after the represented
|
|
97
|
+
meaning and effect boundary are understood;
|
|
98
|
+
- chunk or extract when purpose and interaction are bounded, but inline toward
|
|
99
|
+
one pile when fragmentation itself hides the process;
|
|
100
|
+
- preserve a nonredundant comment when code cannot carry the reason, external
|
|
101
|
+
constraint, or known coupling honestly.
|
|
102
|
+
|
|
103
|
+
Each move must end in a locally explainable comparison. The catalog does not
|
|
104
|
+
supply the accepted pressure, verifier, or next destination.
|
|
72
105
|
|
|
73
106
|
## Horizontal Movement
|
|
74
107
|
|
|
@@ -81,7 +114,9 @@ Classify movement as horizontal when alignment stays at the current level:
|
|
|
81
114
|
|
|
82
115
|
A stable landing is useful evidence: the code is green, understandable, safe to
|
|
83
116
|
pause, and newly comparable. It is not permission to continue toward a
|
|
84
|
-
predetermined design.
|
|
117
|
+
predetermined design. A structural template may expose more selectors or
|
|
118
|
+
recursive candidates than the completed purpose needs; an explicit purpose-based
|
|
119
|
+
omission is not missing movement. Re-select the closest pair from the new state.
|
|
85
120
|
|
|
86
121
|
## Vertical Movement
|
|
87
122
|
|
|
@@ -126,6 +161,31 @@ accepted model with the implementation for:
|
|
|
126
161
|
Use a behavior-preserving movement only to expose the mismatch. When satisfying
|
|
127
162
|
the model requires changed behavior, keep that behavior change explicit.
|
|
128
163
|
|
|
164
|
+
## Change-Relative Coupling And Cohesion
|
|
165
|
+
|
|
166
|
+
Do not report two elements as simply “coupled.” Name the accepted or historically
|
|
167
|
+
observed delta and direction:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
change delta:
|
|
171
|
+
source element and required change:
|
|
172
|
+
dependent element and why it must also change:
|
|
173
|
+
fanout or cascade:
|
|
174
|
+
evidence: contract, repeated accepted diff, compatibility rule, or trace
|
|
175
|
+
counterevidence: tooling, generated code, shared owner, or accidental batching
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Files appearing together in commits are a clue, not proof: formatting, broad
|
|
179
|
+
pull requests, ownership, and generated output can create false co-change.
|
|
180
|
+
Conversely, runtime capacity or deployment assumptions can couple elements with
|
|
181
|
+
no source dependency.
|
|
182
|
+
|
|
183
|
+
Moving change-related elements adjacent is horizontal cohesion movement. It can
|
|
184
|
+
make a change set easier to see without eliminating the coupling. Report a
|
|
185
|
+
vertical candidate only when repeated deltas reveal a stable containing unit,
|
|
186
|
+
policy, or invariant owner. Do not infer cohesion from proximity alone or create
|
|
187
|
+
one giant container for every transitive relationship.
|
|
188
|
+
|
|
129
189
|
## Worked Observation
|
|
130
190
|
|
|
131
191
|
Baseline: tests protect verses 1, 2, and 0 in a simple formatter. A new accepted
|
|
@@ -190,13 +250,26 @@ The capability is being misused when:
|
|
|
190
250
|
## Source Trace
|
|
191
251
|
|
|
192
252
|
- Sandi Metz, Katrina Owen, and TJ Stankus, *99 Bottles of OOP*, Second
|
|
193
|
-
Edition, version 2.2.2, 2024:
|
|
194
|
-
|
|
195
|
-
|
|
253
|
+
Edition, version 2.2.2, 2024: Chapter 1, pp. 2-22; Chapter 2, pp. 23-50;
|
|
254
|
+
Chapter 3, pp. 51-72; and Chapter 4, pp. 73-101, on Shameless Green,
|
|
255
|
+
listening to change, points of attack, flocking, concentrating on difference,
|
|
256
|
+
horizontal movement, and stable landings.
|
|
196
257
|
- Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram
|
|
197
|
-
Krishnamurthi, *How to Design Programs
|
|
198
|
-
|
|
199
|
-
|
|
258
|
+
Krishnamurthi, *How to Design Programs*, official living build 9.2.0.3,
|
|
259
|
+
released 2026-05-28 and audited 2026-05-28:
|
|
260
|
+
Chapter 14
|
|
261
|
+
and Chapter 15
|
|
262
|
+
for comparing completed concrete designs and lifting corresponding roles;
|
|
263
|
+
Chapter 19
|
|
264
|
+
and Chapter 20
|
|
265
|
+
for stabilizing a data model before simplification; and
|
|
266
|
+
Intermezzo 5
|
|
267
|
+
for duplicated-work and hidden-traversal cost signals.
|
|
200
268
|
- Kent Beck, *Tidy First?: A Personal Exercise in Empirical Software Design*,
|
|
201
|
-
O'Reilly Media,
|
|
202
|
-
|
|
269
|
+
First Edition, Second Release, O'Reilly Media, 2025-12-12:
|
|
270
|
+
Part I, Chapters 1-15, pp. 3-32, for small catalog-shaped observation moves;
|
|
271
|
+
Part II, Chapters 16-18, pp. 35-46, for behavior/structure separation,
|
|
272
|
+
chaining, and batch interactions; and Part III, Chapters 29-32, pp. 77-90,
|
|
273
|
+
for change-relative coupling, fanout/cascades, and cohesion movement. Commit
|
|
274
|
+
co-change, power-law cost, tool-constant fanout, and universal collocation are
|
|
275
|
+
qualified rather than imported as laws.
|
package/skills/sketch/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sketch
|
|
3
|
-
description: "Shape an implementable design surface from a requirement, invariant, problem model, existing code, or representative cases using data definitions, templates, wished interfaces, collaborations, checks, and a small implementation queue. Use when ownership, boundaries, data flow, recursion, state, composition, responsibility, variation, or implementation shape remains unresolved."
|
|
3
|
+
description: "Shape an implementable design surface from a requirement, invariant, problem model, existing code, or representative cases using data definitions, templates, wished interfaces, collaborations, checks, and a small implementation queue. Use when ownership, boundaries, data flow, recursion, state, composition, responsibility, variation, or implementation shape remains unresolved. Prefer sketch when caller-facing operations or collaborations still need to be invented; review a candidate only after that concrete surface exists."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Sketch
|
|
@@ -11,6 +11,21 @@ Turn accepted intent into an implementable design surface.
|
|
|
11
11
|
|
|
12
12
|
What design surface makes this intent implementable?
|
|
13
13
|
|
|
14
|
+
## Judgment Spine
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
accepted intent and cases
|
|
18
|
+
-> data/state/ownership facts
|
|
19
|
+
-> one unresolved design question
|
|
20
|
+
-> wishful caller-visible surface
|
|
21
|
+
-> contract, owner, hidden detail, and falsifier
|
|
22
|
+
-> first executable item + explicit handoffs
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A reference extends one arrow in this spine. It must not contribute unrelated
|
|
26
|
+
insights merely because they share a book or broad topic. If a question has its
|
|
27
|
+
own artifact and stop, select or create a separate route.
|
|
28
|
+
|
|
14
29
|
## Inputs
|
|
15
30
|
|
|
16
31
|
- Requirement, invariant, or problem model when available
|
|
@@ -20,40 +35,13 @@ What design surface makes this intent implementable?
|
|
|
20
35
|
|
|
21
36
|
## Reference Routing
|
|
22
37
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
when
|
|
30
|
-
or interactive data must derive a template. Read
|
|
31
|
-
[composition, generative recursion, and accumulators](references/composition-generative-recursion-and-accumulators.md)
|
|
32
|
-
for wished auxiliaries, abstraction from completed functions, generated
|
|
33
|
-
subproblems and termination, or an invariant-bearing accumulator.
|
|
34
|
-
|
|
35
|
-
Read [the abstraction, composition, and state reference](references/abstraction-composition-and-state.md)
|
|
36
|
-
when wishful top-level design, representation independence, abstraction
|
|
37
|
-
barriers, compositional interfaces, module assumptions, environmental process
|
|
38
|
-
boundaries, state/history ownership, or levels of language carry consequential
|
|
39
|
-
judgment.
|
|
40
|
-
|
|
41
|
-
Within that capability, read [abstraction barriers and closure](references/abstraction-barriers-and-closure.md)
|
|
42
|
-
for a representation or combination boundary,
|
|
43
|
-
[processes, state, and time](references/processes-state-and-time.md) for runtime
|
|
44
|
-
shape, history, identity, streams, concurrency, or order, and
|
|
45
|
-
[generic operations and languages](references/generic-operations-and-languages.md)
|
|
46
|
-
for additive representations, coercion, symbolic data, a DSL, or an evaluator.
|
|
47
|
-
|
|
48
|
-
Read [the responsibility and variation reference](references/responsibility-and-variation.md)
|
|
49
|
-
when real change pressure exposes repeated arguments, data clumps, conditional
|
|
50
|
-
dispatch, misplaced knowledge, role substitution, object creation, factory
|
|
51
|
-
tradeoffs, or test-unit boundaries.
|
|
52
|
-
|
|
53
|
-
Read multiple references only when their questions genuinely combine: for
|
|
54
|
-
example, data shape may derive the operational skeleton while abstraction and
|
|
55
|
-
responsibility evidence determine its boundaries. A small local design whose
|
|
56
|
-
purpose, cases, data flow, and first item are already clear needs none.
|
|
38
|
+
The machine-readable [reference policy](reference-policy.json) is the routing
|
|
39
|
+
authority. Each route answers one narrower design question and declares the
|
|
40
|
+
judgment step, artifact, stop, and separation boundary it owns. Select a narrow
|
|
41
|
+
route instead of its fallback; select several only when each produces an
|
|
42
|
+
independent artifact needed by the same sketch. A co-required set means every
|
|
43
|
+
member is necessary for that route's one result, not that the documents share a
|
|
44
|
+
subject. Use the exemption only when no trigger applies and cite its evidence.
|
|
57
45
|
|
|
58
46
|
## Output
|
|
59
47
|
|
|
@@ -101,16 +89,19 @@ data-flow assumptions.
|
|
|
101
89
|
2. State the design unit's purpose in the user's language.
|
|
102
90
|
3. Derive relevant data or state definitions and their ownership pressure.
|
|
103
91
|
4. List representative cases before choosing code shape.
|
|
104
|
-
5.
|
|
105
|
-
|
|
92
|
+
5. Name each independently unresolved design question and select only its routed
|
|
93
|
+
extension; keep disputed meaning in `model`.
|
|
94
|
+
6. Derive the needed template, composition, generation, invariant, level,
|
|
95
|
+
process, state, dispatch, language, or responsibility artifact.
|
|
96
|
+
7. Write wishful top-level code, pseudocode, or interaction flow in a fenced
|
|
106
97
|
code block. Show every wished interface in context rather than merely naming
|
|
107
98
|
helpers in prose.
|
|
108
|
-
|
|
99
|
+
8. For each wished interface, state its purpose, contract, owner, hidden detail,
|
|
109
100
|
and representative stop check in a table.
|
|
110
|
-
|
|
101
|
+
9. Draw the smallest inline map that exposes non-trivial data flow,
|
|
111
102
|
collaboration, state movement, or ownership boundaries.
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
10. Separate design artifacts, implementation items, candidate reviews, and
|
|
104
|
+
deferred questions. Keep the implementation queue small.
|
|
114
105
|
|
|
115
106
|
## Missing Evidence
|
|
116
107
|
|
|
@@ -123,4 +114,9 @@ assumptions.
|
|
|
123
114
|
## Boundary
|
|
124
115
|
|
|
125
116
|
Do not own product scope, decide model correctness, promote an abstraction,
|
|
126
|
-
schedule structural timing, implement the change, or verify completion.
|
|
117
|
+
schedule structural timing, implement the change, or verify completion. Creating
|
|
118
|
+
an original public operation set, representation boundary, ownership map, or
|
|
119
|
+
caller shape belongs here even when replacement pressure motivates it. Route
|
|
120
|
+
`abstraction-review` only after a concrete caller-facing candidate exists; route
|
|
121
|
+
`model` first only when unresolved cases or rules can materially change the
|
|
122
|
+
surface.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"routes": [
|
|
4
|
+
{
|
|
5
|
+
"id": "data-driven-design",
|
|
6
|
+
"question": "How do accepted data meanings and examples determine the first executable function surface?",
|
|
7
|
+
"trigger": "Product information, variants, examples, or tests should determine the function skeleton, and no narrower template, composition, generation, or accumulator question is primary.",
|
|
8
|
+
"method_step": "derive data definition, interpretation, examples, purpose, template, completed shape, and first executable item",
|
|
9
|
+
"references": ["references/data-driven-design.md"],
|
|
10
|
+
"artifacts": ["the six ordered design artifacts", "repository contradictions mapped to those artifacts", "a bounded first item and propagation check"],
|
|
11
|
+
"stop": "Accepted data and behavior examples constrain an executable skeleton with contradictions and compatibility visible.",
|
|
12
|
+
"separate_when": "Template shape, composition, earned abstraction, generated problems, or accumulated knowledge has an independent artifact."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "data-shape-template",
|
|
16
|
+
"question": "Which branches, selectors, recursive calls, and delegations follow from this accepted data shape?",
|
|
17
|
+
"trigger": "Atomic, interval, itemized, structured, recursive, intertwined, multi-input, complex-output, or interactive data must determine the structural template.",
|
|
18
|
+
"method_step": "after data meaning/examples, derive one position for every accepted clause, field, self-reference, or delegated reference",
|
|
19
|
+
"read_order": "listed",
|
|
20
|
+
"references": ["references/data-driven-design.md", "references/data-shape-template-catalog.md"],
|
|
21
|
+
"artifacts": ["the six design artifacts", "a data-corresponding template", "purpose-based omissions and first mismatch diagnosis"],
|
|
22
|
+
"stop": "Every template position corresponds to accepted data and every omission follows from purpose.",
|
|
23
|
+
"separate_when": "Calls are generated rather than structurally selected, traversal needs carried knowledge, or input relations remain policy."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "composition-by-wishes",
|
|
27
|
+
"question": "Which independently meaningful operations compose this accepted result?",
|
|
28
|
+
"trigger": "One accepted purpose contains several separately nameable subproblems with composable intermediate results.",
|
|
29
|
+
"method_step": "after the base recipe, write top-level wished composition and design each subproblem purpose, contract, examples, and template",
|
|
30
|
+
"read_order": "listed",
|
|
31
|
+
"references": ["references/data-driven-design.md", "references/composition-by-wishes.md"],
|
|
32
|
+
"artifacts": ["a top-level wished composition", "independent subproblem contracts/templates", "intermediate compatibility and first composable slice"],
|
|
33
|
+
"stop": "Each operation is independently designable/checkable and the composition hides no incompatible order, effect, or failure boundary.",
|
|
34
|
+
"separate_when": "The question is shared roles across completed designs, generated problems, carried knowledge, process, or state."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "earned-abstraction",
|
|
38
|
+
"question": "Which stable variation roles emerge from several completed correct designs?",
|
|
39
|
+
"trigger": "At least two completed designs with stable purposes/data models expose aligned common movement and possible variation roles.",
|
|
40
|
+
"method_step": "align completed designs and roles, test migration, transfer, and semantic/process observers, then return a candidate",
|
|
41
|
+
"read_order": "listed",
|
|
42
|
+
"references": ["references/data-driven-design.md", "references/earned-abstraction.md"],
|
|
43
|
+
"artifacts": ["completed-design alignment", "a variation-role table and candidate interface", "migration, transfer, observer, and deferred-promotion checks"],
|
|
44
|
+
"stop": "Migrated old designs are simple clients, one transfer fits, and the result is handed to abstraction review rather than approved here.",
|
|
45
|
+
"separate_when": "Only horizontal similarity exists, model meaning is unstable, or a single purpose merely needs decomposition."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "generative-recursion",
|
|
49
|
+
"question": "How are new problem instances generated, related to the original, combined, and proven to progress?",
|
|
50
|
+
"trigger": "Recursive calls are computed by an algorithm idea rather than immediate data fields, including numeric, randomized, divide-and-conquer, or backtracking processes.",
|
|
51
|
+
"method_step": "derive trivial cases, generation, preservation, combination, progress, traces, and failure/divergence semantics",
|
|
52
|
+
"read_order": "listed",
|
|
53
|
+
"references": ["references/data-driven-design.md", "references/generative-recursion.md"],
|
|
54
|
+
"artifacts": ["generation and preservation relations", "a branchwise progress measure or divergence boundary", "machine/random/search limits"],
|
|
55
|
+
"stop": "Every generated branch has correctness and progress evidence; failure, exhaustion, error, and divergence are distinct.",
|
|
56
|
+
"separate_when": "Calls follow data fields, the issue is accumulated knowledge, or search policy remains a model question."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "accumulator-invariant",
|
|
60
|
+
"question": "What lost knowledge or repeated work should traversal carry, and what invariant determines its updates?",
|
|
61
|
+
"trigger": "Traversal recomputes work, loses original/path context, requires provenance/visited/cache knowledge, or needs a sufficient summary.",
|
|
62
|
+
"method_step": "state the original/current/accumulated relation before selecting argument, closure, field, branch, frontier, global, or result ownership",
|
|
63
|
+
"read_order": "listed",
|
|
64
|
+
"references": ["references/data-driven-design.md", "references/accumulator-invariants.md"],
|
|
65
|
+
"artifacts": ["an invariant determining initial/update/result", "a trace and ownership choice", "semantic and resource delta checks"],
|
|
66
|
+
"stop": "The invariant explains initial, step, and final states and every semantic/resource delta is explicit.",
|
|
67
|
+
"separate_when": "Problems are generated, carried data is persistent product history, or a concrete cache surface needs review."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "design-levels",
|
|
71
|
+
"question": "Which vocabulary, owner, and dependency direction make this caller contract truthful?",
|
|
72
|
+
"trigger": "The sketch must choose a level, owner, environment/interface boundary, hidden choice, or dependency direction, and no narrower route is primary.",
|
|
73
|
+
"method_step": "place wished operations, observers, owner, hidden mechanism, assumptions, drift, and replacement falsifier on explicit levels",
|
|
74
|
+
"references": ["references/design-levels-and-boundaries.md"],
|
|
75
|
+
"artifacts": ["a caller-purpose and level map", "contract/owner/hidden choice/assumptions", "an alternate implementation or falsifier"],
|
|
76
|
+
"stop": "Dependencies use truthful vocabulary, guarantees have owners, and lower-level change does not force unrelated callers.",
|
|
77
|
+
"separate_when": "Representation, closure, process, state, dispatch, conversion, language, runtime, responsibility, or variation has its own output."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "representation-barrier",
|
|
81
|
+
"question": "Which public operations and laws hide this consequential representation choice?",
|
|
82
|
+
"trigger": "A domain value needs representation-independent constructors, selectors, predicates, operations, laws, replacement, or leak checks.",
|
|
83
|
+
"method_step": "after levels, derive supported public operations/laws, owner, two representations, caller rewrite, replacement, and leak search",
|
|
84
|
+
"read_order": "listed",
|
|
85
|
+
"references": ["references/design-levels-and-boundaries.md", "references/representation-barriers.md"],
|
|
86
|
+
"artifacts": ["a public domain vocabulary/law set", "two representations and one caller rewrite", "replacement and leak checks"],
|
|
87
|
+
"stop": "A materially different representation changes only the owner/adapters and callers use no raw primitive.",
|
|
88
|
+
"separate_when": "The issue is closure/finalizers, process, state, dispatch, language, or candidate promotion."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "closure-interface",
|
|
92
|
+
"question": "Which operations keep results inside one composable unit, and which intentionally finalize outside it?",
|
|
93
|
+
"trigger": "A closure property, higher-order role, conventional interface, observer/finalizer split, or operational composition assumption is consequential.",
|
|
94
|
+
"method_step": "derive unit predicate, primitives, closed operations, finalizers, invalid combinations, role contracts, and interface assumptions",
|
|
95
|
+
"read_order": "listed",
|
|
96
|
+
"references": ["references/design-levels-and-boundaries.md", "references/closure-and-conventional-interfaces.md"],
|
|
97
|
+
"artifacts": ["a composition-unit and closed-operation table", "explicit observers/finalizers", "higher-order/conventional-interface operational checks"],
|
|
98
|
+
"stop": "Closed operations build required larger units, finalizers are explicit, and stages agree on operational semantics.",
|
|
99
|
+
"separate_when": "The issue is raw representation, process-resource behavior, or a language evaluator."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "process-resources",
|
|
103
|
+
"question": "What work, control, waits, capacity, lifetime, and completion process does this surface generate?",
|
|
104
|
+
"trigger": "Correctness depends on work, continuation/tail position, stack/queue/buffer cost, paused dependencies, overload, lazy acquisition, retention, acknowledgment, cancellation, or bounds without product history being primary.",
|
|
105
|
+
"method_step": "trace work, control, waits, capacity, roots, release, phases, acknowledgment, and failure ownership",
|
|
106
|
+
"read_order": "listed",
|
|
107
|
+
"references": ["references/design-levels-and-boundaries.md", "references/process-shape-and-resources.md"],
|
|
108
|
+
"artifacts": ["a process/continuation trace", "wait/capacity/root/release ownership", "phase/acknowledgment/retry/cancellation boundaries"],
|
|
109
|
+
"stop": "Work, control, wait, capacity, lifetime, failure, and completion are owned and bounded for one honest step.",
|
|
110
|
+
"separate_when": "History/order defines product meaning, or the process is specifically a language runtime convention."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "state-history-order",
|
|
114
|
+
"question": "Which history, identity, transition, and order laws must the design own?",
|
|
115
|
+
"trigger": "Correctness depends on prior interactions, identity, aliases, mutation, transitions, stale/duplicate/reordered/concurrent events, atomicity, streams, logs, replay, or demand history.",
|
|
116
|
+
"method_step": "derive required history, sufficient summary, owner/writers, transitions, order law, aliases, and stream/log observers",
|
|
117
|
+
"read_order": "listed",
|
|
118
|
+
"references": ["references/design-levels-and-boundaries.md", "references/state-history-and-order.md"],
|
|
119
|
+
"artifacts": ["a history/summary relation", "states/events/transitions/identity/order law", "stale/duplicate/retry/stream/log policy"],
|
|
120
|
+
"stop": "Every admitted history has an owner/transition explanation and identity, order, and log observers are explicit.",
|
|
121
|
+
"separate_when": "Allowed histories/fairness remain a model question, or only resource behavior without product history is unresolved."
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "generic-dispatch",
|
|
125
|
+
"question": "Which extension axis and dispatch owner support additive variants without hidden policy?",
|
|
126
|
+
"trigger": "Accepted representations must coexist through generic operations, data-directed dispatch, registration, or explicit unsupported capabilities.",
|
|
127
|
+
"method_step": "derive the variant-operation matrix, observed growth axis, dispatch owner, conflicts, precedence, load order, and extension checks",
|
|
128
|
+
"read_order": "listed",
|
|
129
|
+
"references": ["references/design-levels-and-boundaries.md", "references/generic-dispatch-systems.md"],
|
|
130
|
+
"artifacts": ["a variant-operation matrix and growth-axis decision", "dispatch/conflict/unsupported policy", "fake-row, new-column, and simpler-conditional checks"],
|
|
131
|
+
"stop": "Both axes and dispatch policies are explicit and the mechanism is no more powerful than current pressure requires.",
|
|
132
|
+
"separate_when": "The task is semantic conversion, role/creation ownership, or executable language notation."
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "meaning-preserving-conversion",
|
|
136
|
+
"question": "Which conversion path preserves the observer required by this cross-representation operation?",
|
|
137
|
+
"trigger": "Mixed representation worlds need direct operation, coercion, canonicalization, explicit context, or rejection with visible precision/identity/order/capability loss.",
|
|
138
|
+
"method_step": "draw conversion paths and derive preserved observer, lost ability, ambiguity, cycle/termination, and unsupported policy per edge",
|
|
139
|
+
"read_order": "listed",
|
|
140
|
+
"references": ["references/design-levels-and-boundaries.md", "references/meaning-preserving-conversions.md"],
|
|
141
|
+
"artifacts": ["a conversion graph", "preserved/lost observer notes", "ambiguity, cycle, unsupported, and round-trip checks"],
|
|
142
|
+
"stop": "Every legal edge preserves the required observer and every loss, ambiguity, or unsupported path is explicit.",
|
|
143
|
+
"separate_when": "Preserved meaning is disputed or additive operation dispatch is independently required."
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "language-semantics",
|
|
147
|
+
"question": "What programs does this notation admit, and what do they mean?",
|
|
148
|
+
"trigger": "The design needs symbolic data, a DSL, query/workflow language, grammar, parser, evaluator, result/search shape, scope, order, effects, errors, or termination semantics.",
|
|
149
|
+
"method_step": "pass the language gate, then derive grammar, semantic representation, validation, evaluator/result/effect/error contract, and ordinary-data alternative",
|
|
150
|
+
"read_order": "listed",
|
|
151
|
+
"references": ["references/design-levels-and-boundaries.md", "references/language-semantics.md"],
|
|
152
|
+
"artifacts": ["a language gate and ordinary-data alternative", "grammar/representation/validation", "an evaluator/result/effect/error contract"],
|
|
153
|
+
"stop": "Representative and invalid programs have explainable syntax, meaning, result shape, effects, and failure.",
|
|
154
|
+
"separate_when": "Lowering, compilation, calling convention, roots, or optimization is independently consequential, or search policy is unresolved."
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "runtime-compilation",
|
|
158
|
+
"question": "How does this runtime or compiler preserve the accepted language observers?",
|
|
159
|
+
"trigger": "An accepted language needs interpreter/VM/compiler lowering, calling convention, effect summaries, optimization guards, tail-space, roots, release, or mixed execution.",
|
|
160
|
+
"method_step": "after language semantics, derive execution convention, live state, effects, guards/fallback, roots/release, and interoperation",
|
|
161
|
+
"read_order": "listed",
|
|
162
|
+
"references": ["references/design-levels-and-boundaries.md", "references/language-semantics.md", "references/runtime-and-compilation.md"],
|
|
163
|
+
"artifacts": ["an execution/calling convention", "effect summaries and optimization guards", "tail-space, roots, release, and interoperation checks"],
|
|
164
|
+
"stop": "Nested calls and optimized fragments preserve accepted observers under guards with complete enough roots/release/interoperation.",
|
|
165
|
+
"separate_when": "Program meaning is unsettled or the process is an ordinary non-language execution boundary."
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"id": "responsibility-collaboration",
|
|
169
|
+
"question": "Which owner and messages make this accepted change local without participant or navigation leaks?",
|
|
170
|
+
"trigger": "A real change exposes repeated arguments, data clumps, misplaced knowledge, feature envy, navigation leaks, participant assumptions, or responsibility-focused test pressure.",
|
|
171
|
+
"method_step": "inventory current knowledge/decisions/coordination, then derive wished messages, one coherent owner, participant assumptions, and collaboration boundary",
|
|
172
|
+
"references": ["references/responsibility-and-collaboration.md"],
|
|
173
|
+
"artifacts": ["a responsibility inventory and point of attack", "wished messages and candidate owner", "participant/assumption/navigation/evidence checks"],
|
|
174
|
+
"stop": "The representative change is local to a coherent owner and callers need no unrelated context or participant internals.",
|
|
175
|
+
"separate_when": "Role substitution/creation is independently unresolved, meaning is disputed, only movement is visible, or the candidate needs review."
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"id": "variation-role",
|
|
179
|
+
"question": "Which shared caller role supports these accepted implementations?",
|
|
180
|
+
"trigger": "Accepted variants may share caller messages, substitution obligations, effects, failures, or unsupported cases.",
|
|
181
|
+
"method_step": "derive the caller role, implementation preconditions/results/failures/effects, unsupported policy, transfer case, and direct-conditional alternative",
|
|
182
|
+
"references": ["references/variation-roles.md"],
|
|
183
|
+
"artifacts": ["a role/implementation contract", "substitution and unsupported-case checks", "a transfer implementation and direct-conditional alternative"],
|
|
184
|
+
"stop": "Every admitted implementation substitutes for declared observers and one transfer fits without caller type tests or flags.",
|
|
185
|
+
"separate_when": "Type transition, selection/creation, responsibility ownership, generic dispatch, compatibility meaning, or candidate promotion is independently unresolved."
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"id": "type-transition",
|
|
189
|
+
"question": "How does this accepted event transform one domain type into another while preserving meaning?",
|
|
190
|
+
"trigger": "An operation or event changes a source domain type into a target type with consequential preserved, consumed, retained, terminal, or failure semantics.",
|
|
191
|
+
"method_step": "derive source/event/target, preconditions, preserved meaning, consumed/retained facts, boundary behavior, failure, and construction owner",
|
|
192
|
+
"references": ["references/type-transitions.md"],
|
|
193
|
+
"artifacts": ["a source-event-target contract", "preserved/consumed/retained fact map", "terminal, failure, and construction-owner checks"],
|
|
194
|
+
"stop": "Every accepted source state has one explicit target or failure meaning and preserved facts do not depend on representation coincidence.",
|
|
195
|
+
"separate_when": "Shared role, target selection/creation, or temporal ordering among transitions is independently unresolved."
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "selection-creation",
|
|
199
|
+
"question": "Which owner and least-powerful mechanism should select and construct this variant?",
|
|
200
|
+
"trigger": "Accepted work needs conditional/ordered selection, object creation, factory/mapping/registration/discovery choice, or creation at the composition edge.",
|
|
201
|
+
"method_step": "derive variants/selection input, owner, overlap/precedence/conflicts, unsupported/load-order policy, and mechanism continuum",
|
|
202
|
+
"references": ["references/selection-and-creation.md"],
|
|
203
|
+
"artifacts": ["a selection-owner and conflict policy", "a creation-mechanism comparison", "fake-variant, startup-failure, and deferred-openness checks"],
|
|
204
|
+
"stop": "Selection has one owner and the creation mechanism is no more open or operationally powerful than accepted pressure requires.",
|
|
205
|
+
"separate_when": "The caller role, responsibility boundary, full generic-operation matrix, or candidate promotion is independently unresolved."
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"exemption": {
|
|
209
|
+
"when": "The local purpose, cases, data flow, ownership, caller skeleton, checks, and first item are explicit, and no routed judgment has an independent artifact.",
|
|
210
|
+
"evidence": ["accepted intent and cases", "existing caller surface and owner map", "bounded first item and checks", "why every judgment extension is non-consequential"]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Accumulator Invariants
|
|
2
|
+
|
|
3
|
+
Use this reference when traversal loses knowledge needed later, repeats work, or
|
|
4
|
+
requires an explicit summary of the processed and remaining problem.
|
|
5
|
+
|
|
6
|
+
## Pressure Before Parameter
|
|
7
|
+
|
|
8
|
+
Do not start by adding an argument. Name the pressure:
|
|
9
|
+
|
|
10
|
+
- prior work is recomputed;
|
|
11
|
+
- an answer must be built in an order the natural return path cannot provide;
|
|
12
|
+
- branch-local provenance or visited knowledge is required;
|
|
13
|
+
- a tail-position process needs a sufficient summary;
|
|
14
|
+
- a cached fact must remain consistent with the represented value.
|
|
15
|
+
|
|
16
|
+
An extra parameter without a stated meaning is hidden state.
|
|
17
|
+
|
|
18
|
+
## Invariant First
|
|
19
|
+
|
|
20
|
+
Write a relation among original input, current remainder, and accumulated
|
|
21
|
+
knowledge:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
original meaning
|
|
25
|
+
= combine(processed meaning, remaining meaning)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For reverse:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
original == reverse(seenReversed) ++ remaining
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Trace it:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
original [a,b,c], remaining [a,b,c], seenReversed []
|
|
38
|
+
original [a,b,c], remaining [b,c], seenReversed [a]
|
|
39
|
+
original [a,b,c], remaining [c], seenReversed [b,a]
|
|
40
|
+
original [a,b,c], remaining [], seenReversed [c,b,a]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The invariant determines initialization, transition, and result.
|
|
44
|
+
|
|
45
|
+
## Three Obligations
|
|
46
|
+
|
|
47
|
+
1. **Initial:** identity values make the relation true before work.
|
|
48
|
+
2. **Preserve:** every structural or generated branch updates all related values
|
|
49
|
+
so the relation remains true.
|
|
50
|
+
3. **Conclude:** the base condition plus the invariant implies the public result.
|
|
51
|
+
|
|
52
|
+
If one branch cannot preserve the relation, revise the invariant or the ownership
|
|
53
|
+
of accumulated knowledge rather than patching the update.
|
|
54
|
+
|
|
55
|
+
## Ownership Forms
|
|
56
|
+
|
|
57
|
+
Choose the smallest truthful owner:
|
|
58
|
+
|
|
59
|
+
- helper argument for traversal-local context;
|
|
60
|
+
- closure for stable original context;
|
|
61
|
+
- data field for cached facts behind a closed update boundary;
|
|
62
|
+
- branch-local value for path provenance;
|
|
63
|
+
- frontier or global structure for graph search;
|
|
64
|
+
- threaded result when one branch consumes another branch's output.
|
|
65
|
+
|
|
66
|
+
Path-local, frontier, and global visited sets are not interchangeable. A public
|
|
67
|
+
wrapper should hide private accumulator states when only one initialization
|
|
68
|
+
satisfies the public contract.
|
|
69
|
+
|
|
70
|
+
## Semantic And Resource Delta
|
|
71
|
+
|
|
72
|
+
An accumulator transformation may change:
|
|
73
|
+
|
|
74
|
+
- arithmetic association and floating-point result;
|
|
75
|
+
- item or branch order;
|
|
76
|
+
- failure versus divergence;
|
|
77
|
+
- totality on previously failing inputs;
|
|
78
|
+
- tail position and stack usage;
|
|
79
|
+
- lookup complexity and retained memory;
|
|
80
|
+
- cache consistency and alias behavior.
|
|
81
|
+
|
|
82
|
+
Treat optimization, totality repair, and behavior preservation as different
|
|
83
|
+
claims. Verify the observer each claim names.
|
|
84
|
+
|
|
85
|
+
## Artifact
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
Observed lost knowledge or repeated work:
|
|
89
|
+
Original / current / accumulated relation:
|
|
90
|
+
Identity initialization:
|
|
91
|
+
Transition and preservation explanation:
|
|
92
|
+
Base condition and conclusion:
|
|
93
|
+
Accumulator owner and visibility:
|
|
94
|
+
Representative trace:
|
|
95
|
+
Arithmetic/order/failure/space delta:
|
|
96
|
+
Public wrapper and checks:
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Stop And Separation
|
|
100
|
+
|
|
101
|
+
Stop when the invariant mechanically determines initialization, update, and
|
|
102
|
+
result, and the semantic/resource delta is explicit.
|
|
103
|
+
|
|
104
|
+
Use `generative-recursion` when next problems are algorithmically produced,
|
|
105
|
+
`state-history-and-order` when accumulated knowledge is persistent product
|
|
106
|
+
history, and `abstraction-review` only after a concrete accumulator interface or
|
|
107
|
+
cached representation exists to judge.
|
|
108
|
+
|
|
109
|
+
## Source Trace
|
|
110
|
+
|
|
111
|
+
- Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram
|
|
112
|
+
Krishnamurthi, *How to Design Programs*, living build 9.2.0.3:
|
|
113
|
+
Chapter 31,
|
|
114
|
+
Chapter 32,
|
|
115
|
+
Chapter 33,
|
|
116
|
+
and Chapter 34
|
|
117
|
+
for accumulator pressure, invariants, wrappers, ownership variants, cached
|
|
118
|
+
fields, provenance, and accumulator-as-result designs.
|
|
119
|
+
- Harold Abelson and Gerald Jay Sussman with Julie Sussman, *Structure and
|
|
120
|
+
Interpretation of Computer Programs*, Second Edition:
|
|
121
|
+
Section 1.2
|
|
122
|
+
and Section 5.4.2
|
|
123
|
+
for process shape, continuation placement, and tail-space behavior.
|
|
124
|
+
- Machine-resource gates, visited-scope taxonomy, and production cache checks are
|
|
125
|
+
Developer adaptations of those invariant and process boundaries.
|