its-magic 0.1.3-3 → 0.1.3-4
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/package.json +1 -1
- package/scripts/check_intake_template_parity.py +71 -0
- package/template/.cursor/commands/auto.md +54 -4
- package/template/.cursor/commands/closure.md +184 -0
- package/template/.cursor/commands/intake.md +26 -0
- package/template/.cursor/commands/release.md +17 -26
- package/template/.cursor/scratchpad.local.example.md +168 -70
- package/template/docs/engineering/autonomy-stop-matrix.md +101 -0
- package/template/docs/engineering/context/installer-owned-paths.manifest +12 -0
- package/template/docs/engineering/runbook.md +3869 -3576
- package/template/its_magic/README.md +3981 -6
- package/template/scripts/autonomy_preset_lib.py +224 -0
- package/template/scripts/check_intake_template_parity.py +71 -0
- package/template/scripts/validate_autonomy_stop_matrix.py +486 -0
- package/template/scripts/validate_closure_verification.py +304 -0
- package/template/scripts/work_kind_classify_lib.py +543 -0
- package/template/scripts/work_kind_routing_lib.py +318 -0
- package/template/tests/__pycache__/scratchpad_example_parity_test.cpython-312-pytest-9.0.2.pyc +0 -0
- package/template/tests/us0118_contract_test.py +330 -0
- package/template/tests/us0119_autonomy_preset_test.py +168 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Autonomy preset expansion library (US-0119).
|
|
4
|
+
|
|
5
|
+
Expands AUTONOMY_PRESET into per-feature autonomy flags with deterministic,
|
|
6
|
+
pure-stdlib logic. No LLM, no network, no .env reads.
|
|
7
|
+
"""
|
|
8
|
+
import sys
|
|
9
|
+
import json
|
|
10
|
+
from typing import Dict, Optional
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# 12 per-feature autonomy flags (DEC-0119 §7)
|
|
14
|
+
AUTONOMY_FLAGS = {
|
|
15
|
+
"INTAKE_AUTONOMY_MODE",
|
|
16
|
+
"INTAKE_MINIMAL_PACK",
|
|
17
|
+
"INTAKE_ASSUME_STACK_CONTEXT",
|
|
18
|
+
"WORK_KIND_AUTO_ACCEPT",
|
|
19
|
+
"CROSS_MODEL_REWORK_EXHAUSTED_POLICY",
|
|
20
|
+
"CROSS_MODEL_SKIP_PHASES",
|
|
21
|
+
"RESUME_BRIEF_AUTO_REFRESH",
|
|
22
|
+
"RUNTIME_PROOF_KIND",
|
|
23
|
+
"GOAL_CONVERGENCE_INTERVAL",
|
|
24
|
+
"SOVEREIGN_DRAIN_AUTO_ACCEPT",
|
|
25
|
+
"RELEASE_PUBLISH_AUTO_CONFIRM",
|
|
26
|
+
"AUTONOMY_STOP_POLICY",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Preset definitions (DEC-0119 §7)
|
|
31
|
+
# none: empty expansion (byte-identical pre-US-0119)
|
|
32
|
+
# balanced: 8 flags (moderate autonomy)
|
|
33
|
+
# full: all 12 flags (maximum autonomy)
|
|
34
|
+
PRESET_DEFINITIONS = {
|
|
35
|
+
"none": {},
|
|
36
|
+
"balanced": {
|
|
37
|
+
"WORK_KIND_AUTO_ACCEPT": "1",
|
|
38
|
+
"CROSS_MODEL_REWORK_EXHAUSTED_POLICY": "downgrade",
|
|
39
|
+
"CROSS_MODEL_SKIP_PHASES": "",
|
|
40
|
+
"RESUME_BRIEF_AUTO_REFRESH": "1",
|
|
41
|
+
"RUNTIME_PROOF_KIND": "lightweight",
|
|
42
|
+
"GOAL_CONVERGENCE_INTERVAL": "3",
|
|
43
|
+
"SOVEREIGN_DRAIN_AUTO_ACCEPT": "1",
|
|
44
|
+
"AUTONOMY_STOP_POLICY": "auto_repair_then_block",
|
|
45
|
+
},
|
|
46
|
+
"full": {
|
|
47
|
+
"INTAKE_AUTONOMY_MODE": "1",
|
|
48
|
+
"INTAKE_MINIMAL_PACK": "1",
|
|
49
|
+
"INTAKE_ASSUME_STACK_CONTEXT": "1",
|
|
50
|
+
"WORK_KIND_AUTO_ACCEPT": "1",
|
|
51
|
+
"CROSS_MODEL_REWORK_EXHAUSTED_POLICY": "downgrade",
|
|
52
|
+
"CROSS_MODEL_SKIP_PHASES": "",
|
|
53
|
+
"RESUME_BRIEF_AUTO_REFRESH": "1",
|
|
54
|
+
"RUNTIME_PROOF_KIND": "lightweight",
|
|
55
|
+
"GOAL_CONVERGENCE_INTERVAL": "1",
|
|
56
|
+
"SOVEREIGN_DRAIN_AUTO_ACCEPT": "1",
|
|
57
|
+
"RELEASE_PUBLISH_AUTO_CONFIRM": "1",
|
|
58
|
+
"AUTONOMY_STOP_POLICY": "auto_repair_then_skip",
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def expand_autonomy_preset(
|
|
64
|
+
preset: str,
|
|
65
|
+
overrides: Optional[Dict[str, str]] = None
|
|
66
|
+
) -> Dict[str, str]:
|
|
67
|
+
"""
|
|
68
|
+
Expand AUTONOMY_PRESET into per-feature flags.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
preset: One of {none, balanced, full}
|
|
72
|
+
overrides: Explicit per-flag values that override preset defaults
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
Dict of flag_name -> flag_value
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ValueError: If preset is invalid or overrides contain unknown keys
|
|
79
|
+
|
|
80
|
+
Precedence (LOCKED): explicit per-flag > preset expansion > scratchpad defaults
|
|
81
|
+
"""
|
|
82
|
+
if preset not in PRESET_DEFINITIONS:
|
|
83
|
+
raise ValueError(
|
|
84
|
+
f"Invalid AUTONOMY_PRESET='{preset}'. "
|
|
85
|
+
f"Must be one of: {', '.join(PRESET_DEFINITIONS.keys())}"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Start with preset base
|
|
89
|
+
result = PRESET_DEFINITIONS[preset].copy()
|
|
90
|
+
|
|
91
|
+
# Apply overrides (explicit per-flag values always win)
|
|
92
|
+
if overrides:
|
|
93
|
+
unknown_keys = set(overrides.keys()) - AUTONOMY_FLAGS
|
|
94
|
+
if unknown_keys:
|
|
95
|
+
raise ValueError(
|
|
96
|
+
f"Unknown autonomy flag(s) in overrides: {', '.join(sorted(unknown_keys))}"
|
|
97
|
+
)
|
|
98
|
+
result.update(overrides)
|
|
99
|
+
|
|
100
|
+
return result
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def explain_preset(preset: str) -> Dict[str, Dict[str, str]]:
|
|
104
|
+
"""
|
|
105
|
+
Explain preset expansion with source annotations.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
Dict of flag_name -> {value, source} where source is 'preset' or 'default'
|
|
109
|
+
"""
|
|
110
|
+
expansion = PRESET_DEFINITIONS[preset]
|
|
111
|
+
result = {}
|
|
112
|
+
|
|
113
|
+
for flag in sorted(AUTONOMY_FLAGS):
|
|
114
|
+
if flag in expansion:
|
|
115
|
+
result[flag] = {
|
|
116
|
+
"value": expansion[flag],
|
|
117
|
+
"source": "preset"
|
|
118
|
+
}
|
|
119
|
+
else:
|
|
120
|
+
result[flag] = {
|
|
121
|
+
"value": "",
|
|
122
|
+
"source": "default"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return result
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def self_test() -> bool:
|
|
129
|
+
"""
|
|
130
|
+
Self-test mode: verify known-key set, precedence, and preset expansions.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
True if all tests pass, False otherwise
|
|
134
|
+
"""
|
|
135
|
+
tests_passed = 0
|
|
136
|
+
tests_total = 0
|
|
137
|
+
|
|
138
|
+
# Test 1: none preset is empty
|
|
139
|
+
tests_total += 1
|
|
140
|
+
result = expand_autonomy_preset("none")
|
|
141
|
+
if result == {}:
|
|
142
|
+
tests_passed += 1
|
|
143
|
+
print("[PASS] Test 1: none preset is empty")
|
|
144
|
+
else:
|
|
145
|
+
print(f"[FAIL] Test 1: expected {{}}, got {result}")
|
|
146
|
+
|
|
147
|
+
# Test 2: balanced preset has 8 flags
|
|
148
|
+
tests_total += 1
|
|
149
|
+
result = expand_autonomy_preset("balanced")
|
|
150
|
+
if len(result) == 8 and all(k in AUTONOMY_FLAGS for k in result.keys()):
|
|
151
|
+
tests_passed += 1
|
|
152
|
+
print("[PASS] Test 2: balanced preset has 8 flags, all known keys")
|
|
153
|
+
else:
|
|
154
|
+
print(f"[FAIL] Test 2: expected 8 flags, got {len(result)}")
|
|
155
|
+
|
|
156
|
+
# Test 3: full preset has 12 flags
|
|
157
|
+
tests_total += 1
|
|
158
|
+
result = expand_autonomy_preset("full")
|
|
159
|
+
if len(result) == 12 and all(k in AUTONOMY_FLAGS for k in result.keys()):
|
|
160
|
+
tests_passed += 1
|
|
161
|
+
print("[PASS] Test 3: full preset has 12 flags, all known keys")
|
|
162
|
+
else:
|
|
163
|
+
print(f"[FAIL] Test 3: expected 12 flags, got {len(result)}")
|
|
164
|
+
|
|
165
|
+
# Test 4: explicit override wins
|
|
166
|
+
tests_total += 1
|
|
167
|
+
result = expand_autonomy_preset("balanced", {"WORK_KIND_AUTO_ACCEPT": "0"})
|
|
168
|
+
if result.get("WORK_KIND_AUTO_ACCEPT") == "0":
|
|
169
|
+
tests_passed += 1
|
|
170
|
+
print("[PASS] Test 4: explicit override wins over preset")
|
|
171
|
+
else:
|
|
172
|
+
print(f"[FAIL] Test 4: expected '0', got '{result.get('WORK_KIND_AUTO_ACCEPT')}'")
|
|
173
|
+
|
|
174
|
+
# Test 5: unknown key in overrides raises ValueError
|
|
175
|
+
tests_total += 1
|
|
176
|
+
try:
|
|
177
|
+
expand_autonomy_preset("balanced", {"UNKNOWN_FLAG": "1"})
|
|
178
|
+
print("[FAIL] Test 5: should have raised ValueError for unknown key")
|
|
179
|
+
except ValueError:
|
|
180
|
+
tests_passed += 1
|
|
181
|
+
print("[PASS] Test 5: unknown key in overrides raises ValueError")
|
|
182
|
+
|
|
183
|
+
# Test 6: invalid preset raises ValueError
|
|
184
|
+
tests_total += 1
|
|
185
|
+
try:
|
|
186
|
+
expand_autonomy_preset("invalid")
|
|
187
|
+
print("[FAIL] Test 6: should have raised ValueError for invalid preset")
|
|
188
|
+
except ValueError:
|
|
189
|
+
tests_passed += 1
|
|
190
|
+
print("[PASS] Test 6: invalid preset raises ValueError")
|
|
191
|
+
|
|
192
|
+
print(f"\nSelf-test: {tests_passed}/{tests_total} tests passed")
|
|
193
|
+
return tests_passed == tests_total
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == "__main__":
|
|
197
|
+
if len(sys.argv) > 1:
|
|
198
|
+
mode = sys.argv[1]
|
|
199
|
+
|
|
200
|
+
if mode == "--self-test":
|
|
201
|
+
success = self_test()
|
|
202
|
+
sys.exit(0 if success else 1)
|
|
203
|
+
|
|
204
|
+
elif mode == "--explain":
|
|
205
|
+
if len(sys.argv) < 3:
|
|
206
|
+
print("Usage: autonomy_preset_lib.py --explain <preset>")
|
|
207
|
+
sys.exit(1)
|
|
208
|
+
|
|
209
|
+
preset = sys.argv[2]
|
|
210
|
+
try:
|
|
211
|
+
explanation = explain_preset(preset)
|
|
212
|
+
print(json.dumps(explanation, indent=2))
|
|
213
|
+
except Exception as e:
|
|
214
|
+
print(f"Error: {e}", file=sys.stderr)
|
|
215
|
+
sys.exit(1)
|
|
216
|
+
|
|
217
|
+
else:
|
|
218
|
+
print(f"Unknown mode: {mode}", file=sys.stderr)
|
|
219
|
+
print("Usage: autonomy_preset_lib.py [--self-test | --explain <preset>]", file=sys.stderr)
|
|
220
|
+
sys.exit(1)
|
|
221
|
+
|
|
222
|
+
else:
|
|
223
|
+
print("Autonomy Preset Library (US-0119)")
|
|
224
|
+
print("Usage: python autonomy_preset_lib.py [--self-test | --explain <preset>]")
|
|
@@ -16,6 +16,8 @@ Scoped modes (DEC-0073 §10 / US-0090):
|
|
|
16
16
|
--scope=sovereign-parallel-dev DEC-0108 parallel instance arbitrage surfaces (US-0108).
|
|
17
17
|
--scope=sovereign-self-healing-deploy DEC-0109 self-healing deploy loop surfaces (US-0109).
|
|
18
18
|
--scope=release-trigger-adapter DEC-0111 release trigger adapter surfaces (US-0111).
|
|
19
|
+
--scope=us-0119 DEC-0119 autonomous-autonomy preset surfaces (US-0119).
|
|
20
|
+
--scope=us-0120 US-0120 dedicated /closure phase surfaces.
|
|
19
21
|
--scope=all union of all tables.
|
|
20
22
|
"""
|
|
21
23
|
|
|
@@ -409,6 +411,69 @@ RELEASE_TRIGGER_ADAPTER_PAIRS: tuple[tuple[str, str], ...] = (
|
|
|
409
411
|
),
|
|
410
412
|
)
|
|
411
413
|
|
|
414
|
+
# DEC-0118 §6 / US-0118 — Work-kind routing surface pairs. Contents must
|
|
415
|
+
# be byte-identical between active and template paths; installer delivers
|
|
416
|
+
# template copies (BUG-0003 / DEC-0066). 6 surface pairs per R-0106 Q6
|
|
417
|
+
# LOCKED. Note: scratchpad key parity is structural (key presence) via
|
|
418
|
+
# BUG-0013 test, NOT byte-parity (active scratchpad carries project-local
|
|
419
|
+
# overrides like DELIVERY_MODE=ultra_lean that must not leak to template).
|
|
420
|
+
WORK_KIND_ROUTING_PAIRS: tuple[tuple[str, str], ...] = (
|
|
421
|
+
(
|
|
422
|
+
"scripts/work_kind_classify_lib.py",
|
|
423
|
+
"template/scripts/work_kind_classify_lib.py",
|
|
424
|
+
),
|
|
425
|
+
(
|
|
426
|
+
"scripts/work_kind_routing_lib.py",
|
|
427
|
+
"template/scripts/work_kind_routing_lib.py",
|
|
428
|
+
),
|
|
429
|
+
(
|
|
430
|
+
"tests/us0118_contract_test.py",
|
|
431
|
+
"template/tests/us0118_contract_test.py",
|
|
432
|
+
),
|
|
433
|
+
(".cursor/commands/auto.md", "template/.cursor/commands/auto.md"),
|
|
434
|
+
(".cursor/commands/intake.md", "template/.cursor/commands/intake.md"),
|
|
435
|
+
(
|
|
436
|
+
"docs/engineering/runbook.md",
|
|
437
|
+
"template/docs/engineering/runbook.md",
|
|
438
|
+
),
|
|
439
|
+
(
|
|
440
|
+
"docs/engineering/context/installer-owned-paths.manifest",
|
|
441
|
+
"template/docs/engineering/context/installer-owned-paths.manifest",
|
|
442
|
+
),
|
|
443
|
+
(
|
|
444
|
+
"scripts/check_intake_template_parity.py",
|
|
445
|
+
"template/scripts/check_intake_template_parity.py",
|
|
446
|
+
),
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
# DEC-0119 §6 / US-0119 — Autonomous-autonomy preset surfaces. Contents must
|
|
450
|
+
# be byte-identical between active and template paths. 8 surface pairs.
|
|
451
|
+
AUTONOMY_PRESET_PAIRS: tuple[tuple[str, str], ...] = (
|
|
452
|
+
("scripts/autonomy_preset_lib.py", "template/scripts/autonomy_preset_lib.py"),
|
|
453
|
+
("scripts/validate_autonomy_stop_matrix.py", "template/scripts/validate_autonomy_stop_matrix.py"),
|
|
454
|
+
("docs/engineering/autonomy-stop-matrix.md", "template/docs/engineering/autonomy-stop-matrix.md"),
|
|
455
|
+
("docs/engineering/context/installer-owned-paths.manifest", "template/docs/engineering/context/installer-owned-paths.manifest"),
|
|
456
|
+
("docs/engineering/runbook.md", "template/docs/engineering/runbook.md"),
|
|
457
|
+
(".cursor/commands/auto.md", "template/.cursor/commands/auto.md"),
|
|
458
|
+
("tests/us0119_autonomy_preset_test.py", "template/tests/us0119_autonomy_preset_test.py"),
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
# US-0120 — Dedicated /closure phase surfaces. Contents must be byte-identical
|
|
462
|
+
# between active and template paths.
|
|
463
|
+
CLOSURE_PHASE_PAIRS: tuple[tuple[str, str], ...] = (
|
|
464
|
+
(".cursor/commands/closure.md", "template/.cursor/commands/closure.md"),
|
|
465
|
+
(".cursor/commands/release.md", "template/.cursor/commands/release.md"),
|
|
466
|
+
(".cursor/commands/auto.md", "template/.cursor/commands/auto.md"),
|
|
467
|
+
(
|
|
468
|
+
"scripts/validate_closure_verification.py",
|
|
469
|
+
"template/scripts/validate_closure_verification.py",
|
|
470
|
+
),
|
|
471
|
+
(
|
|
472
|
+
"scripts/check_intake_template_parity.py",
|
|
473
|
+
"template/scripts/check_intake_template_parity.py",
|
|
474
|
+
),
|
|
475
|
+
)
|
|
476
|
+
|
|
412
477
|
SCOPES: dict[str, tuple[tuple[str, str], ...]] = {
|
|
413
478
|
"intake": INTAKE_TEMPLATE_PAIRS,
|
|
414
479
|
"caveman-compress": CAVEMAN_COMPRESS_PAIRS,
|
|
@@ -428,6 +493,9 @@ SCOPES: dict[str, tuple[tuple[str, str], ...]] = {
|
|
|
428
493
|
"sovereign-parallel-dev": SOVEREIGN_PARALLEL_DEV_PAIRS,
|
|
429
494
|
"sovereign-self-healing-deploy": SOVEREIGN_SELF_HEALING_DEPLOY_PAIRS,
|
|
430
495
|
"release-trigger-adapter": RELEASE_TRIGGER_ADAPTER_PAIRS,
|
|
496
|
+
"work-kind-routing": WORK_KIND_ROUTING_PAIRS,
|
|
497
|
+
"us-0119": AUTONOMY_PRESET_PAIRS,
|
|
498
|
+
"us-0120": CLOSURE_PHASE_PAIRS,
|
|
431
499
|
"all": (
|
|
432
500
|
INTAKE_TEMPLATE_PAIRS
|
|
433
501
|
+ CAVEMAN_COMPRESS_PAIRS
|
|
@@ -446,6 +514,9 @@ SCOPES: dict[str, tuple[tuple[str, str], ...]] = {
|
|
|
446
514
|
+ SOVEREIGN_ROLE_MANIFEST_PAIRS
|
|
447
515
|
+ SOVEREIGN_SELF_HEALING_DEPLOY_PAIRS
|
|
448
516
|
+ RELEASE_TRIGGER_ADAPTER_PAIRS
|
|
517
|
+
+ WORK_KIND_ROUTING_PAIRS
|
|
518
|
+
+ AUTONOMY_PRESET_PAIRS
|
|
519
|
+
+ CLOSURE_PHASE_PAIRS
|
|
449
520
|
),
|
|
450
521
|
}
|
|
451
522
|
|