API reference¶
Package exports¶
akms_failure_memory
¶
Optional deterministic failure-memory workflows for AKMS projects.
ProjectConfig
dataclass
¶
ProjectConfig(
source_path: Path,
repository_id: str,
node_namespace: str,
domain: str,
subdomain: str,
paths: Mapping[str, str],
generated: Mapping[str, str],
validation: Mapping[str, Any],
taxonomy: Mapping[str, Any],
compatibility: Mapping[str, Any],
toolchain: Mapping[str, Any],
promotion: Mapping[str, Any],
canonical_data: Mapping[str, Any],
fingerprint: str,
)
Validated immutable project policy and its canonical fingerprint.
load_project_config
¶
Load a strict TOML configuration; duplicate keys fail in tomllib.
Source code in packages/akms_failure_memory/src/akms_failure_memory/config.py
Configuration¶
akms_failure_memory.config
¶
Strict loader for failure-memory-project/v1 TOML configuration.
ProjectConfig
dataclass
¶
ProjectConfig(
source_path: Path,
repository_id: str,
node_namespace: str,
domain: str,
subdomain: str,
paths: Mapping[str, str],
generated: Mapping[str, str],
validation: Mapping[str, Any],
taxonomy: Mapping[str, Any],
compatibility: Mapping[str, Any],
toolchain: Mapping[str, Any],
promotion: Mapping[str, Any],
canonical_data: Mapping[str, Any],
fingerprint: str,
)
Validated immutable project policy and its canonical fingerprint.
load_project_config
¶
Load a strict TOML configuration; duplicate keys fail in tomllib.
Source code in packages/akms_failure_memory/src/akms_failure_memory/config.py
Recording¶
akms_failure_memory.record
¶
One canonical recorder for interactive, machine, and direct-edit workflows.
add_lesson
¶
add_lesson(
*,
config_path: str | Path,
repository_root: str | Path,
global_vault: str | Path,
request_path: str | Path | None = None,
interactive: bool = False,
input_fn: Callable[[str], str] = input,
) -> dict[str, Any]
Allocate, validate, atomically publish, and compile one canonical record.
Source code in packages/akms_failure_memory/src/akms_failure_memory/record.py
Compiler¶
akms_failure_memory.compiler
¶
Configuration-driven deterministic lesson compiler and exact-route generator.
validate_registry_bytes
¶
validate_registry_bytes(
data: bytes, source: Path, config: ProjectConfig
) -> tuple[dict[str, Any], ...]
Validate the canonical append-only v1 registry without mutating it.
Source code in packages/akms_failure_memory/src/akms_failure_memory/compiler.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
run_compiler
¶
run_compiler(
*,
config_path: str | Path,
repository_root: str | Path,
global_vault: str | Path | None = None,
output_root: str | Path | None = None,
mode: str = "write",
) -> dict[str, Any]
Validate, compare, and atomically publish configured deterministic outputs.
Source code in packages/akms_failure_memory/src/akms_failure_memory/compiler.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |
Refresh¶
akms_failure_memory.refresh
¶
Pinned toolchain preflight and single-writer deterministic refresh.
preflight
¶
Check that the installed AKMS is usable and repo2md is callable.
This is deliberately NOT an identity check. It blocks on exactly two things:
- the installed AKMS schema version is incompatible with the project, and
- repo2md cannot be invoked with the export contract this package needs.
Both are conditions under which the next step genuinely cannot run.
Everything else — the AKMS version string, the AKMS public-API digest, and
the repo2md checkout version / commit / cleanliness / fixture digest — is
reported as an advisory and never raises. Those answer "is this the exact
artifact we certified?", which matters when publishing a release, not when a
developer is using the tool. Enforcing them on every resolve made ordinary,
correct edits to AKMS fail closed here, so pins got chased instead of code
getting fixed: the duplicated run_qmd.sh lookup in
akms.graph.generate_loadout survived precisely because removing it would
have tripped the public-API digest.
Advisories are returned under advisories so drift stays visible.
Publication paths that do need exact identity should compare these values
themselves rather than relying on this function to refuse.
Source code in packages/akms_failure_memory/src/akms_failure_memory/refresh.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
refresh_project
¶
refresh_project(
*,
action: str,
config_path: str | Path,
repository_root: str | Path,
global_vault: str | Path,
phase: int = 1,
generated_at: str | None = None,
force_lock: bool = False,
) -> dict[str, Any]
Run one refresh stage or the ordered lessons→mirror→graph chain.
Source code in packages/akms_failure_memory/src/akms_failure_memory/refresh.py
Provider¶
akms_failure_memory.provider
¶
Harness-neutral deterministic failure-memory provider contract.
load_provider_request
¶
Load and strictly validate one closed v1 provider request.
Source code in packages/akms_failure_memory/src/akms_failure_memory/provider.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
validate_publication
¶
Package-owned deterministic validation of the published graph.
Two published artifacts must agree: the graph and the generated project
node files it was built from. This verifies what is there — it never
re-derives the compiler's or the graph builder's rules — and it is the
single definition both consumers inherit through validate_fingerprint,
so neither has to (and neither may) mirror a package predicate.
Checks, all against this project's own namespace only:
- The graph carries this project's identity:
graph.repo_idequals the configuredrepository_id. Fingerprint reproducibility alone cannot see this — a graph published under a foreign identity reproduces consistently. - The project-namespaced nodes in the graph are exactly the published generated node files — a graph node with no published file behind it is fabricated content, and a published file missing from the graph is the ordinary "nodes were recompiled but the graph was not rebuilt" state.
- Every field the two artifacts share agrees, and every
load_withtarget a published node names is present in the graph, because resolution will read that content and try to load those targets.
Returns a list of human-readable problems; an empty list means the publication is internally consistent and carries this project's identity.
Source code in packages/akms_failure_memory/src/akms_failure_memory/provider.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
resolve_provider
¶
resolve_provider(
*,
config_path: str | Path,
repository_root: str | Path,
request_source: str | Path | Mapping[str, Any],
write_artifacts: bool = True,
) -> dict[str, Any]
Resolve one provider request using only pinned public AKMS services.
Source code in packages/akms_failure_memory/src/akms_failure_memory/provider.py
validate_fingerprint
¶
validate_fingerprint(
*,
config_path: str | Path,
repository_root: str | Path,
request_source: str | Path | Mapping[str, Any],
result_path: str | Path,
) -> dict[str, Any]
Recompute a result fingerprint without writing provider artifacts.
current requires BOTH that the recomputed fingerprint matches the
recorded one AND that :func:validate_publication finds the published
graph valid. Fingerprint reproducibility alone cannot notice a graph
published under a foreign repository identity, or a graph whose
project-namespaced nodes disagree with the published generated node files
— a consistently-wrong graph reproduces consistently — so those states
report stale (republish the graph), never current.