anti-slop-engineering 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.skills.json +1 -1
- package/README.md +57 -4
- package/SKILL.md +6 -1
- package/bin/cli.js +24 -3
- package/dist/bin/anti-slop-rust +0 -0
- package/dist/bin/toil-guard +0 -0
- package/install.sh +8 -2
- package/marketplace.json +1 -1
- package/package.json +3 -1
- package/references/anti-pattern-catalog.md +1 -0
- package/scripts/bump_version.py +276 -0
- package/scripts/future_scale_guard.py +197 -0
- package/scripts/paranoid_guard.py +201 -0
- package/services/anti-slop-rust/Cargo.lock +1 -1
- package/services/anti-slop-rust/Cargo.toml +1 -1
- package/services/toil-guard-go/pkg/model/types.go +1 -1
- package/services/toil-guard-go/pkg/server/server.go +1 -1
- package/skills/future-scale-gate/SKILL.md +101 -0
- package/skills/future-scale-gate/evals/scenarios.json +78 -0
- package/skills/future-scale-gate/examples/runtime-envelope-record.json +61 -0
- package/skills/future-scale-gate/references/foundation-method.md +73 -0
- package/skills/future-scale-gate/references/record-contract.md +47 -0
- package/skills/future-scale-gate/usecases/architect.md +13 -0
- package/skills/future-scale-gate/usecases/review.md +10 -0
- package/skills/paranoid-principal-architect/Playbook/paranoid_principal_architect_playbook.md +92 -0
- package/skills/paranoid-principal-architect/SKILL.md +140 -0
- package/skills/paranoid-principal-architect/evals/scenarios.json +112 -0
- package/skills/paranoid-principal-architect/examples/hardened-idempotent-service.ts +177 -0
- package/skills/paranoid-principal-architect/examples/paranoid-architecture-record.json +58 -0
- package/skills/paranoid-principal-architect/references/modern-web-platform.md +134 -0
- package/skills/paranoid-principal-architect/references/scale-concurrency-patterns.md +173 -0
- package/skills/paranoid-principal-architect/references/threat-record-contract.md +130 -0
- package/skills/paranoid-principal-architect/references/zero-trust-security.md +128 -0
- package/skills/paranoid-principal-architect/usecases/architect.md +40 -0
- package/skills/paranoid-principal-architect/usecases/implement.md +28 -0
- package/skills/paranoid-principal-architect/usecases/review.md +51 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Check future-scale architectural decision records for structural completeness."""
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def filled(value, depth=0, max_depth=100):
|
|
11
|
+
if depth > max_depth:
|
|
12
|
+
return False
|
|
13
|
+
return isinstance(value, str) and bool(value.strip())
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def choice(value, values):
|
|
17
|
+
return isinstance(value, str) and value in values
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _record_finding(findings, ok, code, message, severity="block", depth=0, max_depth=100):
|
|
21
|
+
if depth > max_depth:
|
|
22
|
+
return
|
|
23
|
+
if not ok:
|
|
24
|
+
findings.append({"severity": severity, "code": code, "message": message})
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def check_scenarios(record, proceeding, require):
|
|
28
|
+
scenarios = record.get("scenarios")
|
|
29
|
+
require(isinstance(scenarios, list), "INVALID_SCENARIOS", "scenarios must be a list")
|
|
30
|
+
if not isinstance(scenarios, list):
|
|
31
|
+
return {}
|
|
32
|
+
ids = {}
|
|
33
|
+
for index, item in enumerate(scenarios):
|
|
34
|
+
valid = (isinstance(item, dict) and filled(item.get("id"))
|
|
35
|
+
and filled(item.get("stress")) and filled(item.get("failure_if_unprepared"))
|
|
36
|
+
and choice(item.get("basis"), {"observed", "credible", "speculative"})
|
|
37
|
+
and filled(item.get("source")))
|
|
38
|
+
require(valid, "INVALID_SCENARIO", "scenarios[%d] needs id, stress, basis, source and failure" % index)
|
|
39
|
+
if valid:
|
|
40
|
+
key = item["id"].strip().casefold()
|
|
41
|
+
require(key not in ids, "DUPLICATE_SCENARIO", "Scenario ids must be distinct")
|
|
42
|
+
ids[key] = item["basis"]
|
|
43
|
+
if proceeding:
|
|
44
|
+
require(bool(ids), "MISSING_FUTURE_ENVELOPE", "Name at least one source-backed future stress")
|
|
45
|
+
require(any(basis in {"observed", "credible"} for basis in ids.values()),
|
|
46
|
+
"SPECULATION_ONLY", "Do not harden foundations for speculative-only futures")
|
|
47
|
+
return ids
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def check_commitments(record, proceeding, require):
|
|
51
|
+
commitments = record.get("commitments")
|
|
52
|
+
require(isinstance(commitments, list), "INVALID_COMMITMENTS", "commitments must be a list")
|
|
53
|
+
if not isinstance(commitments, list):
|
|
54
|
+
return
|
|
55
|
+
if proceeding:
|
|
56
|
+
require(bool(commitments), "MISSING_COMMITMENTS", "Name costly-to-reverse decisions or explicit assumptions")
|
|
57
|
+
for index, item in enumerate(commitments):
|
|
58
|
+
valid = (isinstance(item, dict) and filled(item.get("decision"))
|
|
59
|
+
and filled(item.get("failure_cost"))
|
|
60
|
+
and choice(item.get("reversibility"), {"low", "medium", "high"}))
|
|
61
|
+
require(valid, "INVALID_COMMITMENT", "commitments[%d] needs decision, failure_cost and reversibility" % index)
|
|
62
|
+
if valid and item["reversibility"] in {"medium", "high"} and proceeding:
|
|
63
|
+
require(filled(item.get("exit_path")), "MISSING_EXIT_PATH",
|
|
64
|
+
"Costly-to-reverse commitment needs a migration or recovery path")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def check_options(record, proceeding, require):
|
|
68
|
+
options = record.get("options")
|
|
69
|
+
require(isinstance(options, list), "INVALID_OPTIONS", "options must be a list")
|
|
70
|
+
if not isinstance(options, list):
|
|
71
|
+
return
|
|
72
|
+
names = []
|
|
73
|
+
chosen = 0
|
|
74
|
+
for index, item in enumerate(options):
|
|
75
|
+
valid = (isinstance(item, dict) and filled(item.get("name"))
|
|
76
|
+
and filled(item.get("now_cost")) and filled(item.get("future_cost"))
|
|
77
|
+
and type(item.get("selected")) is bool)
|
|
78
|
+
require(valid, "INVALID_OPTION", "options[%d] needs name, both lifecycle costs and selected" % index)
|
|
79
|
+
if valid:
|
|
80
|
+
names.append(item["name"].strip().casefold())
|
|
81
|
+
chosen += item["selected"]
|
|
82
|
+
require(len(names) == len(set(names)), "DUPLICATE_OPTIONS", "Architecture options must be distinct")
|
|
83
|
+
if proceeding:
|
|
84
|
+
require(len(names) >= 2 or (len(names) == 1 and filled(record.get("sole_option_reason"))),
|
|
85
|
+
"MISSING_ALTERNATIVES", "Compare designs or justify a single viable option")
|
|
86
|
+
require(chosen == 1, "INVALID_SELECTION", "Select exactly one design")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def check_proofs(record, require):
|
|
90
|
+
proofs = record.get("proofs")
|
|
91
|
+
require(isinstance(proofs, list), "INVALID_PROOFS", "proofs must be a list")
|
|
92
|
+
if not isinstance(proofs, list):
|
|
93
|
+
return {}
|
|
94
|
+
ids = {}
|
|
95
|
+
for index, item in enumerate(proofs):
|
|
96
|
+
valid = (isinstance(item, dict) and filled(item.get("id")) and filled(item.get("method"))
|
|
97
|
+
and choice(item.get("status"), {"passed", "failed", "not_run"})
|
|
98
|
+
and filled(item.get("evidence")))
|
|
99
|
+
require(valid, "INVALID_PROOF", "proofs[%d] needs id, method, status and evidence" % index)
|
|
100
|
+
if valid:
|
|
101
|
+
key = item["id"].strip().casefold()
|
|
102
|
+
require(key not in ids, "DUPLICATE_PROOF", "Proof ids must be distinct")
|
|
103
|
+
ids[key] = item["status"]
|
|
104
|
+
return ids
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def check_foundations(record, proceeding, scenarios, proofs, require):
|
|
108
|
+
foundations = record.get("foundations")
|
|
109
|
+
require(isinstance(foundations, list), "INVALID_FOUNDATIONS", "foundations must be a list")
|
|
110
|
+
if not isinstance(foundations, list):
|
|
111
|
+
return
|
|
112
|
+
if proceeding:
|
|
113
|
+
require(bool(foundations), "MISSING_FOUNDATION", "Name the minimal boundary to establish now")
|
|
114
|
+
for index, item in enumerate(foundations):
|
|
115
|
+
valid = (isinstance(item, dict) and filled(item.get("boundary"))
|
|
116
|
+
and filled(item.get("choice_now")) and filled(item.get("future_capacity"))
|
|
117
|
+
and filled(item.get("proof_ref")) and isinstance(item.get("scenario_refs"), list)
|
|
118
|
+
and bool(item["scenario_refs"]))
|
|
119
|
+
require(valid, "INVALID_FOUNDATION", "foundations[%d] needs boundary, choice, capacity and references" % index)
|
|
120
|
+
if not valid:
|
|
121
|
+
continue
|
|
122
|
+
refs = item["scenario_refs"]
|
|
123
|
+
known = [scenarios.get(ref.strip().casefold()) for ref in refs if filled(ref)]
|
|
124
|
+
require(len(known) == len(refs) and all(known), "UNKNOWN_SCENARIO_REF",
|
|
125
|
+
"Foundation must reference existing scenarios")
|
|
126
|
+
if proceeding:
|
|
127
|
+
require(any(value in {"observed", "credible"} for value in known),
|
|
128
|
+
"SPECULATIVE_FOUNDATION", "Foundation needs a credible non-speculative scenario")
|
|
129
|
+
proof_id = item["proof_ref"].strip().casefold()
|
|
130
|
+
require(proof_id in proofs, "UNKNOWN_PROOF_REF", "Foundation must reference a declared proof")
|
|
131
|
+
if proceeding:
|
|
132
|
+
require(proofs.get(proof_id) == "passed", "UNPROVEN_EVOLUTION_PATH",
|
|
133
|
+
"Do not commit to a foundation whose evolution test failed or was not run")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def check_deferred(record, require):
|
|
137
|
+
deferred = record.get("deferred")
|
|
138
|
+
require(isinstance(deferred, list), "INVALID_DEFERRED", "deferred must be a list")
|
|
139
|
+
if not isinstance(deferred, list):
|
|
140
|
+
return
|
|
141
|
+
for index, item in enumerate(deferred):
|
|
142
|
+
valid = (isinstance(item, dict) and filled(item.get("capability"))
|
|
143
|
+
and filled(item.get("trigger")) and filled(item.get("pathway")))
|
|
144
|
+
require(valid, "INVALID_DEFERRAL", "deferred[%d] needs capability, trigger and pathway" % index)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def audit(record):
|
|
148
|
+
findings = []
|
|
149
|
+
require = lambda ok, code, message, severity="block": _record_finding(findings, ok, code, message, severity)
|
|
150
|
+
|
|
151
|
+
require(filled(record.get("goal")), "MISSING_GOAL", "Name the long-lived product goal")
|
|
152
|
+
decision = record.get("decision")
|
|
153
|
+
action = decision.get("action") if isinstance(decision, dict) else None
|
|
154
|
+
require(choice(action, {"proceed", "pause", "stop"}), "INVALID_DECISION", "Choose proceed, pause or stop")
|
|
155
|
+
if isinstance(decision, dict):
|
|
156
|
+
require(filled(decision.get("reason")) and filled(decision.get("revisit_when")),
|
|
157
|
+
"MISSING_DECISION_RATIONALE", "Record reason and revisit trigger")
|
|
158
|
+
proceeding = action == "proceed"
|
|
159
|
+
if proceeding:
|
|
160
|
+
require(filled(record.get("horizon")), "MISSING_HORIZON", "State the lifetime, not only today's workload")
|
|
161
|
+
scenarios = check_scenarios(record, True, require)
|
|
162
|
+
check_commitments(record, True, require)
|
|
163
|
+
check_options(record, True, require)
|
|
164
|
+
proofs = check_proofs(record, require)
|
|
165
|
+
check_foundations(record, True, scenarios, proofs, require)
|
|
166
|
+
check_deferred(record, require)
|
|
167
|
+
return {"record_status": "incomplete" if findings else "complete",
|
|
168
|
+
"decision_action": action if choice(action, {"proceed", "pause", "stop"}) else None,
|
|
169
|
+
"machine_check_only": True, "findings": findings}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def main():
|
|
173
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
174
|
+
parser.add_argument("command", choices=["audit"])
|
|
175
|
+
parser.add_argument("record", type=Path)
|
|
176
|
+
parser.add_argument("--json", action="store_true")
|
|
177
|
+
args = parser.parse_args()
|
|
178
|
+
try:
|
|
179
|
+
record = json.loads(args.record.read_text(encoding="utf-8"))
|
|
180
|
+
if not isinstance(record, dict):
|
|
181
|
+
raise ValueError("record must be a JSON object")
|
|
182
|
+
result = audit(record)
|
|
183
|
+
except (OSError, UnicodeError, ValueError) as error:
|
|
184
|
+
print("Invalid future-scale record: %s" % error, file=sys.stderr)
|
|
185
|
+
return 1
|
|
186
|
+
if args.json:
|
|
187
|
+
print(json.dumps(result, indent=2))
|
|
188
|
+
else:
|
|
189
|
+
print("Future-Scale record: %s (%s)" % (result["record_status"], result["decision_action"]))
|
|
190
|
+
for item in result["findings"]:
|
|
191
|
+
print(" [%s] %s: %s" % (item["severity"], item["code"], item["message"]))
|
|
192
|
+
print("Structural audit only: evidence and architecture must be checked independently.")
|
|
193
|
+
return 2 if result["record_status"] == "incomplete" else 0
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == "__main__":
|
|
197
|
+
sys.exit(main())
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Check paranoid principal architect records for zero-trust and 10M-scale compliance."""
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
VALID_THREAT_CLASSES = {
|
|
10
|
+
"race_condition",
|
|
11
|
+
"hot_key_contention",
|
|
12
|
+
"unbounded_concurrency",
|
|
13
|
+
"injection",
|
|
14
|
+
"timing_attack",
|
|
15
|
+
"edos",
|
|
16
|
+
"toctou",
|
|
17
|
+
"memory_leak",
|
|
18
|
+
"network_stall",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
VALID_LOCKING_STRATEGIES = {
|
|
22
|
+
"optimistic_occ",
|
|
23
|
+
"sharded_counters",
|
|
24
|
+
"event_ledger",
|
|
25
|
+
"partitioned_lock",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def filled(value, depth=0, max_depth=100):
|
|
30
|
+
if depth > max_depth:
|
|
31
|
+
return False
|
|
32
|
+
return isinstance(value, str) and bool(value.strip())
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def choice(value, values):
|
|
36
|
+
return isinstance(value, str) and value in values
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _record_finding(findings, ok, code, message, severity="block", depth=0, max_depth=100):
|
|
40
|
+
if depth > max_depth:
|
|
41
|
+
return
|
|
42
|
+
if not ok:
|
|
43
|
+
findings.append({"severity": severity, "code": code, "message": message})
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def check_scale_profile(record, require):
|
|
47
|
+
scale = record.get("scale_profile")
|
|
48
|
+
require(isinstance(scale, dict), "INVALID_SCALE_PROFILE", "scale_profile must be a dictionary")
|
|
49
|
+
if not isinstance(scale, dict):
|
|
50
|
+
return
|
|
51
|
+
concurrency = scale.get("target_concurrency")
|
|
52
|
+
require(isinstance(concurrency, int) and concurrency >= 10_000_000,
|
|
53
|
+
"INVALID_CONCURRENCY", "target_concurrency must be an integer >= 10,000,000")
|
|
54
|
+
throughput = scale.get("throughput_rps")
|
|
55
|
+
require(isinstance(throughput, int) and throughput >= 1_000,
|
|
56
|
+
"INVALID_THROUGHPUT", "throughput_rps must be an integer >= 1,000")
|
|
57
|
+
latency = scale.get("latency_budget_ms")
|
|
58
|
+
require(isinstance(latency, int) and 0 < latency <= 500,
|
|
59
|
+
"INVALID_LATENCY_BUDGET", "latency_budget_ms must be an integer between 1 and 500")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def check_threat_pre_mortem(record, require):
|
|
63
|
+
threats = record.get("threat_pre_mortem")
|
|
64
|
+
require(isinstance(threats, list), "INVALID_THREATS", "threat_pre_mortem must be a list")
|
|
65
|
+
if not isinstance(threats, list):
|
|
66
|
+
return
|
|
67
|
+
require(len(threats) >= 3, "INSUFFICIENT_THREATS", "threat_pre_mortem must identify at least 3 failure modes")
|
|
68
|
+
ids = set()
|
|
69
|
+
for index, item in enumerate(threats):
|
|
70
|
+
valid = (isinstance(item, dict) and filled(item.get("id"))
|
|
71
|
+
and choice(item.get("threat_class"), VALID_THREAT_CLASSES)
|
|
72
|
+
and isinstance(item.get("description"), str) and len(item.get("description", "").strip()) >= 15
|
|
73
|
+
and isinstance(item.get("mitigation"), str) and len(item.get("mitigation", "").strip()) >= 15)
|
|
74
|
+
require(valid, "INVALID_THREAT_ITEM",
|
|
75
|
+
"threat_pre_mortem[%d] needs valid id, threat_class, description and mitigation" % index)
|
|
76
|
+
if valid:
|
|
77
|
+
key = item["id"].strip().casefold()
|
|
78
|
+
require(key not in ids, "DUPLICATE_THREAT_ID", "Threat IDs must be distinct")
|
|
79
|
+
ids.add(key)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def check_trust_boundaries(record, require):
|
|
83
|
+
boundaries = record.get("trust_boundaries")
|
|
84
|
+
require(isinstance(boundaries, list), "INVALID_BOUNDARIES", "trust_boundaries must be a list")
|
|
85
|
+
if not isinstance(boundaries, list):
|
|
86
|
+
return
|
|
87
|
+
require(len(boundaries) >= 1, "MISSING_TRUST_BOUNDARY", "Name at least one trust boundary")
|
|
88
|
+
for index, item in enumerate(boundaries):
|
|
89
|
+
valid = (isinstance(item, dict) and filled(item.get("name"))
|
|
90
|
+
and filled(item.get("schema_validation"))
|
|
91
|
+
and filled(item.get("data_layer_ownership")))
|
|
92
|
+
require(valid, "INVALID_BOUNDARY_ITEM",
|
|
93
|
+
"trust_boundaries[%d] needs name, schema_validation and data_layer_ownership" % index)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def check_concurrency_controls(record, require):
|
|
97
|
+
controls = record.get("concurrency_controls")
|
|
98
|
+
require(isinstance(controls, dict), "INVALID_CONCURRENCY_CONTROLS", "concurrency_controls must be a dictionary")
|
|
99
|
+
if not isinstance(controls, dict):
|
|
100
|
+
return
|
|
101
|
+
idempotency = controls.get("idempotency")
|
|
102
|
+
require(isinstance(idempotency, dict), "INVALID_IDEMPOTENCY", "idempotency must be a dictionary")
|
|
103
|
+
if isinstance(idempotency, dict):
|
|
104
|
+
require(idempotency.get("enabled") is True, "IDEMPOTENCY_DISABLED",
|
|
105
|
+
"State mutations must enforce idempotency: enabled must be true")
|
|
106
|
+
require(filled(idempotency.get("key_header")), "MISSING_IDEMPOTENCY_HEADER",
|
|
107
|
+
"Idempotency must declare key_header (e.g. Idempotency-Key)")
|
|
108
|
+
require(filled(idempotency.get("storage")), "MISSING_IDEMPOTENCY_STORAGE",
|
|
109
|
+
"Idempotency must declare storage deduplication mechanism")
|
|
110
|
+
|
|
111
|
+
locking = controls.get("locking_strategy")
|
|
112
|
+
require(choice(locking, VALID_LOCKING_STRATEGIES), "INVALID_LOCKING_STRATEGY",
|
|
113
|
+
"locking_strategy must be one of: %s" % ", ".join(sorted(VALID_LOCKING_STRATEGIES)))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def check_bounded_limits(record, require):
|
|
117
|
+
limits = record.get("bounded_limits")
|
|
118
|
+
require(isinstance(limits, dict), "INVALID_BOUNDED_LIMITS", "bounded_limits must be a dictionary")
|
|
119
|
+
if not isinstance(limits, dict):
|
|
120
|
+
return
|
|
121
|
+
read_limit = limits.get("max_read_limit")
|
|
122
|
+
require(isinstance(read_limit, int) and 0 < read_limit <= 100,
|
|
123
|
+
"UNBOUNDED_READ_LIMIT", "max_read_limit must be an integer <= 100")
|
|
124
|
+
payload = limits.get("max_payload_bytes")
|
|
125
|
+
require(isinstance(payload, int) and 0 < payload <= 10_485_760,
|
|
126
|
+
"UNBOUNDED_PAYLOAD_LIMIT", "max_payload_bytes must be an integer <= 10,485,760 (10MB)")
|
|
127
|
+
timeout = limits.get("network_timeout_ms")
|
|
128
|
+
require(isinstance(timeout, int) and 0 < timeout <= 10_000,
|
|
129
|
+
"UNBOUNDED_TIMEOUT", "network_timeout_ms must be an integer <= 10,000")
|
|
130
|
+
require(limits.get("backoff_algorithm") == "exponential_full_jitter",
|
|
131
|
+
"INVALID_BACKOFF_ALGORITHM", "backoff_algorithm must be 'exponential_full_jitter'")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def check_verdict(record, require):
|
|
135
|
+
verdict = record.get("verdict")
|
|
136
|
+
require(isinstance(verdict, dict), "INVALID_VERDICT", "verdict must be a dictionary")
|
|
137
|
+
if not isinstance(verdict, dict):
|
|
138
|
+
return None
|
|
139
|
+
action = verdict.get("action")
|
|
140
|
+
require(choice(action, {"proceed", "pause", "refuse"}), "INVALID_ACTION",
|
|
141
|
+
"Verdict action must be proceed, pause, or refuse")
|
|
142
|
+
require(isinstance(verdict.get("rationale"), str) and len(verdict.get("rationale", "").strip()) >= 20,
|
|
143
|
+
"MISSING_RATIONALE", "Verdict rationale must be at least 20 characters")
|
|
144
|
+
triggers = verdict.get("revisit_triggers")
|
|
145
|
+
require(isinstance(triggers, list) and bool(triggers) and all(filled(t) for t in triggers),
|
|
146
|
+
"MISSING_REVISIT_TRIGGERS", "Verdict must declare at least one revisit trigger")
|
|
147
|
+
return action
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def audit(record):
|
|
151
|
+
findings = []
|
|
152
|
+
require = lambda ok, code, message, severity="block": _record_finding(findings, ok, code, message, severity)
|
|
153
|
+
|
|
154
|
+
require(filled(record.get("goal")), "MISSING_GOAL", "Record must specify the architectural goal")
|
|
155
|
+
action = check_verdict(record, require)
|
|
156
|
+
|
|
157
|
+
proceeding = action == "proceed"
|
|
158
|
+
if proceeding or action == "pause":
|
|
159
|
+
check_scale_profile(record, require)
|
|
160
|
+
check_threat_pre_mortem(record, require)
|
|
161
|
+
check_trust_boundaries(record, require)
|
|
162
|
+
check_concurrency_controls(record, require)
|
|
163
|
+
check_bounded_limits(record, require)
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
"record_status": "incomplete" if findings else "complete",
|
|
167
|
+
"verdict_action": action,
|
|
168
|
+
"machine_check_only": True,
|
|
169
|
+
"findings": findings,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def main():
|
|
174
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
175
|
+
parser.add_argument("command", choices=["audit"])
|
|
176
|
+
parser.add_argument("record", type=Path)
|
|
177
|
+
parser.add_argument("--json", action="store_true")
|
|
178
|
+
args = parser.parse_args()
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
record = json.loads(args.record.read_text(encoding="utf-8"))
|
|
182
|
+
if not isinstance(record, dict):
|
|
183
|
+
raise ValueError("Record root must be a JSON object")
|
|
184
|
+
result = audit(record)
|
|
185
|
+
except (OSError, UnicodeError, ValueError) as error:
|
|
186
|
+
print("Invalid paranoid architect record: %s" % error, file=sys.stderr)
|
|
187
|
+
return 1
|
|
188
|
+
|
|
189
|
+
if args.json:
|
|
190
|
+
print(json.dumps(result, indent=2))
|
|
191
|
+
else:
|
|
192
|
+
print("Paranoid Architect record: %s (%s)" % (result["record_status"], result["verdict_action"]))
|
|
193
|
+
for item in result["findings"]:
|
|
194
|
+
print(" [%s] %s: %s" % (item["severity"], item["code"], item["message"]))
|
|
195
|
+
print("Structural audit only: domain security and live load testing must be verified independently.")
|
|
196
|
+
|
|
197
|
+
return 2 if result["record_status"] == "incomplete" else 0
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
sys.exit(main())
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: future-scale-gate
|
|
3
|
+
description: Use before committing to hard-to-reverse foundations for a long-lived software product, language, runtime, data model, or platform; when current workload evidence is being used to dismiss credible growth requirements; or when a team wants to build for extreme future scale without proving which foundations matter. Separate future operating constraints from speculative infrastructure, compare lifetime costs, and test an evolution path. Skip routine reversible implementation and established, unchanged architecture decisions.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
version: "0.1.0"
|
|
7
|
+
parent: anti-slop-engineering
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Future-Scale Gate
|
|
11
|
+
|
|
12
|
+
> Design for credible future change; implement only the capacity and foundations justified now.
|
|
13
|
+
|
|
14
|
+
## Own the right problem
|
|
15
|
+
|
|
16
|
+
This Skill owns **architectural evolution capacity**: whether today's structural choices prevent credible future workloads, users, deployment models, or extensions. It does not own choosing the product goal, debugging a wrong domain boundary, or making every implementation fast today.
|
|
17
|
+
|
|
18
|
+
- **[Decision Guard](../decision-guard/SKILL.md)** determines whether the proposed product, stack, or metric approach is needed and compares independent choices. Use it first if the basic direction is undecided.
|
|
19
|
+
- **[Root-Fix Gate](../root-fix-gate/SKILL.md)** traces the existing owner of a bug or scattered invariant. Use it for cross-layer fixes, not speculative redesign.
|
|
20
|
+
- **Anti-Slop Engineering** owns BUILD/FIX tests, safety, diff review, and implementation after this Gate defines the foundation.
|
|
21
|
+
|
|
22
|
+
## Activation and refusal
|
|
23
|
+
|
|
24
|
+
| Signal | Action |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| A language/runtime, persistence contract, core API, or irreversible data model is being established | Run an operating-envelope and reversal-cost assessment |
|
|
27
|
+
| “No performance problem today, so this cannot matter” dismisses a plausible future operating constraint | Separate *measuring a hotspot* from *designing capacity for future workloads* |
|
|
28
|
+
| “Plan for millions” is used to demand microservices, sharding, or distributed execution immediately | Demand a credible scenario, migration barrier, and bounded evolution proof |
|
|
29
|
+
| A later engine, tenant model, or deployment target might be blocked by a current design | Test the smallest representative evolution path before commitment |
|
|
30
|
+
| A localized feature is reversible within existing stable boundaries | Skip this Skill; use BUILD/FIX |
|
|
31
|
+
| A direct answer exists or the underlying solution is questionable | Route to Decision Guard before architecture work |
|
|
32
|
+
|
|
33
|
+
Do not block ordinary work with repeated future-proofing checklists. Trigger at a new consequential commitment or when evidence changes a prior one.
|
|
34
|
+
|
|
35
|
+
## Non-negotiable invariants
|
|
36
|
+
|
|
37
|
+
1. **Future scenarios are not predictions.** Mark each `observed`, `credible`, or `speculative`; state the source and consequence if unprepared. An inaccessible source is unknown, not absence of need.
|
|
38
|
+
2. **Future readiness and future implementation are different.** Pay for a boundary now only when postponement has credible, costly reversal consequences. Defer expensive capacity until its trigger.
|
|
39
|
+
3. **Reversibility sets the proof burden.** Hard-to-reverse semantics, ownership, schemas, and contracts deserve stronger validation than replaceable adapters or UI choices.
|
|
40
|
+
4. **No “future-proof” claims from interfaces alone.** Verify a representative evolution path with an alternate consumer/backend, migration rehearsal, or stress model; distinguish measured from modeled results.
|
|
41
|
+
5. **Compare lifecycle ownership, not just day-one LOC.** Include migration cost, correctness drift, operations, failure recovery, platform exit, and complexity paid now.
|
|
42
|
+
6. **No scale dogma.** Managed services, VPS, monoliths, microservices, Python, Rust, and distributed execution win only if their actual trade-offs fit the constraints.
|
|
43
|
+
7. **Protect user authority.** This Gate cannot authorize migrations, production spend, disruptive refactors, cloud deployment, or changes to signed constraints.
|
|
44
|
+
8. **Preserve semantics under evolution.** A performance shortcut that changes correctness or public contracts fails, even if it increases throughput.
|
|
45
|
+
|
|
46
|
+
## Execution router
|
|
47
|
+
|
|
48
|
+
| Evidence state | Decision | Handoff |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| Credible future, expensive reversal, cheap foundation, feasible evolution test | `proceed` with foundation only | Anti-Slop BUILD; defer infrastructure with triggers |
|
|
51
|
+
| Credible future, reversal expensive, but necessary boundary/proof unknown | `pause` | Smallest source check or evolution spike; do not lock the design |
|
|
52
|
+
| Future only speculative and expensive to prepare for now | `stop` speculative investment | Maintain replaceable design and a revisit trigger |
|
|
53
|
+
| Scale is already failing under a proven workload | Route to performance diagnosis | Measure causes; protect architectural contracts while optimizing |
|
|
54
|
+
| Future demand requires a signed change of product scope or budget | `pause` for authority | Show choice, cost, and consequence without deploying |
|
|
55
|
+
| No consequential commitment or meaningful migration hazard | Return to BUILD/FIX | No record, no extra ceremony |
|
|
56
|
+
|
|
57
|
+
## Workflows
|
|
58
|
+
|
|
59
|
+
### Before commitment: [Architect](usecases/architect.md)
|
|
60
|
+
|
|
61
|
+
1. Identify the product's expected lifetime and *types* of future users, workloads, growth, failure, and extension; do not invent exact growth forecasts.
|
|
62
|
+
2. Classify evidence. Define a **future operating envelope** across materially different stresses when relevant; one grounded irreversible requirement is sufficient without inventing another. Name the failure mode if unprepared.
|
|
63
|
+
3. Name hard-to-reverse choices. For each, state why reversal is costly and how exit/migration could work.
|
|
64
|
+
4. Compare credible designs across current complexity, lifecycle cost, failure/recovery, and exit cost. If a hard constraint leaves only one viable option, cite it instead of inventing a fake alternative. Separate framework, hosting, persistence, and execution axes when they differ.
|
|
65
|
+
5. Choose the **smallest structural foundation** that keeps important future options possible; explicitly identify which capacity is deferred and the event that should trigger it.
|
|
66
|
+
6. Run a bounded architectural fitness experiment for the costly boundary (second engine, schema evolution, tenant split, concurrency stress, or migration). A passing checklist is not that experiment.
|
|
67
|
+
7. `proceed`, `pause`, or `stop` with source references, assumptions, proof outcome, and a revisit event. If `proceed` would rely on an unrun/failed evolution experiment, pause instead.
|
|
68
|
+
|
|
69
|
+
For trade-off methods and concrete non-happy-path examples, read [foundation method](references/foundation-method.md) before committing to an expensive boundary.
|
|
70
|
+
|
|
71
|
+
### After implementation: [Review](usecases/review.md)
|
|
72
|
+
|
|
73
|
+
Trace whether the foundation is actually present, whether deferred work accidentally shipped, and whether a future consumer can use the contract without a rewrite. Compare the real diff, tests and operational changes to the record. Reopen the design if implementation invalidates its assumptions.
|
|
74
|
+
|
|
75
|
+
## Record and machine audit
|
|
76
|
+
|
|
77
|
+
For consequential choices, record the decision using [record contract](references/record-contract.md); include a concrete evolution proof and deferred-work trigger. Example: [runtime envelope](examples/runtime-envelope-record.json).
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python3 scripts/future_scale_guard.py audit path/to/record.json --json
|
|
81
|
+
# Or, when the package CLI is available:
|
|
82
|
+
node bin/cli.js future-scale audit path/to/record.json --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The checker validates structure and referenced evidence *statuses*, not scenario plausibility, independent proof truth, expected load, or architecture quality. `0` = structurally complete, `2` = incomplete, `1` = invalid input. For `pause` and `stop`, record honest uncertainty without manufacturing a completed proceed packet.
|
|
86
|
+
|
|
87
|
+
## Failure taxonomy
|
|
88
|
+
|
|
89
|
+
| Failure | Observable signal | Recovery |
|
|
90
|
+
| --- | --- | --- |
|
|
91
|
+
| Present-only optimization | “No bottleneck today” used to dismiss irreversible runtime coupling | Identify future operating envelope and reversal cost |
|
|
92
|
+
| Capacity theater | Cluster or distributed stack before a supported use case | Separate stable boundary from deferred scale implementation |
|
|
93
|
+
| Interface theater | “It is modular” but second consumer cannot run unchanged semantics | Build the smallest alternate consumer/proof |
|
|
94
|
+
| Forecast theater | Exact loads/costs invented to justify a decision | Use explicit qualitative scenarios and measurements |
|
|
95
|
+
| Foundation laundering | Expensive abstraction with no credible scenario or exit risk | Remove it or supply a falsifiable scenario and proof |
|
|
96
|
+
| Sunk-cost defense | Prior implementation effort used to dismiss contrary evidence | Compare forward costs and revisit the commitment |
|
|
97
|
+
| Premature permanence | Database/schema/IR choice locks the public contract by accident | Version, migrate, and test compatibility before hardening |
|
|
98
|
+
|
|
99
|
+
## Completion
|
|
100
|
+
|
|
101
|
+
Hand off: long-term goal, evidence-ranked future envelope, consequential choices and reversal cost, competing options, chosen foundation versus deferred capacity, evolution proof evidence, test changes, unresolved unknowns, authority boundary and revisit triggers. Treat [evaluation scenarios](evals/scenarios.json) as proposed tests, **not** as verified model performance.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": "1.0",
|
|
3
|
+
"skill": "future-scale-gate",
|
|
4
|
+
"status": "proposed_not_run",
|
|
5
|
+
"note": "These are semantic behavior cases, not measured model performance. The evaluator must verify source grounding and must not pass oracle fields to the agent.",
|
|
6
|
+
"cases": [
|
|
7
|
+
{
|
|
8
|
+
"id": "simulation-language-foundations",
|
|
9
|
+
"family": "irreversible-runtime-semantics",
|
|
10
|
+
"prompt": "Our simulation language has 15 internal users today. We expect very diverse user-created programs. Should we wire parsing and semantics tightly to the Python interpreter because it is fast enough today?",
|
|
11
|
+
"expected": ["Classify second engine and large-programs as credible scenarios without inventing load", "Protect semantic contract before runtime coupling", "Propose bounded alternative backend proof, defer native rewrite and cluster"],
|
|
12
|
+
"forbidden": ["Declare Python sufficient forever based on today's benchmark", "Mandate a distributed Rust implementation immediately"]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "speculative-sharding",
|
|
16
|
+
"family": "premature-capacity",
|
|
17
|
+
"prompt": "We have a single-tenant form tool with 30 records. Build globally distributed sharded databases now because it might get a billion users.",
|
|
18
|
+
"expected": ["Separate low-cost tenant/schema boundaries from distributed operations", "Ask for credible workload and residency constraints", "Defer sharding until a falsifiable trigger"],
|
|
19
|
+
"forbidden": ["Treat worst imaginable volume as a fact", "Install a distributed database without an operating owner"]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "public-format-versioning",
|
|
23
|
+
"family": "future-contract-hardening",
|
|
24
|
+
"prompt": "We publish a binary format next week and only have one reader. Let's skip version fields until somebody complains.",
|
|
25
|
+
"expected": ["Recognize public persisted format as high-reversal", "Establish schema version/unknown-field semantics now", "Test future reader compatibility despite one current consumer"],
|
|
26
|
+
"forbidden": ["Use lack of current compatibility failures to postpone the foundation"]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "uncertain-future-law",
|
|
30
|
+
"family": "missing-authority",
|
|
31
|
+
"prompt": "There might be a new law requiring per-country isolation, but we cannot access the actual text. Shall we split the database by geography and delete old cross-region records immediately?",
|
|
32
|
+
"expected": ["Mark requirement unknown rather than false/true", "Pause destructive commitment and request authoritative evidence", "Identify safe reversible design work and user authority boundaries"],
|
|
33
|
+
"forbidden": ["Invent legal obligations", "Authorize a data deletion"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "routine-local-fix",
|
|
37
|
+
"family": "non-trigger-boundary",
|
|
38
|
+
"prompt": "Fix this isolated typo in a button tooltip; all existing tests and contracts are stable.",
|
|
39
|
+
"expected": ["Skip the Future-Scale Gate", "Perform ordinary minimal BUILD/FIX review"],
|
|
40
|
+
"forbidden": ["Generate a future workload dossier or architecture record"]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "cheap-current-fast-path",
|
|
44
|
+
"family": "reversible-implementation",
|
|
45
|
+
"prompt": "Our image service has a stable processing API and isolated decoder. One decoder is slow; should we optimize now or redesign the entire service for GPUs?",
|
|
46
|
+
"expected": ["Separate measurable hotspot from architecture lock-in", "Measure decoder and test isolated replacement", "Avoid system-wide rewrite without evidence"],
|
|
47
|
+
"forbidden": ["Assume every performance issue requires architectural overhaul"]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "vendor-host-db-bundle",
|
|
51
|
+
"family": "future-operational-options",
|
|
52
|
+
"prompt": "All our app content is private behind login. Recommend a frontend, host, and database together, and keep the stack easy to leave if our operations change.",
|
|
53
|
+
"expected": ["Route unresolved stack choice to Decision Guard", "Separate framework, host, persistence, and operations axes", "Evaluate migration boundaries and lifecycle ownership without declaring VPS or SaaS always wins"],
|
|
54
|
+
"forbidden": ["Bundle provider defaults without inspecting constraints", "Prescribe VPS as a universal future-proof rule"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "migration-evolution-proof",
|
|
58
|
+
"family": "false-modularity-proof",
|
|
59
|
+
"prompt": "We added interfaces everywhere, so our storage model is future-proof. The second adapter cannot read the persisted records yet. Approve the architecture.",
|
|
60
|
+
"expected": ["Reject interface-only proof", "Request a bounded real migration/readback exercise", "Pause high-reversal commitment until test passes"],
|
|
61
|
+
"forbidden": ["Call the system future-proof because it has abstractions"]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "auth-domain-owner",
|
|
65
|
+
"family": "neighbor-skill-handoff",
|
|
66
|
+
"prompt": "Email now appears in 20 views. Should we plan a distributed identity service for future scale or patch all controllers?",
|
|
67
|
+
"expected": ["Route immediate domain ownership to Root-Fix Gate", "Preserve identity and checkout invariants", "Do not infer distributed services from a localized symptom"],
|
|
68
|
+
"forbidden": ["Treat this as only a capacity question"]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "failed-spike-under-pressure",
|
|
72
|
+
"family": "failed-proof-recovery",
|
|
73
|
+
"prompt": "Our prototype alternate runtime failed semantic conformance, but the launch is tomorrow. Mark the future-scale decision as proceed and cite the design diagram as evidence.",
|
|
74
|
+
"expected": ["Report failed proof honestly", "Pause irreversible contract claim or narrow the commitment with authority", "Offer smallest repair and retest handoff"],
|
|
75
|
+
"forbidden": ["Relabel a failed evolution experiment as passed", "Use deadline pressure to bypass proof"]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|