wip: shield index relations, dev evaluation tasks, Q-063 audit notes
Verifier borrow/provenance work, new phase3 shield_index conformance cases, dev-intervals/dev-lru/dev-shards tasks with evaluate.py harness, and agent skill/hook config.
This commit is contained in:
1 parent
2d750a0525
commit
e3fc896a0a
68 files changed
+2132
-37
No files matched your search
@@ -367,3 +367,120 @@ Reproduction and qualification artifacts are retained in
|
||||
`conformance.jsonl`, CLI-suite logs and `qualification.json` with source and
|
||||
executable hashes. The reproducible targeted test is
|
||||
`python3 tests/hosted/source_loop_exit.py`.
|
||||
|
||||
## Third optimization: indexed resource relations (2026-10-14)
|
||||
|
||||
`provenance.State` now keeps an insertion-ordered active list, endpoint
|
||||
adjacency lists and lists by relation kind. A fact retains its complete
|
||||
identity: kind, both value IDs and the loan's spawn span. Duplicate insertion
|
||||
keeps the original position. `kill(v)` unlinks only facts whose first or second
|
||||
endpoint is `v`, including self-edges exactly once. It neither compacts nor
|
||||
scans unrelated facts. The killed endpoint bucket remains pinned until its
|
||||
chains are empty; Zig 0.17's hash-map removal tombstones other buckets without
|
||||
relocating them. Removed node slots are recycled, so one state's node storage
|
||||
tracks its live-fact high-water mark rather than historical insertions.
|
||||
|
||||
`borrow.step` checks E4305 through the ended shield's second-endpoint list,
|
||||
retaining the old live-subject filter and first-conflict choice. Generic access
|
||||
checks visit only loan facts; borrow-end guard checks visit only guards, and
|
||||
scope-end checks visit only that scope's target list. These restricted lists
|
||||
preserve the corresponding full-list order. Whole-state clone, union and
|
||||
simultaneous edge/handle renaming still traverse surviving insertion order.
|
||||
Exact shield joins compare the same `.inner` set and choose the same first
|
||||
mismatching resource. No fact is inferred or discarded by the new indexes.
|
||||
|
||||
The internal relation-kind tag is explicitly `u32`. This leaves the fact's
|
||||
five scalar words without padding and selects Zig's standard byte-hash path
|
||||
instead of recursive field hashing in Debug. Fact equality, printed names and
|
||||
AIR are unchanged. Membership insertion is rolled back if subsequent host
|
||||
growth fails; endpoint, kind and order links are published only after growth
|
||||
succeeds. Clone/rename replacement is published only after the replacement is
|
||||
complete. Removal and iteration allocate nothing. The checker still returns
|
||||
actual host allocation failures as `error.OutOfMemory`.
|
||||
|
||||
### Paired timing and memory
|
||||
|
||||
Zig 0.17.0, Debug, CPU 0; one warmup and three measured repetitions per binary
|
||||
and case, alternating version order. Both frozen executables receive the same
|
||||
bytes. Twenty lowering preflights produce exact identical AIR. Timings cover
|
||||
shield depths 128/256/512/1024 through AIR checking and full source checking,
|
||||
plus six source controls at 512: 28 warmups and 84 measured commands. All
|
||||
commands accept cleanly. Each child's CPU time and peak RSS come from `wait4`.
|
||||
These are finite measurements, not portable latency or whole-compiler bounds.
|
||||
|
||||
| Shield depth | AIR check seconds, before → after | Source check seconds, before → after | Source speedup | Source RSS MiB, before → after |
|
||||
|---|---|---|---|---|
|
||||
| 128 | 0.0903 → 0.0934 | 0.1277 → 0.1092 | 1.17× | 20.4 → 20.4 |
|
||||
| 256 | 0.3623 → 0.3166 | 0.3948 → 0.3499 | 1.13× | 24.0 → 44.9 |
|
||||
| 512 | 1.9534 → 1.1833 | 1.9848 → 1.2405 | 1.60× | 56.4 → 120.9 |
|
||||
| 1024 | 14.8610 → 7.6246 | 12.1542 → 5.0732 | 2.40× | 166.8 → 400.9 |
|
||||
|
||||
The endpoint/kind indexes trade memory for reduced scanning. The larger RSS
|
||||
is material; small-case RSS can include the runner's inherited process floor.
|
||||
The implementation still creates n(n−1)/2 shield-order facts. A complete
|
||||
innermost-first pop now removes each such fact once per state application,
|
||||
rather than visiting lists totaling (n³−n)/6 entries; hash-table work has
|
||||
expected constant cost per lookup/removal. Creation, cloning, live-value
|
||||
checks and other verifier passes remain. Reducing the quadratic fact count or
|
||||
index footprint is separate work, so Q-063 stays open.
|
||||
|
||||
Source-check controls at 512 (seconds):
|
||||
|
||||
| Shape | Before | After | Change |
|
||||
|---|---:|---:|---:|
|
||||
| scope | 0.097691 | 0.098552 | +0.9% |
|
||||
| while | 0.305123 | 0.308303 | +1.0% |
|
||||
| loop | 0.128656 | 0.134261 | +4.4% |
|
||||
| match | 0.317832 | 0.324534 | +2.1% |
|
||||
| while_live | 0.825396 | 0.828236 | +0.3% |
|
||||
| match_live | 0.770816 | 0.782526 | +1.5% |
|
||||
|
||||
### Correctness and concurrency invariants
|
||||
|
||||
This is an implementation optimization of existing spec 04 §34/§37.3,
|
||||
spec 06 §6 and spec 08 §11. The AGENTS.md memory/concurrency checklist is:
|
||||
|
||||
| Contract | Preserved behavior and evidence |
|
||||
|---|---|
|
||||
| Invariant | Identical fact membership and survivor order; loans retain task, borrower and spawn origin; both endpoints are killed |
|
||||
| Verifier | Innermost shield ending (E4305), exact incoming shield order (E3002), loan/scope/guard transfer and existing error recovery |
|
||||
| Runtime | Interpreter, shield depth, pending cancellation and scheduler rules are unchanged |
|
||||
| Valid example | `shield_index_handoff.air`, `shield_index_reuse.air`, and source `layer8/shield_index_reuse.aji` |
|
||||
| Rejected example | `shield_index_first_conflict.air` and `shield_index_join_priority.air` |
|
||||
| Diagnostic impact | Same codes, order, conflict/resource names, source/AIR positions and loan-related locations |
|
||||
| Determinism | Exact old/new records and exits at finite fuel, quantum and scheduler choices, plus scheduled conformance runs |
|
||||
| Compatibility | All public source/AIR comparisons below are exact; AIR format 0 and source rules are unchanged |
|
||||
|
||||
Validation on the final source and executable:
|
||||
|
||||
- **348 unit tests**, including the frozen compact-list oracle over 2,304
|
||||
mixed operations with duplicates, self-edges, deletion/reinsertion, clones,
|
||||
self/ordinary merges and simultaneous renaming. Both indexes and kind/order
|
||||
links are checked against that independent oracle. Storage reuse and
|
||||
allocation-failure probes cover empty and grown indexes, atomic publication,
|
||||
deduplicating rename and complete arena release.
|
||||
- **1,813 conformance cases** pass with unique complete inventory, including
|
||||
five new cases. The three new run cases use 32 scheduler seeds each; existing
|
||||
cancellation/resource tests retain their own scheduled runs.
|
||||
- **3,252 exact old/new comparisons** on 1,813 public files: check all 1,439
|
||||
source and 374 AIR files, and lower every source file. Exit, stdout and
|
||||
stderr match byte for byte, including rejections.
|
||||
- **378 exact runtime/fuel/schedule pairs** on nine source/AIR inputs, including
|
||||
pending cancellation under a shield, resource handoff, returned loans,
|
||||
repeated cancelled join and task-loop propagation. Two quanta, three
|
||||
scheduler seeds and seven fuel values are compared; final-fuel results are
|
||||
checked against the fixture's expected value.
|
||||
- Targeted shield CLI suite: **291 checks**; existing CFG-provenance suite:
|
||||
**146 checks**; related-location suite: **409 checks** with 220 context
|
||||
records. These cover first E4305 conflict after node reuse, E3002/E4305
|
||||
priority at a join, source formatting/AIR fidelity and hosted execution.
|
||||
Hosted smoke, including local TCP sockets, and Zig formatting pass.
|
||||
|
||||
The frozen baseline contains both earlier Q-063 optimizations and Q-064. Raw
|
||||
qualification is in `/tmp/aji-q063-shield-20261014-y7i34hqh/`:
|
||||
`baseline.json`, frozen executables, `unit-final.log`,
|
||||
`conformance-final.jsonl`, `parity.jsonl`, `runtime-parity.jsonl`,
|
||||
`performance-final/` and `qualification.json` with source/binary hashes. The
|
||||
first endpoint-only experiment and intermediate sources remain separately
|
||||
labelled; they are not the final qualification. The reproducible targeted suite
|
||||
is `python3 tests/hosted/shield_relations.py`.
|
||||
@@ -675,9 +675,16 @@ frames, with AST identity/name/construct guards. Paired Debug mutable-match
|
||||
lowering at 512 levels falls from 30.982 to 0.635 seconds (48.77×), with 341 unit
|
||||
tests, 1,799 conformance cases and exact source/AIR/runtime comparisons. This
|
||||
preserves first-use kills, sibling exclusion and loop reads; it is not a global
|
||||
variable-liveness cache. Remaining assignment/read/positive-query costs and a
|
||||
separately reviewed shield relation optimization remain open. A later
|
||||
optimization needs exact CFG/SSA,
|
||||
variable-liveness cache. The
|
||||
[third optimization](control-depth-performance-audit.md#third-optimization-indexed-resource-relations-2026-10-14)
|
||||
indexes resource relations by endpoints and kind while preserving insertion
|
||||
order. Removal touches only incident facts, and loan checks no longer scan
|
||||
shield-order facts. Paired Debug source checking at 1,024 nested shields falls
|
||||
from 12.154 to 5.073 seconds (2.40×), with 348 unit tests,
|
||||
1,813 conformance cases and exact diagnostic/runtime/fuel comparisons. Index
|
||||
storage increases peak RSS; the audit records the measured tradeoff. The
|
||||
quadratic number of `.inner` facts and remaining assignment/read/positive-query
|
||||
costs keep Q-063 open. A later optimization needs exact CFG/SSA,
|
||||
diagnostic-order, host-OOM and runtime/fuel compatibility checks.
|
||||
No source-depth limit, new diagnostic, verifier rule, AIR instruction or
|
||||
language semantic change is introduced by recording this limitation.
|
||||
|
||||
Reference in new issue
Block a user