Record the owner-requested STD-0..7 merge boundary and adoption of implemented RFCs 0016-0035, whose normative rules and vertical implementations land together. Update repository and std status; keep remaining Std 0.1 and service milestones in the backlog. Track Q-034/P6-11 as the next source-language task and retain the existing P7/P8 gate. Implementation checks are recorded in RFC 0035 and the std plan; this change updates adoption metadata and planning only.
41 lines
5.6 KiB
Markdown
41 lines
5.6 KiB
Markdown
# RFC 0026: Non-cryptographic hash foundation
|
|
|
|
Status: Implemented
|
|
Scope: STD-6d.1 pure library; next map contract remains a design proposal
|
|
Adoption: owner-requested intermediate std merge, 2026-10-07; normative rules and reference implementation are integrated together.
|
|
|
|
## Decision
|
|
|
|
Spec 16 §2.12 registers std.hash and four monomorphic safe functions: fresh and extend for FNV-1a 64 and Castagnoli CRC-32C. Integer state is explicit; CRC continuation takes the finalized checksum, not an internal inverted register. This avoids a state/context/finalize API while supporting chunked I/O. Every input byte participates. Empty chunks are identities, arbitrary numeric continuation states are valid, and serialized integer order is explicit. Constants and public vectors are checked against [RFC 9923](https://www.rfc-editor.org/rfc/rfc9923.html#section-2) and [RFC 3720 B.4](https://www.rfc-editor.org/rfc/rfc3720.html#appendix-B.4). Neither algorithm provides authentication or adversarial collision resistance.
|
|
|
|
FNV implements XOR plus explicit wrapping multiplication. CRC uses eight reflected bit steps per byte, deliberately avoiding table storage/runtime magic in this initial implementation. Both cost O(bytes) work and O(1) state; no native throughput claim. Larger/specialized hashes or accelerated CRC would require separate evidence while retaining this recurrence.
|
|
|
|
## Borrow and compatibility checklist
|
|
|
|
Invariant: input remains unchanged, no ownership transfers and no borrow escapes. Existing immutable slice bounds/exclusion verify the source; no verifier state, runtime/GC rule, effect, capability, diagnostic, opcode or feature is added. Safe source lowers to existing AIR and deterministic/hosted results agree. Only interpreter fuel/environment limits can interrupt valid calls. [Valid example](../../examples/std/hash.aji) hashes chunks and explicitly serializes the CRC. Holding a mutable element while hashing its parent rejects E2101; wrong argument types/imports/monomorphic specialization use existing E7005/E7002/E7006. Existing source/AIR/API meanings remain unchanged.
|
|
|
|
## Map follow-through
|
|
|
|
The [owning map proposal](../design/hash-map.md) fixes returned-value ownership, capacity, tombstones, exact collision handling and failure-preserving explicit rehash. No map API is registered in this increment. It proposes U64Map<V> first, since current source type parameters cannot provide user hashing/equality operations. A checked storage prerequisite demonstrates that a struct with Copy key/state fields and Option<V> supports observational metadata access for owning V; a linear key/value enum would not. Both tags are explicitly charged. General HashMap<K,V> remains Q-037 and the STD-6d collection gate stays open. A byte hash must not be substituted for original key equality; no map-specific trait/compiler magic is introduced.
|
|
|
|
## Agent complexity impact
|
|
|
|
New language/verifier/runtime/syntax/diagnostic concepts: none. Four functions and one numeric continuation convention; no context lifetime, implicit seed, method, overload, trait or reflection. Ordinary source operations suffice. Full recurrence and usage stay on demand; Quick Reference adds only discovery guidance. The future map draft stays outside normative source/AIR bundles. Bundle growth is measured below; no empirical Model Capability Compression benefit or task-specific semantic change is claimed. No private held-out corpus was accessed.
|
|
|
|
## Validation
|
|
|
|
Conformance covers empty/high-bit/all single-byte inputs, boundary lengths, published numeric vectors, every split of representative inputs, byte-at-a-time continuation and arbitrary state. An independent Python oracle uses arbitrary-precision FNV and forward-polynomial CRC with reflected input/output, structurally distinct from the library's right-shift CRC. It validates 286 inputs / 1,144 fresh/continuation results. Immutable sub-slice bounds/reborrow, shared workers, alias/type/import rejections, canonical AIR, local-name/import-order independence, explicit packages and hosted/isolated execution are checked. Unit tests and full conformance pass; the final suite includes the checked owning storage prerequisite. All eleven hash fixtures pass with collection before every instruction and 12 schedule seeds over four quanta; the owning slot prerequisite also passes per-instruction collection. Source/package/hosted CLI checks pass (84), source coverage is 95/95, and formatting/reference generation pass. Final conformance count is recorded in the commit. These checks add no new verifier or runtime rule.
|
|
|
|
## Reference bundle measurement
|
|
|
|
Relative to RFC 0025 Deque, using the three repository tokenizers:
|
|
|
|
| Bundle | cl100k before → after | o200k before → after | Qwen2.5 before → after |
|
|
|---|---:|---:|---:|
|
|
| Quick Reference | 7,747 → 7,806 | 7,778 → 7,837 | 7,982 → 8,043 |
|
|
| Other source docs | 46,246 → 47,475 | 46,376 → 47,616 | 47,467 → 48,802 |
|
|
| Full source excluding AIR | 53,993 → 55,281 | 54,154 → 55,453 | 55,449 → 56,845 |
|
|
| AIR reference in source bundle | 45,520 → 45,520 | 45,667 → 45,667 | 46,981 → 46,981 |
|
|
|
|
Full source growth is +2.4% relative to Deque and +62.7% since the 33,981-token pre-stdlib baseline. Quick Reference adds discovery guidance (+0.8%); library/std.md is 12,190 cl100k tokens. Standalone AIR stays 175,736 bytes / 19 files / 50 sections. The map draft is excluded from both bundles. Cumulative growth and the existing Quick Reference target overrun remain for owner review; the cost is justified by reusable exact byte/checksum contracts with no language/verifier-state expansion. Documentation size is not evidence of compression benefit.
|