diff --git a/.arxiv/2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md b/.arxiv/2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md new file mode 100644 index 000000000..5243fb7d9 --- /dev/null +++ b/.arxiv/2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md @@ -0,0 +1,93 @@ +# Supplemental research excerpts: ONA observability, adaptive holdouts and metamorphic software awareness + +**Date:** 2026-10-12. **Scope:** source-grounded *paraphrased excerpts*, implementation constraints and red tests expanding D-SAG-2. **Not implementation evidence.** +**Companion:** [operational falsification addendum](../.claude/knowledge/sag-v2-observability-causality-and-evaluation-addendum.md). +The `.arxiv` folder is a curated literature shelf, not a claim that every item is published on arXiv. Links to journal/conference PDFs are separately identified. No long quotations are reproduced. + +## 1. Hammer & Lofthouse (2020), *'OpenNARS for Applications': Architecture and Control* + +Primary conference PDF: https://agi-conf.org/2020/wp-content/uploads/2020/06/AGI-20_paper_52.pdf (AGI 2020, 11 pages, printed pp. 1–11). +**Location:** §2 Architecture (printed pp. 2–4); §3 Data Structures (printed pp. 5–6). + +**Research excerpt, paraphrase:** ONA's application-oriented architecture replaces aspects of older OpenNARS control with an event-selected, bounded priority process. A cycling event selects relevant concepts, which are checked for evidential overlap before inference. Semantic inference and sensorimotor/temporal procedural inference are separated. Every event has a term, NAL truth value, evidence stamp, occurrence time, and priority. In §3 an implication of the form `(a, operation) ⇒ b` can predict an outcome, and its evidence changes when the outcome is or is not observed. The authors describe *Assumption of Failure*, where initial negative evidence can be outweighed by later positive evidence, rather than using a strict anticipation deadline. + +**Specific transfer:** SAG can define a counterfactual prediction receipt and a later observation receipt, but *must not* transfer assumption-of-failure to an open-world/static harvester wholesale. Absence is meaningful only for a complete observable predicate on the expected snapshot and interval. The narrower SAG model permits pending, incomplete and unobservable predictions. + +**Probes:** (a) same event stamp encountered via multiple derivations must not become independent evidence; (b) deliberately disabled Ruff predicate does not count as failed prediction; (c) positive result arriving late must not irreversibly corrupt another snapshot; (d) event priorities alter which facts are inspected, never authorization or the truth of compiler verdicts. + +**Limit:** event-handling, capacity and evidential overlap are described by the paper; this does not verify a specific API, NAL-9 self-observation implementation, or CE64 byte layout in ONA. + +## 2. ONA issue #286 (2024), *Do-nothing operator* as an explicit research ambiguity + +Primary implementation discussion: https://github.com/opennars/OpenNARS-for-Applications/issues/286 +**Location:** issue description discussing `Concept::precondition_beliefs`, `Decision_Anticipate` and the special operation index 0. + +**Excerpt, paraphrase:** An issue contrasts including or excluding index 0 when traversing operation precondition beliefs. Its author asks whether do-nothing and ordinary operation slots should be distinguished. This is a question on the issue page, **not** proof that the proposed interpretation was accepted or implemented. + +**Transfer:** distinguish SAG's explicit `NoOp` intervention from a read-only `Probe` and an OGAR-gated `ExternalMutate`. A no-op provides a genuine causal baseline for spontaneous data drift, instrumentation overhead and false-positive prediction of change. Do not infer that ONA's operation code 0 is equivalent to SAG's action or source mutation. + +**Red test:** a no-op A→B reharvest incorrectly creates a semantic dependency delta or a verified action effect. + +## 3. Dwork et al. (2015), *Generalization in Adaptive Data Analysis and Holdout Reuse* + +Primary arXiv: https://arxiv.org/abs/1506.02629; related https://arxiv.org/abs/1411.2664. +**Location:** abstracts and holdout-reuse framing; mathematical guarantees are specific to the proposed algorithms, not automatically available to SAG. + +**Research excerpt, paraphrase:** When an analyst repeatedly adapts hypotheses after inspecting evaluation outcomes, even a held-out dataset can be overfit through reuse. The work studies how to answer adaptively selected questions while preserving generalization; simply calling a test "held-out" is insufficient once its feedback has guided development. + +**Transfer:** split the D-SAG-2 corpus by repository and edit family into development, selection-validation and truly protected final evaluation. Log how many times an oracle is consulted. Freeze the policy and hypothesis set before the protected test and treat an already disclosed fixture as development material. + +**Falsifier:** measured adaptation disappears on unseen edit families; the method looks strong only after being tuned to a repeatedly queried mutation corpus. + +**Non-claim:** SAG is not implementing the paper's formally private or statistically valid holdout mechanisms; it adopts the leakage hazard and conservative evaluation discipline. + +## 4. Li et al. (2024), *Metamorphic Relation Generation: State of the Art and Visions for Future Research* + +Primary arXiv: https://arxiv.org/abs/2406.05397. +**Location:** abstract and systematic-review framing. + +**Research excerpt, paraphrase:** Metamorphic testing addresses situations where a fully specified output oracle is hard to construct, by asserting an expected relationship between inputs and outputs after a known transformation. Metamorphic relations themselves need generation, validation and applicability checks. + +**Transfer:** record the predicate and known applicability conditions of source transformations (whitespace, declaration order, safe renaming, extension-view locator edits, full vs incremental harvest, A→B→A' revert). Neither a successful identical checksum nor a single matching SUM is proof of broad semantic equivalence. + +**Falsifier:** SAG considers reordered Ruby mutation/raise events equivalent merely because an unordered field-fact set matches. + +## 5. Duque-Torres et al. (2023), *Bug or not Bug? Analysing the Reasons Behind Metamorphic Relation Violations* + +Primary arXiv: https://arxiv.org/abs/2305.09640; related pipeline proposal https://arxiv.org/abs/2310.00338. +**Location:** abstracts and proof-of-concept description. + +**Research excerpt, paraphrase:** A violated metamorphic relation is suspicious, but may reflect violated applicability preconditions rather than a defect in the program. Their work investigates how to refine constraints and explain these violations; it does not claim all MR violations are bugs. + +**Transfer:** when Ruff reassembly drops unsupported core-7 fields or when C free function calls are deliberately absent from SPO, parity failure may indicate an unsupported projection, not a miscompilation. Label as `Unsupported`, `Incomplete`, or `Refuted` with separately justified semantics. + +**Falsifier:** the validation runner files a "fixed" runtime bug by inventing a triple that the source frontend never promised to emit. + +## 6. Operational synthesis for lance-graph SAG + +A deliberately small sequence, inspired but not equivalent to ONA: + +1. Pin immutable source A and metadata describing what Ruff can observe. +2. Select one source-graph proposition and an intervention from a declared candidate pool. +3. Commit a falsifiable forecast *before* observing B, including expected result, scoring universe and deadline. +4. Use an independent run to observe B and attach the collector completeness receipt. +5. Count independent evidence sources, not duplicated derivation paths or repeated hypothesis layers. +6. Revise only hypotheses when observations are admissible; keep compiler authority and OGAR policy untouched. +7. Compare against no-feedback, shuffled-feedback and no-op controls on protected, unseen edits. + +A positive adaptation claim needs a **difference in next decision attributable to receipt feedback**, plus a predeclared improvement measure on held-out tests. A negative result or explicit `NotObservable` is a correct output. + +This is an *engineering experiment*, not an official consciousness ladder, a port of ONA, a proof of AGI, or an authorization to rewrite source code. + +## 7. Source/version ledger still to pin before execution + +| Component | Source | Status | +|---|---|---| +| SAG base | https://github.com/AdaWorldAPI/lance-graph/pull/1509 | merge `42fa2a347cda22eaaa327bba514f2029cc9daa82` pinned | +| Current documentation | https://github.com/AdaWorldAPI/lance-graph/pull/1510 | branch head subject to PR updates | +| Ruff fork | https://github.com/AdaWorldAPI/ruff | exact test/run commit **not pinned yet** | +| ONA | https://github.com/opennars/OpenNARS-for-Applications | executable commit **not pinned yet** | +| Research OpenNARS | https://github.com/opennars/opennars | separate implementation; **not pinned** | +| Hyperon | https://github.com/trueagi-io/hyperon-experimental | unrelated parity track, **not pinned** | + +No tests, benchmarks or complete ONA/Hyperon parity runs were performed to produce these research excerpts. Preserve that state when reporting this document. diff --git a/.arxiv/2026-10_software_awareness_ona_ruff_research_excerpts.md b/.arxiv/2026-10_software_awareness_ona_ruff_research_excerpts.md new file mode 100644 index 000000000..9e9f9bce6 --- /dev/null +++ b/.arxiv/2026-10_software_awareness_ona_ruff_research_excerpts.md @@ -0,0 +1,106 @@ +# Research excerpts: software awareness, ONA, evidence revision, attention, metagraph folds and Rubicon + +**2026-10-12. Status: annotated primary-source excerpts and engineering transfer, not a proof of self-awareness.** +The repository's .arxiv directory is a literature shelf: some referenced papers are journal articles, not arXiv submissions. "Excerpt" here is a section-faithful concise **paraphrase**, not a reproduced text passage. Where chapter/section or abstract is named, verify against the linked edition before treating it as a mathematical implementation contract. This file does not authorize any CE64, NARS, ISA, OGAR, or runtime change. + +## 1. Wang, Li & Hammer (2018): *Self in NARS, an AGI System* + +Source: https://doi.org/10.3389/frobt.2018.00020 (open-access full text: https://www.frontiersin.org/journals/robotics-and-ai/articles/10.3389/frobt.2018.00020/full). +**Read:** §§2.1, 3.1–3.4, 4.2, 5. + +**Source-faithful extract:** The system reasons under insufficient knowledge and resources. Built-in operations anchor the notion of SELF; internal experience is treated as sensory input with a different origin. Deliberate *mental operations* supplement the fixed automatic inference/attention routines without freely rewriting them. The authors describe this as a preliminary implementation whose self-knowledge is incomplete and fallible. + +**Engineering transfer (hypothesis):** Treat compiler judgments, code harvest, execution traces, budget appraisals and independent test receipts as separate internal observations over existing graph data. Model executable capabilities as methods and evidence of preconditions/outcomes. Preserve the automatic executor and OGAR action authority rather than allowing introspection to modify either. + +**Falsifier:** With the same source and outcomes, does removal of observation-to-revision cause a different or worse subsequent decision? An instrumented graph with no causal feedback fails the stronger adaptation claim. + +**Do not claim:** the article proves machine consciousness, ONA's implementation has complete NAL-9 introspection, or a graph of code alone constitutes subjective awareness. + +## 2. ONA: OpenNARS for Applications (software reference, not a paper) + +Sources: https://github.com/opennars/OpenNARS-for-Applications and https://github.com/opennars/OpenNARS-for-Applications/wiki ; contrast https://github.com/opennars/opennars. + +**Engineering extract:** ONA is a compact NARS implementation focusing on application reasoning, temporal implications, anticipation, operations and feedback. Its implementation may differ materially from the older Java/OpenNARS research code and the paper's introspective mental operations. + +**Probe, not assumed fact:** Pin a concrete ONA commit. Locate source and tests for operation registration, anticipation, success/failure feedback, decision priorities and any internal observation hooks. Produce a table: "exists in ONA", "exists in research OpenNARS", "paper-only", "unverified". Run an executable fixture against pinned ONA before mapping any operator. + +**Falsifier:** A proposed ONA feature with no source entry point is excluded from the implementation mapping. External operation feedback is not automatically internal introspection. + +## 3. Jøsang (2007): *Cumulative and Averaging Fission of Beliefs* + +Source: https://arxiv.org/abs/0712.1182 (Audun Jøsang, 2007, abstract and operator definitions). + +**Source-faithful extract:** Cumulative and averaging belief fusion model different evidence assumptions. Fission attempts to recover the residual opinion after removing one contributor from a fused result. This provides a separate mathematical control for provenance-aware ablation. + +**Engineering transfer:** Use explicit evidence-contributor keys. Compute cumulative versus averaging controls only under their own assumptions; use an independent source witness when removing a contribution. Compare removal with rerunning only the remaining observations. + +**Falsifier:** If a specific contributor's identity is lost, exact inverse fission must return insufficiency rather than a fabricated truth value. Never substitute subjective-logic fission for NARS revision silently. + +## 4. Gollwitzer (1999): *Implementation Intentions: Strong Effects of Simple Plans* + +Source: https://doi.org/10.1037/0003-066X.54.7.493 ; author/publication page: https://www.socmot.uni-konstanz.de/publications/implementation-intentions-strong-effects-simple-plans (American Psychologist 54, 493–503). + +**Source-faithful extract:** Implementation intentions link a specific anticipated situational cue to a goal-directed response. Their empirical subject is human goal execution, not a software permission model. + +**Engineering transfer:** A Rubicon commitment can be represented as a versioned, revocable if-cue-then-propose policy. Deliberation and action selection remain distinct, and an action cannot skip the independent OGAR permission check. + +**Falsifier:** Present a near-miss cue, expired/revoked intent, stale source revision, and Undetermined role. A commitment that executes anyway violates the software contract. + +## 5. Goertzel (2020): *Folding and Unfolding on Metagraphs* + +Source: https://arxiv.org/abs/2012.01759 (abstract; full mathematical definitions require checking PDF/text). + +**Source-faithful extract:** Directed typed metagraphs admit multiple recursion/fold/unfold formulations, including catamorphisms, anamorphisms, histomorphisms and chronomorphisms. A metagraph edge may point to another edge and carry ordered typed ports; not every row-set reduction preserves these structures. + +**Engineering transfer:** Compare finite typed metagraph fixtures against independent scalar reference, preserving edge-to-edge references, binding multiplicity, nested results and a pinned read snapshot. Quack SUM equivalence is not evidence for general categorical fold equivalence. + +**Falsifier:** A hyperedge or nondeterministic rewrite whose multiplicity or nested order is lost must be marked unsupported, not called translated. + +## 6. Goertzel et al. (2023): *OpenCog Hyperon: A Framework for AGI at the Human Level and Beyond* + +Source: https://arxiv.org/abs/2310.18318 (architectural overview; not a benchmark of AGI). + +**Source-faithful extract:** Hyperon redesigns prior OpenCog ideas around metagraph representation, type systems, patterns and reflective future aspirations. The text discusses possibilities for reflective self-modification and improvement, not a validated production equivalent of our execution substrate. + +**Engineering transfer:** Separate structural fold/unfold semantics from runnable MeTTa pattern matching, atom binding/rewrite, side effects, and probabilistic reasoning. #1498's explicit four-result nondeterminism fixture is a cardinality gate, not an optional nuance. + +**Falsifier:** Run a pinned Hyperon nondeterministic fixture; if four possibilities collapse to two row-mask matches, fail parity and record the missing operation. + +## 7. Shannon/EIG and Bayesian control: a measurement discipline + +Sources: Kullback & Leibler (1951), *On Information and Sufficiency*, https://doi.org/10.1214/aoms/1177729694 ; companion internal study [#1497 attention research](https://github.com/AdaWorldAPI/lance-graph/pull/1497). + +**Source-faithful extract:** KL divergence compares explicitly defined probability distributions. Shannon entropy and expected information gain require a named random variable, posterior/likelihood model and target outcomes. NARS frequency/confidence, PLN strength and software code frequency are not automatically calibrated probabilities. + +**Engineering transfer:** Specify the target distribution before computing entropy. Compare FIFO, confidence priority, high entropy, EIG and Moore/Staunen at equal rule/candidate budgets with correlated evidence and irrelevant high-entropy distractors. + +**Falsifier:** A scheduler that spends more work on irrelevant entropy but yields fewer independent oracle-supported discoveries loses, even if its raw entropy score is higher. + +## 8. Ruff as an independent *software observation* source + +Primary implementation references (source of current code behavior, not peer-reviewed research): +- https://github.com/AdaWorldAPI/ruff/blob/main/crates/ruff_spo_triplet/src/ir.rs — ModelGraph, common per-language IR. +- https://github.com/AdaWorldAPI/ruff/blob/main/crates/ruff_spo_triplet/src/reassemble.rs — explicitly restricted to C++ machine-plane projected form. +- https://github.com/AdaWorldAPI/ruff/pull/117 — ordered Ruby MethodOre; reported 4,459 events vs 850 set entries in tested OpenProject corpus, not an independent rerun in this study. +- https://github.com/AdaWorldAPI/ruff/pull/118 — free-function signatures; C linkage stays frontend-local; free function dispatch not yet projected. +- https://github.com/AdaWorldAPI/ruff/pull/120 — Odoo parent/extension inherit_id resolution; unresolved XPath remains unresolved. +- https://github.com/AdaWorldAPI/ruff/blob/main/.claude/OGAR-POLYGLOT-AST-INTEGRATION.md — design RFC, not proof of complete bidirectional AST translation. + +**Transfer:** Ruff is an independent static observation oracle for supported constructs; runtime tests remain a separate behavioral oracle. Use exactly matching source revisions, trace missing facts as residuals and record partial extraction as unknown. + +**Falsifier:** If identical unordered reads/writes/calls mask different order-dependent outcomes, static equivalence fails. If a source call graph predicate was never emitted, SAG cannot use its absence as proof there are no calls. + +## 9. Experimental synthesis and non-claims + +Proposed experiment: harvest software revision A with Ruff; issue SAG forecast about a controlled revision B; commit forecast and its evidence; change source; blind reharvest; score agreement; update evidence-based priority; run an identical no-feedback twin. Distinguish **instrumentation**, **operational introspection**, **anticipation**, **control**, and **validated adaptive improvement**. These are proposed engineering test tiers, not official ONA awareness levels or evidence of phenomenal experience. + +Related merged sources: [#1496 CE64/NAL](https://github.com/AdaWorldAPI/lance-graph/pull/1496), [#1497 PLN/Shannon](https://github.com/AdaWorldAPI/lance-graph/pull/1497), [#1498 Hyperon](https://github.com/AdaWorldAPI/lance-graph/pull/1498), [#1499 NARS self](https://github.com/AdaWorldAPI/lance-graph/pull/1499), [#1500 Rubicon](https://github.com/AdaWorldAPI/lance-graph/pull/1500), and [#1509 SAG](https://github.com/AdaWorldAPI/lance-graph/pull/1509). + +## 10. Reproduction and source restrictions + +Pin runtime commits and package/tool versions before claiming parity. Cite a versioned test artifact, fixture, input/output and exact operator mapping. Treat peer-reviewed empirical effects, mathematical proofs, and project-specific engineering hypotheses as **different epistemic tiers**. No paper here licenses adding a new byte interpretation, operator, or action privilege without an independently verified insufficiency and explicit owner decision. + +## 11. Further research note (non-shipped addendum) + +The research shelf [ONA observability, adaptive holdouts and metamorphic oracle limits](2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md) adds annotated excerpts from Hammer & Lofthouse's 2020 ONA architecture paper, the ONA do-nothing-operator issue, Dwork et al. on adaptive holdout reuse, and metamorphic testing studies. These sources motivate **P21–P40**, in particular the distinction between an *unobserved* event and an event known not to have occurred in a fully observed window. None is a production semantics change. + diff --git a/.claude/knowledge/sag-v2-observability-causality-and-evaluation-addendum.md b/.claude/knowledge/sag-v2-observability-causality-and-evaluation-addendum.md new file mode 100644 index 000000000..b1986c9d7 --- /dev/null +++ b/.claude/knowledge/sag-v2-observability-causality-and-evaluation-addendum.md @@ -0,0 +1,228 @@ +# D-SAG-2 supplemental contract: operational observability, causal feedback, metamorphic validation, and resource bounds + +**Status:** research and falsifier expansion after #1510's initial documentation commit. **Non-authoritative.** No production behavior, CE64 bit, ISA layout, method registry, policy grant or external action is changed or approved here. + +**READ BY:** Claude Code implementing D-SAG-2-1..5; SAG SoftwareGraph, Ruff AST/SPO harvest, Quack/R2IL, OGAR/dir-sim/HotPlug, and any ONA-inspired feedback or evaluation operator. +**Parent:** [D-SAG-2 plan](../plans/software-awareness-graph-v2-ruff-ona-closed-loop.md). **Execution instructions:** [D-SAG-2 prompt](../prompts/software-awareness-graph-v2-claude-code.md). **Sources:** [.arxiv annotated follow-up](../../.arxiv/2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md). + +## 1. Not-yet-shipped questions and why they change the experiment + +The original D-SAG-2 deliverables defined predictions and independent observations, but did not fully formalize when **silence** is evidence, how repeated adaptive tests are prevented from overfitting, whether a feedback update is *causally* responsible for later decisions, how non-operation can be a reference action, and what it costs to introspect the introspector itself. + +**Six missing contracts**, all proposed: +1. A negative observation requires a covered, complete, current and functioning observation window. +2. A source-code prediction is not a causal effect estimate merely because it precedes an edit. +3. Feedback credit goes to the originating evidence source, not every derivative graph edge or repeated harvest. +4. The agent must be compared with identical no-feedback, shuffled-feedback and no-op arms on new, held-out edits. +5. Semantic equivalence of programs requires relations over input/output, including ordering and multiplicity, not only triple/set counts. +6. Introspection consumes a fixed, measured compute and memory budget and cannot recursively certify itself. + +## 2. The absence/unknown contract: **not observed** is not **observed false** + +ONA's 2020 architecture describes anticipation and evidence adjustment through *Assumption of Failure* (see paper §3, PDF printed p. 5). That is a mechanism in ONA, **not** a license to assume closed-world completeness for SAG. Static harvesters may miss unsupported syntactic constructs; traces may sample events; the time window may not have closed. Therefore define the proposed test model: + +```text +CoverageReceipt { + collector_id, version, source_revision, snapshot_id, language, + predicate, scope, feature_support: Supported | Partial | Unsupported, + scan_completed, scanned_units, excluded_units, errors, + observation_window_start, observation_window_end +} + +PredictionStatus { + Confirmed, Refuted, Pending, NotObservable, Incomplete, Stale +} +``` + +**Admission rule** for negative evidence: predicate in declared supported set AND exact population covered AND observation end/window satisfied AND scan completed without errors/exclusions AND pinned snapshot valid AND oracle independent enough for the claim. Otherwise return `NotObservable`, `Incomplete`, `Pending`, or `Stale`, and do not change prediction confidence based on absence. + +| Source B outcome | Collector contract | Legitimate inference | +|---|---|---| +| positive hit with matching source witness | supported, fresh, pinned | Confirmed, subject to semantic precision | +| no hit | supported + complete + closed window | Refuted *for that scoped proposition* | +| no hit | unsupported C free-function call edge in Ruff SPO | NotObservable; **not** proof of no call | +| no hit | Odoo XPath predicate unsupported / parent outside tree | Incomplete; not proof of no control | +| no hit | sampled runtime trace misses occurrence | Incomplete unless trace oracle establishes completeness | +| no hit | edit/forecast still in progress | Pending | +| no hit | B reading/seal/version differs | Stale or schema incompatibility, never evidence for current version | + +A predicted *negative* (no impact) is also a real prediction. Use a no-op edit and a semantically inert edit to establish the baseline false-positive rate. + +**First red tests:** deliberately drop one source file after recording a prediction; switch a supported predicate to unsupported without changing code; abort a harvest midway; feed a late event after the observation window; and reorder arrival of equivalent receipts. No case may silently become a failed prediction or a confidence decrease unless its negative-evidence preconditions are satisfied. + +## 3. Time, provenance, and causality are different axes + +Keep **source revision**, **observation/event time**, **ingestion time**, and **decision time** distinct. They are not always equal: a journal or reharvest can arrive late; a branch can rewind; receipt ingestion can happen after a newer prediction. Use a total source snapshot identity for replay and a monotonic append index only for append order. + +Separate these questions: + +- *Who said it?* Collector/provenance and reproducible source artifact. +- *What derived it?* Rule version, input evidence IDs and derivation receipt. +- *When was it true?* Source or device state revision, observation interval, as-of version. +- *When did we learn it?* Ingest/revision sequence. +- *Who was allowed to act?* OGAR action receipt at commit time, independently checked. +- *Would the result differ without the action?* Controlled intervention/no-op twin, NOT observational co-occurrence. + +Minimum proposed `EvidenceKey` for de-dup: originating input SHA/record ID, collector, source revision, observation scope, predicate, asserted event ID. **Do not** use graph-edge ID or layer ID alone; downstream copies are not independent observations. + +A **causal DAG of receipts** may reference sources and derivations without inventing graph semantic causality for the software being analyzed. Two paths from one Ruff AST token via the same ModelGraph are one evidential base, not two independent votes. Two different parsers of the same commit may be separate implementation oracles for correctness *but are not independent evidence of two world events*. + +**Prediction-before-intervention** requires a committed artifact containing (a) exact A revision, (b) frozen candidate/rule set, (c) expected observable delta, (d) source coverage class, (e) scoring rule and (f) machine timestamp or immutable commit order prior to B. Branch A and B names are not enough without commit SHA/hash receipts. + +## 4. A stronger experiment than "we predicted an edited dependency" + +Four controlled interventions over the **same fixture family**, each preregistered: + +| Arm | Mutation | Expected graph property | Why useful | +|---|---|---|---| +| M0 | no source change, rerun harvest | zero semantic delta | oracle, cache and identity stability | +| M1 | whitespace/comment formatting or reorder independent declarations | structural equivalence under declared canonicalization, spans may change | metamorphic normalization | +| M2 | one parent Odoo view / Rails callback / C++ overload change | affected subgraph changes, unaffected subgraph invariant | factual change-impact attribution | +| M3 | misleading new comment, unresolved XPath, omitted module, disabled harvester | abstention/unknown rather than invented witness | epistemic stress test | + +Where semantics allow, run **A→B→A'** (revert) and require the declared semantic graph to return to A while historical receipts remain addressed and immutable. A method's display name can change without changing its authorized caller-issued MethodKey **only** if an explicit versioned correspondence proves continuity; never auto-merge by fuzzy name. + +Metamorphic relation examples to pin as tests: +- Adding irrelevant whitespace must not change the semantic SPO projection except source spans/hashes. +- Permuting independent declarations preserves graph content while source order metadata may differ. +- Swapping Ruby `write; raise` and `raise; write` can have identical unordered W/R/X/C but **must not** be asserted behaviorally equivalent. +- Duplicate source inclusion with the same evidence ID cannot inflate independent confidence. +- A separately repeated *new* independent observation retains independent weight. +- Under supported semantics, full reharvest(A→B) equals incremental reharvest(A→B); if not, caching is not a proof. +- A→B→A' restores the current semantic projection without erasing historical A/B receipts. +- C linkage `static` and C++ static member remain distinct even if labels match. + +For source-only behavior claims, ask for an independent executable test or return `NotObservable`. An AST assertion is not proof of exception ordering, database side effects, or deployment effects. + +## 5. Operational loop versus ONA research vocabulary + +ONA 2020 keeps semantic and sensorimotor inference apart, uses bounded attention and evidence stamps. For a SAG probe we propose the following **behavioral observation loop**, not a literal ONA port: + +```text +read frozen A + -> propose hypotheses H[0..n] + -> choose a test within budget (no side effect by default) + -> commit prediction and observability contract + -> authorized fixture intervention OR select explicit NoOp + -> independently obtain source/runtime result at pinned B + -> classify Confirmed | Refuted | Pending | NotObservable | Incomplete | Stale + -> revise ONLY eligible hypothesis evidence + -> choose the next experiment from a frozen candidate pool +``` + +Observe three classes of operation separately: +- **NoOp**: no source or external change; tests attention and measurement drift. An ONA issue discusses ambiguity around a "do nothing operator" as an implementation question, not a settled semantic analogue for SAG. +- **Probe**: read-only, potentially costly harvest/measurement. Its side effect is **knowledge intake**, not target-program modification. +- **Proposal**: inert suggested code/transformation/action that cannot execute externally before OGAR authorization. + +No unbounded action loops, no automatic source rewriting. A decision to probe is not the same as a commitment to mutate. A failure prediction becomes negative evidence **only** if the collector could have witnessed its expected outcome. + +**Introspection depth budget:** a meta-query about the current SAG must read immutable snapshot k; telemetry about its own execution may enter k+1, never the same query epoch. Terminate cycles by (snapshot, method key, query signature, recursion depth/remaining budget), and return a typed budget/recursion refusal. No new runtime engine is necessary to articulate or test this rule. + +## 6. Adaptive testing can make a self-optimizer hallucinate progress + +Dwork et al. (2015) show why repeated access to an adaptively reused holdout can bias apparent generalization. Our finite source-change test sets have the same conceptual risk. A system that learns which Ruff mutations the benchmark contains can score better without transferable software reasoning. + +Preregister three disjoint buckets, grouped by **repository + edit family**, not random lines: +- **Development:** visible failures may be iterated on; all changes logged. +- **Validation:** limited, counted selection of policies/thresholds; freeze the chosen candidate and feedback law afterward. +- **Protected test:** never exposed during training/selection; one run of final frozen policy and its ablations. + +At protected test time, compare under identical precommitted budget and candidate pool: +- A0: no observation→belief feedback (logging only). +- A1: source-grounded revision enabled. +- A2: shuffled or deliberately stale receipts (negative control; should not improve). +- A3: no-op or heuristic scheduler only (distinguishes information from exploration strategy). +- A4: Oracle-aware abstention enabled versus blindly treating silence as false. +- Optional A5: attention policies FIFO / confidence / naive entropy / calibrated EIG / Staunen under unchanged inference law. + +Report **paired decision-quality difference on unseen edits**, uncertainty intervals where sample size permits, coverage/abstention, false-positive/negative rates under complete supported predicates, calibration for any probabilistic score, discovery per decoded byte, and instrumentation overhead. "Different next decision" is a minimal causal check; "better" requires predeclared utility and held-out evidence. + +If learning works only when evaluation fixtures are visible, or with shuffled evidence, claim **selection leakage** or a weak control, not a cognitive advance. A null result is useful. + +## 7. Attention and CARE: measure the *value of information*, not its aesthetic + +A candidate set of maskable unknown cells is useful as a *search agenda*, not ground truth. `popcount(unknown_mask)` measures how many unknowns are available; it does not measure probability, causal relevance or human-like curiosity. Any prospective 50–52 CE64 CARE/motivation reading must remain a **versioned, typed semantic interpretation**, not an assignment of meaning to the ISA bytes; #1496 records unresolved existing interpretations of those bits. No new semantics are shipped here. + +A falsifiable resource allocator could propose: `score = E[oracle-supported improvement or error reduction | probe] / expected total cost`, estimated only from calibrated historical observations with no future leakage. Compare with FIFO and random, and explicitly count costs for: +- AST/SPO parsing, projection, binding and query lowering; +- mask/lane byte decode, allocations, branch fan-out and materialization; +- oracle invocations, negative controls, replay, merge and retention; +- wasted probes, abstentions and cache misses. + +High Shannon entropy on irrelevant facts must not dominate. Structural redundancy, epistemic uncertainty and execution cost remain distinct axes; hard correctness/security gates dominate any score. If computing exact EIG is unjustified, report that instead of renaming a heuristic "EIG." + +## 8. Action boundaries: hard separation of belief, intent and permission + +The Rubicon research (#1500) describes human commitment/implementation intentions, not software authorization. Define a *proposed* software boundary: + +```text +Hypothesis -> CandidateProbe -> PrecommittedPrediction -> ReadOnlyProbe + -> OutcomeReceipt -> RevisedEvidence -> CandidateProposal + -> OperatorCommitIntent (revocable) -> OGAR Action Gate + -> ExternalActionReceipt -> PostconditionObservation +``` + +A committed intent can become invalid at any point due to role loss, authorization revocation, schema/reading mismatch, stale test receipt or expired universe. Commit checks must be atomic with authorization or otherwise refuse and re-evaluate. #1503's `Undetermined` is not a grant. The operator's approval of a *research PR* is not authorization to perform a production source rewrite. + +Adversarial dry runs: revoke permission between intention and dispatch; switch user's role path to alternate still-valid grant; leave a security group unread; change method seal after commitment; delayed outcome arrives after cancellation. Refuse external mutation without current policy and witnessed capability; do not convert source graph edges into executable actions merely because the same class defines both. + +## 9. Versioned hot-plug and graph custody + +Avoid a parallel method-mint registry. Caller-issued MethodKey is the identity under #1509. Class/field/readings resolve through OGAR's existing ownership; Quack only binds what the active glove/schema declares. Preserve the difference between: +- logical schema shape; +- hotplug activation/version and current permission; +- source-program revision and compiler build; +- read snapshot/persistent Alpha overlay; +- source code harvest provenance. + +**Cross-repository evolution** is a compatibility proof obligation. When Ruff exposes a new predicate, it is not automatically a valid OGAR ontology value. When OGAR adds a method key, it is not a rule to rewrite historic SAG identifiers. Typed unknown/residual is better than casual string fallback. + +Proposed minimal artifact manifest (no new crate): +```text +FixtureManifest { + sag_base_sha, ruff_sha, model_or_method_key, classid, schema_seal, reading_id, + harvester_features, supported_predicates, excluded_sources, fixture_digest, + source_A_sha, prediction_receipt_sha, source_B_sha, oracle_receipt_sha, + collector_version, evaluator_version, cpu_tier, budget +} +``` +If any artifact cannot be pinned, report non-reproducible, not verified. + +## 10. Probe matrix supplement: P21–P40 (not executed) + +| ID | Test/falsifier | Must reject or distinguish | +|---|---|---| +| P21 | complete supported negative observation at B | scoped Refuted allowed | +| P22 | unsupported predicate omitted by Ruff | NotObservable, no negative revision | +| P23 | truncated / failed extraction with omitted module | Incomplete, not Refuted | +| P24 | premature or late event beyond window | Pending/Stale versus negative evidence | +| P25 | no-op source edit plus repeat harvest | zero semantic delta; no fabricated change | +| P26 | formatting/alpha-renaming with explicit identity map | no false semantic diff; no name-based method key | +| P27 | A→B→A' revert, historic receipts retained | current graph restored, history immutable | +| P28 | full versus incremental reharvest at pinned snapshot | same supported predicates/edges | +| P29 | same source via Ruff AST → ModelGraph → SAG | one evidence contributor, no double confidence | +| P30 | same originating event repeated across hypothesis layers | one contributor, not two | +| P31 | two independent sources of same proposition | preserve both contributors | +| P32 | read k while own telemetry appends to k+1 | no recursive contamination or time drift | +| P33 | self-introspection infinite feedback possibility | bounded recursion/typed refusal | +| P34 | no-op operator versus probe operator | separate effect and observational cost | +| P35 | visible-dev success, unseen protected holdout | no hidden adaptive benchmark selection | +| P36 | shuffled/stale feedback control | cannot claim source-grounded learning advantage | +| P37 | mismatch in behavior with equal Ruby unordered sets | behavioral equivalence disallowed | +| P38 | high entropy irrelevant facts vs useful low entropy | report discovery per total budget | +| P39 | role revoked between Rubicon commit and action gate | refusal; intent alone no authority | +| P40 | observation feedback decreases accuracy on new edit family | negative result preserved, not relabeled improvement | + +**Kill conditions:** false Verified, phantom negative evidence, provenance overlap counted twice, unbounded introspective recursion, hidden second evaluator, unpinned test reuse presented as validation, unsupported Ruff fact treated as false, or action past a revoked authorization. Ship a narrow failing fixture and stop broadening until repaired. + +## 11. References to consult before writing code + +- [Hammer & Lofthouse (2020), ONA Architecture and Control, PDF](https://agi-conf.org/2020/wp-content/uploads/2020/06/AGI-20_paper_52.pdf), §§2–3 (queue, stamps, sensorimotor predictions and *Assumption of Failure*). +- [ONA implementation](https://github.com/opennars/OpenNARS-for-Applications) and [do-nothing operator discussion #286](https://github.com/opennars/OpenNARS-for-Applications/issues/286). +- [Dwork et al. (2015), Generalization in Adaptive Data Analysis and Holdout Reuse](https://arxiv.org/abs/1506.02629). +- [Li et al. (2024), Metamorphic Relation Generation](https://arxiv.org/abs/2406.05397) and [Duque-Torres et al. (2023), Bug or not Bug?](https://arxiv.org/abs/2305.09640). +- [SAG #1509](https://github.com/AdaWorldAPI/lance-graph/pull/1509); [method composition #1508](https://github.com/AdaWorldAPI/lance-graph/pull/1508); [identity evidence #1503](https://github.com/AdaWorldAPI/lance-graph/pull/1503); [NARS Self #1499](https://github.com/AdaWorldAPI/lance-graph/pull/1499); [PLN/Shannon #1497](https://github.com/AdaWorldAPI/lance-graph/pull/1497); [Rubicon #1500](https://github.com/AdaWorldAPI/lance-graph/pull/1500). +- [AdaWorldAPI/ruff #117](https://github.com/AdaWorldAPI/ruff/pull/117), [#118](https://github.com/AdaWorldAPI/ruff/pull/118), [#120](https://github.com/AdaWorldAPI/ruff/pull/120). + +**No-code constraint:** this file asks future implementers to falsify before changing behavior. No passage is an instruction to rename classes, allocate CE64 bits, widen the ISA, construct a new Quack primitive, execute production changes or assert ONA implementation parity without a pinned source check. diff --git a/.claude/knowledge/software-awareness-provenance-parity.md b/.claude/knowledge/software-awareness-provenance-parity.md new file mode 100644 index 000000000..d852e6109 --- /dev/null +++ b/.claude/knowledge/software-awareness-provenance-parity.md @@ -0,0 +1,83 @@ +# D-SAG-2 evidence / parity contract: the observations are not the authority + +**Type:** cross-repo method and validation checklist. **READ BY:** anyone changing SoftwareGraph/MethodTable, Ruff SPO/AST frontends, SAG prediction loops, OGAR ActionDef, Quack/R2IL or NARS evidence. +**Status:** proposed guardrail, with source-grounded possible defects to *test*, not confirmed bugs. + +## Separation of concerns + +| Question | Evidence source | Permitted conclusion | +|---|---|---| +| What did the author declare? | MethodSpec, Ruff AST, source digest | Declared syntax with span and revision | +| What did the compiler accept? | MethodTable::prepare, Program, refusal | Compiled or typed refusal, not runtime proof | +| What actually ran? | independently executed oracle / instrumentation | Observed result under bound environment | +| Was it independently confirmed? | signed/registered or replayable oracle receipt | Verified only when oracle identity and output validated | +| Which hypothesis deserves testing? | observations + revision policy | Hypothesis; no method authority | +| May an external effect occur? | OGAR action capability + current policy/roles | Authorization decision only at execution/commit | + +**"Unknown" is not "NotHeld" and "not emitted" is not "false."** Dir-sim #1503 explicitly distinguishes Held, NotHeld, Undetermined and NotDeclared. Ruff may omit a triple for unsupported semantic reasons. Never infer a negative fact from absent output without known complete extraction. + +**No self-certifying loop:** a SoftwareGraph claim() or a user-supplied string never produces Verified. Compiler-produced edges are not sufficient to prove behavior; tests are not a valid oracle unless actually run. A test identifier and matching body digest prove only identity compatibility, not that execution occurred. + +## Minimal source→graph crosswalk + +Require: +- repository identity and commit SHA; +- language and compiler/harvester version; +- source span and symbol qualified name where available; +- stable concept identity, schema seal and reading; +- method key with explicit mapping provenance, never derived from display label alone; +- edge predicate with source declaration, derived inference, or unavailable-status; +- extraction closure/completeness per predicate on the specific source domain. + +Do not promise that all Ruff languages lower directly to one lossless ModelGraph round-trip. As of the verified 2026-10-12 Ruff source, reassemble() reverses C++ machine-plane projected form only; core-7 and OpenProject IR content are not reconstructed. The Ruff RFC is a desired destination, not proof of full coverage. + +Ruff #117 preserved ordered Ruby MethodOre (set reductions are lossy). Ruff #118 deliberately did not overload C++ IsStatic to represent C file-scope linkage and did not emit a free-function call graph into triples. Ruff #120 resolves a subset of Odoo extension-view locators; unsupported XPath remains unresolved, not guessed. + +Therefore distinguish: +- *source structure parity* (supported SPOs, anchors, signatures); +- *behavioral equivalence* (tests/runtime oracle); +- *temporal counterfactual prediction* (precommitted A→B with blind independent observation); +- *optimization* (semantic parity + measured cost); +- *authority* (action gate plus current permission witness). + +## Provenance and snapshots + +A logical fact and its evidence witnesses need separate identities. If (src,rel,dst,tier) is logically deduplicated, multiple ctx/prov owners still need independently removable ownership. Test current awareness.rs link() and project() behavior, including classes and shared fields. When a source disappears in B, remove current witness without erasing the other source or rewriting the archived A receipt. + +A compiler's current refusal can change at revision B; no old ComputeCycle remains active merely because its node exists in the interning table. For source/version-sensitive hypothesis revision, replay a pinned read at k during writes to k+1. Immutable method/node identity is not equivalent to immutable snapshot semantics. + +Evidence stamps represent *originating observations*, not each derivative inference or each layer containing the same observation. Retraction needs explicit original contributor; where provenance is insufficient, return typed insufficiency. Keep Jøsang belief fission distinct from NARS evidence revision. + +## Controlled attention and intervention + +Run five attention policies under fixed candidate pool, oracle, inference rules, source revision, seed and total work budget: +1. FIFO; +2. priority by declared confidence; +3. naive high Shannon entropy; +4. expected information gain, only after a normalized and calibrated predictive distribution is defined; +5. Moore/Staunen policy. + +Include irrelevant high-entropy distractors, correlated evidence, a delayed useful discovery, negative tests and bad predictions. Report oracle-supported findings / total work, decoded bytes, allocations, and time. Do not treat NARS f/c or PLN strength as a probability distribution without calibration. + +For Rubicon-style agent control, distinguish: predecisional evidence deliberation → revocable implementation intention → action *proposal* → OGAR commit gate → witnessed outcome → adaptation/disengagement. A predicted benefit never grants action capability. A committed intent must re-check policy and role evidence at commit and cannot override Unread/Undetermined. + +## Measurement and failure semantics + +Hard gates: correctness, independent provenance, schema/reading version, graph/row population, evidence overlap, permission, and replay. Soft measurements: discovery quality, hypothesis coverage, entropy reduction, MDL, latency, allocations, decoded bytes and energy if available. + +H1 reported a gap (current Quack masked sum slower than a fused scalar reference) and an absent fused terminal; it did not report a speedup. Don't put that gap into a success numerator. Use native and x86-64-v3 controls from #1505. + +If a new result cannot be expressed through existing Quack/OGAR/R2IL, return an explicit typed refusal and file the exact minimal insufficiency. Do not work around it by injecting a graph evaluator. + +## Source map + +- [lance-graph #1503 role evidence](https://github.com/AdaWorldAPI/lance-graph/pull/1503) +- [#1504 method parity](https://github.com/AdaWorldAPI/lance-graph/pull/1504) +- [#1506 DAG range](https://github.com/AdaWorldAPI/lance-graph/pull/1506) +- [#1508 predicate reuse](https://github.com/AdaWorldAPI/lance-graph/pull/1508) +- [#1509 SoftwareGraph](https://github.com/AdaWorldAPI/lance-graph/pull/1509) +- [Ruff #117 ordered behavioral ore](https://github.com/AdaWorldAPI/ruff/pull/117) +- [Ruff #118 C linkage semantics](https://github.com/AdaWorldAPI/ruff/pull/118) +- [Ruff #120 Odoo inherit_id](https://github.com/AdaWorldAPI/ruff/pull/120) +- [Ruff ModelGraph](https://github.com/AdaWorldAPI/ruff/blob/main/crates/ruff_spo_triplet/src/ir.rs) +- [Ruff reassemble](https://github.com/AdaWorldAPI/ruff/blob/main/crates/ruff_spo_triplet/src/reassemble.rs) diff --git a/.claude/plans/software-awareness-graph-v2-ruff-ona-closed-loop.md b/.claude/plans/software-awareness-graph-v2-ruff-ona-closed-loop.md new file mode 100644 index 000000000..a8cc7f5b6 --- /dev/null +++ b/.claude/plans/software-awareness-graph-v2-ruff-ona-closed-loop.md @@ -0,0 +1,198 @@ +# D-SAG-2 — Ruff × ONA software-awareness closed-loop validation + +**Status:** RESEARCH / IMPLEMENTATION PLAN, not an implementation. **Base:** merged lance-graph #1509, main merge 42fa2a347cda22eaaa327bba514f2029cc9daa82 (2026-10-12). +**Owner of authority:** existing OGAR action gate. **First executor:** existing Quack → mask-risc; R2IL FoldDialect is the alternate frontend. **Independent source oracle:** AdaWorldAPI/ruff. +**Prompt:** [software-awareness-graph-v2-claude-code.md](../prompts/software-awareness-graph-v2-claude-code.md). +**Research shelf:** [2026-10_software_awareness_ona_ruff_research_excerpts.md](../../.arxiv/2026-10_software_awareness_ona_ruff_research_excerpts.md). +**Evidence contract:** [software-awareness-provenance-parity.md](../knowledge/software-awareness-provenance-parity.md). + +## 0. Research question, answer threshold, and limits + +Can a software graph that already queries its own compiled methods: (1) preserve independent, versioned observations; (2) make a **registered prediction before a code change**; (3) compare that prediction with an independent Ruff harvest or runtime oracle; and (4) change a subsequent prediction or experiment selection **because of** the observed mismatch? + +**Success is a measured closed loop, not self-awareness as consciousness:** a prediction is committed before the intervention; blind reharvest supplies observations; a controlled update affects the next decision, with an ablated no-feedback twin as the causal control. If recording an event does not alter any subsequent choice, it is instrumentation only. + +**Non-goals:** no new graph engine, second method registry, automatic self-rewriting, new NARS semantics or CE64 bit allocation, inferred permission grants, unpinned external runtimes, or performance claims from theoretical equivalence. + +## 1. Ground truth: #1496–#1509 in dependency order + +| PR | Actual shipped state | Role for D-SAG-2 | +|---|---|---| +| #1496 | docs: CE64 hypothesis layers/NAL polyfill; unresolved physical-vs-semantic reading conflicts | keep byte-level ISA immutable; readings versioned | +| #1497 | docs: PLN/Shannon/EIG and attention falsifiers | candidate schedulers; **not** truth laws | +| #1498 | docs: Hyperon/MeTTa fold parity | preserve multiplicity, binding, nested values and snapshot semantics | +| #1499 | docs: NARS self, evidence provenance/fission and snapshot | independent contributors, revision/ablation semantics | +| #1500 | docs: Heckhausen/Gollwitzer Rubicon | revocable commitment distinct from hypothesis | +| #1501 | docs: Class × Schema × Methods HotPlug | existing inventory/binding seam; no second registry | +| #1502 | docs: GPO/Intune/Linux policy baseline; no policy reader implemented | configured ≠ assigned ≠ observed | +| #1503 | code: dir-sim membership-path witnesses; Held/NotHeld/Undetermined/NotDeclared roles | missing evidence must not become negative authorization | +| #1504 | code: class-qualified MethodTable → Quack/R2IL; NarsRevision law | execution contract and independent row oracle | +| #1505 | code: native CPU default and portable v3 config | pinned build tier/performance fairness | +| #1506 | code: compute DAG Kahn over all 256 field positions | dependency cycles and wide-field gate | +| #1507 | code: runtime text declarations → same MethodTable prepare path | source change without recompiling executor | +| #1508 | code: Gremlin V/has/where/values/dedup/count/sum; predicates inlined at prepare | caller/callee relationships; relation hops refused | +| #1509 | code: SoftwareGraph, typed tiers, compiled programs, Quack one-hop queries, H1 candidate | direct base, **not** a general introspective reasoner | + +Confirmed seams: +- glove-parity/src/method.rs: MethodKey is caller-issued; schema seal is local FNV over ordered basis; ReadingId and Universe gate calls; Action is named but pure dispatch refuses it. +- glove-parity/src/gremlin.rs: NoRelationCarrier for in/out/both; effects have no executable Gremlin steps. +- glove-parity/src/awareness.rs: SoftwareGraph projects MethodTable; edge table Binder → Draft → ScatterOrU32; provenance tiers Declared/Derived/Compiled/Verified/Hypothesis. +- glove-parity/examples/awareness_loop.rs: H1 is a **candidate**. Existing tiled masked sum was reported ~1.59–1.78× scalar reference; fused SIMD terminal and post-fusion improvement are NOT measured. +- #1509 plan acknowledges generic multi-hop, canonical cross-build digest, and durable source revisions as unfinished. + +## 2. Proposed contract: typed observations without competing authority + +Conceptual records only, **not** an ABI or new CE64 reading: + +~~~text +ObservationReceipt { + id, source_kind: RuffHarvest | Compiler | RuntimeOracle | Benchmark | Policy, + source_revision, snapshot_revision, operation_or_method_key, + schema_seal, reading_id, universe, evidence_source_id, derivation_id, + observed_relation_or_outcome, observation_grade, + evidence_independence_key, collector_version, environment_fingerprint +} +PredictionReceipt { + id, preregistered_at_revision, frozen_input_snapshot, claim, + expected_delta_or_result, eligible_candidate_set, method_and_rule_version, + independent_oracle, abstention_policy, budget, decision_log +} +ResultReceipt { + prediction_id, oracle_revision, matched, unexpected, missing, unknown, + truth_or_semantic_parity, costs, control_arm, observed_counterexamples +} +~~~ + +Do NOT map collector verdict directly to compile-tier or verified-tier. Existing source proof and independent oracle evidence are different authorities. Keep "source declared", "derived from AST", "compiled", "oracle verified" and "hypothesis" separately. An external Ruff extraction cannot certify a runtime behavior without the independent runtime test. + +Identity must be scoped: (repository, revision, language, source-span-or-symbol, concept, seal, reading) → stable correspondence to method/class identity; **do not infer MethodKey from method label**. Preserve overload signatures, C linkage, Odoo qualified identities, and Ruby event order as appropriate. Introduce a mapping **adapter** only after proving exactness of all supported predicates and an explicit residual category for unsupported facts. + +Avoid version-blind provenance merges. Full graph snapshot and delta semantics should be decided by a falsifier before changing storage. When using hypothesis overlays, identical evidence seen in multiple layers must not add independent confidence. + +## 3. Audit first: three probable failure modes, all UNVERIFIED + +**A. Shared-edge provenance.** In awareness.rs, link() deduplicates on (src,rel,dst,tier), excluding ctx/prov. If two method contexts share a field→claim edge, reprojecting one method can remove a witness or leave ownership missing. Reproduce with two contexts, two revisions, one shared edge. Prove the precise invariant; **do not fix preemptively**. + +**B. Compute DAG invalidation.** project_compute() appends ComputesFrom and ComputeCycle verdict edges but does not mirror project()'s per-method cleanup. Reproject cyclic→acyclic and dependency A→B to A→C under the same class. Inspect stale edges and refuse the wrong version. Distinguish historical evidence from current projection. + +**C. Oracle trust/certificates.** certify() checks method digest/seal, while caller supplies the test identifier and proof. It does not authenticate the execution receipt. An untrusted caller could submit a certificate with current digest. Mark accepted metadata versus independently verified test execution; require a registered oracle runner to upgrade to Verified. Avoid changing existing API until compatibility tested. + +Additional audits: caller-issued MethodKey; FNV(Debug(MethodSpec)) cross-build stability; caller-supplied SAG_REV; temporal snapshot consistency; edge source ownership; duplicate evidence; memory-only graph; execution and graph projection cost (avoid hot-path instrumentation). + +## 4. Implementation waves, authorization, and deliverables + +### D-SAG-2-0: frozen oracle inventory (no code) + +- Pin baseline #1509 merge SHA and Ruff revision, relevant ONA/OpenNARS/Hyperon reference commits before execution. +- Record supported Ruff IR predicates versus residuals by language, with explicit Odoo/Rails/C++/C# limitations. +- Establish independent scalar/original runtime oracles. Record adversarial fixtures before designing answers. +- Run unchanged #1509 tests and benchmarks only in the actual toolchain; do not claim CI from documentation. + +Gate: reproducible source ledger and no ungrounded "supported" predicates. + +### D-SAG-2-1: provenance and revocation hardening (tests first) + +- Falsify or clear issues A–C, including identical shared relations with separate contexts. +- Define authoritative evidence source, derivation, observation, revision, schema/reading and test certificate roles, with no evidence duplication. +- Check snapshot pinning (version k replay remains identical while k+1 appends). Separate historical receipt preservation from current projection deletion. +- Write a negative control: forged Verified, stale seal/body, reinterpreted reading and wrong CPU tier must not be current proof. + +Gate: every mutation triggers a red test before a minimal fix; no new engine or broad schema redesign. + +### D-SAG-2-2: Ruff → SAG independent read-only observation + +- Compare Ruff ModelGraph and emitted Triples for **supported projection only** against SAG mapping; align identity with explicit correspondence map. +- Python/Odoo: inheritance, compute dependencies and view inherit_id/anchors; Ruby/Rails: ordered MethodOre, private helpers, guard/order; C++: overloads, signatures, no overloaded C file-scope static semantics; C#: preserve out-of-proc Roslyn provenance. +- Keep Ruff's reassemble() restriction visible: currently inverse only for the C++ machine-plane **projected form**, not core-7 and OpenProject. +- Never fabricate free-function dispatches_to: Ruff #118 explicitly keeps C free-function calls frontend-local. +- Collect accepted/rejected/residual facts, missing edges, extra edges, identity collision counts, and time/memory cost. + +Gate: structural parity only within declared supported subset; unsupported remains Unknown, not False. + +### D-SAG-2-3: prediction → independent intervention → revision (the main proof) + +- Snapshot revision A. Before a change, emit PredictionReceipt for impact on affected methods, classes, edges or authorization. +- Apply controlled edit in a fixture branch, separately reharvest revision B with Ruff; independently run semantic oracle where needed. +- Compare delta with the prediction; stratify matched/missing/extra/unknown and evidence class; count precision/recall only on complete labeled universe. +- Update a *contextual hypothesis* or experiment priority from the negative/positive receipts, never rewrite compiler- or source-authoritative truth. +- Repeat on a new seed with **identical model, budget, candidate order and fixtures** except feedback enabled versus disabled. + +Gate: preregistered prediction changed by evidence; a paired ablation demonstrates an effect on subsequent decision and reports failures/no-effect without inventing improvement. + +### D-SAG-2-4: ONA, NARS, PLN, EIG and Rubicon controls + +- ONA-inspired operation cycle = context → precondition → expected event → operation proposal → observed event → revision. Trace it with receipts, not consciousness claims. NAL-9 introspective research is not proof ONA implements it completely. +- Preserve NARS evidence independence, with explicit repeated-source/independent-source controls. Jøsang fission is a *separate control law*, never a drop-in NARS replacement. +- Scheduler-only comparison: FIFO, confidence priority, naive Shannon entropy, calibrated EIG and Staunen/Moore. Freeze candidate pool, inference rules, oracle and resource budget. Then freeze scheduler and compare reasoning laws. High-entropy irrelevant distractors must not win by default. +- Rubicon phases: deliberate → commit revocable if-then plan → check authority **at execution** → observe outcome → revise/disengage. A committed plan grants no privilege; OGAR is only DO authority. An Undetermined directory role fails closed. +- Snapshot consistency and branch multiplicity are hard correctness preconditions for Hyperon-like folds/rewrites. + +Gate: if no benefit with paired controls, keep scheduling hypothesis falsified and do not add runtime machinery. + +### D-SAG-2-5: generic multi-hop and optimization proposal (separate, gated) + +- First show the exact two-hop query that #1509 cannot perform with one legal Quack Program, then evaluate #1508 D-CMH-G1-4 **relation carrier** or existing EqU32Via; do not feed an intermediate population mask between programs illegally. +- Compare Odoo/Ruby structural relation paths with dir-sim's existing witnessed BFS as an **independent oracle**, not a replacement engine. +- H1 fusion: output parity across NULL/UNKNOWN, 1/64/65/4097+ rows, bags/sets, no false primitive claim; benchmark at named native and v3 tiers, medians, allocations, decoded bytes and control cost. Show separate performance results for direct current Program, scalar reference and actual compiled fused candidate (if authorized later). +- Candidate life cycle: hypothesized → structurally feasible → semantically oracle verified → multi-workload cost measured → operator-approved or rejected. No self-change application in this plan. + +Gate: performance claim only after a real fused program exists and passes the parity oracle. + +## 5. Falsification matrix (pre-register before implementing) + +| ID | Deliberately adversarial case | Fails if | +|---|---|---| +| SAG2-P01 | two methods share field→claim; reproject one | other owner's witness/provenance lost | +| SAG2-P02 | compute DAG A→B becomes A→C, cyclic becomes acyclic | old current edges/refusal survive | +| SAG2-P03 | fake test name with matching digest | verified-tier accepted as independent proof | +| SAG2-P04 | same method label across class/seal/reading | identities collapse | +| SAG2-P05 | duplicate evidence in two hypothesis layers | belief confidence rises twice | +| SAG2-P06 | replay pinned k while k+1 appends | result changes or physical snapshot drifts | +| SAG2-P07 | Ruff Ruby equal (W,R,X,C) sets, different event order | SAG asserts behavioral equivalence | +| SAG2-P08 | C file-scope static vs C++ static method | semantic conflation | +| SAG2-P09 | Ruff reassemble(core-7) | unsupported roundtrip silently called lossless | +| SAG2-P10 | Odoo view parent edit/extension anchors | delta impact guessed without source witness | +| SAG2-P11 | unknown or unsupported relation | absence reported as proven False | +| SAG2-P12 | multi-hop call dependency | hidden second evaluator or invalid population intermediate | +| SAG2-P13 | 63/64/255 compute field cycle | DAG check misses edge | +| SAG2-P14 | prediction registered only after edit | leaked result counted as forecast | +| SAG2-P15 | feedback disabled twin versus revision-enabled | same choices misreported as learning | +| SAG2-P16 | correlated evidence and irrelevant high-entropy distractors | attention metric rewarded without useful oracle findings | +| SAG2-P17 | staged action with Undetermined role/revoked commit | action permitted by attention/prediction | +| SAG2-P18 | H1 mixed workloads/CPU tier and NULL | speed claim despite mixed/parity failure | +| SAG2-P19 | Hyperon 4-result nondeterminism | 2-result mask incorrectly called equivalent | +| SAG2-P20 | Ruff harvest versus original program behavior | static fact treated as runtime proof | + +Use positive/negative twins and disable one guard at a time. Report test names, red-before-fix result, measured environment and orphaned concerns. Unknown is an acceptable **typed answer**. + +## 6. Report schema and success metrics + +For each experiment publish: exact base SHA, Ruff SHA, fixture/license, source spans, source/oracle independence, proposition, forecast timestamp/revision, affected identities, emitted evidence count, unsupported residues, known truth universe, TP/FP/FN/Unknown, replay check, authorization verdict, budget, CPU tier, allocations, wall/CPU time, number of mask/lane decodes, observation/learning/control ablations, and explicit pass/fail/undetermined. + +Never collapse structural correctness, epistemic uncertainty and execution cost into a scalar "awareness score." A score cannot override authority, independent provenance or semantic equivalence. If using MDL, preserve #1509's result: single-condition shared reuse need not improve description length. + +## 7. Architectural decisions needing explicit sign-off + +1. Source-of-truth for durable method identities, currently caller issued, and schema/readings versioning; OGAR #357 is still a proposal at the #1509 base. +2. Who may issue and authenticate independent test receipts (not arbitrary claim()). +3. Provenance deduplication semantics: (src,rel,dst,tier,ctx,prov) or separate witnesses per logical edge; preserve shared edges, not duplicate facts. +4. Graph persistence and snapshot pinning: memory-only v1 vs Lance receipts; no write-back to compiler authority. +5. Explicit unsupported/residual contract for polyglot AST harvest and #1508 relation carrier. +6. Permission-gated action proposal semantics and rollback, without conflating NARS evidence, Rubicon commitment and OGAR authority. + +**Stop conditions:** any incorrectly upgraded authority, double-counted source, non-replayable snapshot, nondeterministic oracle mismatch presented as parity, hidden second engine, or false H1 speedup claim. Repair first; do not widen scope. + +## 8. Sources and exact entry points + +Internal: [#1496](https://github.com/AdaWorldAPI/lance-graph/pull/1496), [#1497](https://github.com/AdaWorldAPI/lance-graph/pull/1497), [#1498](https://github.com/AdaWorldAPI/lance-graph/pull/1498), [#1499](https://github.com/AdaWorldAPI/lance-graph/pull/1499), [#1500](https://github.com/AdaWorldAPI/lance-graph/pull/1500), [#1501](https://github.com/AdaWorldAPI/lance-graph/pull/1501), [#1502](https://github.com/AdaWorldAPI/lance-graph/pull/1502), [#1503](https://github.com/AdaWorldAPI/lance-graph/pull/1503), [#1504](https://github.com/AdaWorldAPI/lance-graph/pull/1504), [#1505](https://github.com/AdaWorldAPI/lance-graph/pull/1505), [#1506](https://github.com/AdaWorldAPI/lance-graph/pull/1506), [#1507](https://github.com/AdaWorldAPI/lance-graph/pull/1507), [#1508](https://github.com/AdaWorldAPI/lance-graph/pull/1508), [#1509](https://github.com/AdaWorldAPI/lance-graph/pull/1509). + +Ruff: [AdaWorldAPI/ruff](https://github.com/AdaWorldAPI/ruff), [polyglot RFC](https://github.com/AdaWorldAPI/ruff/blob/main/.claude/OGAR-POLYGLOT-AST-INTEGRATION.md), [ModelGraph](https://github.com/AdaWorldAPI/ruff/blob/main/crates/ruff_spo_triplet/src/ir.rs), [C++-only reassembler](https://github.com/AdaWorldAPI/ruff/blob/main/crates/ruff_spo_triplet/src/reassemble.rs), [#117 order](https://github.com/AdaWorldAPI/ruff/pull/117), [#118 C linkage](https://github.com/AdaWorldAPI/ruff/pull/118), [#120 Odoo views](https://github.com/AdaWorldAPI/ruff/pull/120). + +Primary literature and independent runtimes: see the .arxiv shelf. All external implementation versions are **not pinned for execution yet**. + +## 9. Deferred-probe expansion after initial D-SAG-2 draft + +An additional source-grounded adversarial pass is documented in [SAG observability, causality, metamorphic testing and adaptive evaluation](../knowledge/sag-v2-observability-causality-and-evaluation-addendum.md) with **SAG2-P21..P40**. Its supplemental primary-source shelf is [ONA anticipation, do-nothing controls, adaptive holdouts and metamorphic relations](../../.arxiv/2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md). + +This expansion does **not** mark a new wave as shipped or authorize new runtime semantics. Before D-SAG-2-3, settle observation completeness, negative evidence admission, independent source stamps, NoOp/Probe/action distinctions, and protected unseen evaluation. Keep introspective telemetry on k+1 while reading k. The 20 new probes are extensions of the original P01–P20, not replacements. + diff --git a/.claude/prompts/software-awareness-graph-v2-claude-code.md b/.claude/prompts/software-awareness-graph-v2-claude-code.md new file mode 100644 index 000000000..72fb5a887 --- /dev/null +++ b/.claude/prompts/software-awareness-graph-v2-claude-code.md @@ -0,0 +1,72 @@ +# Claude Code work prompt — D-SAG-2: falsify, observe, predict, revise + +**Base:** lance-graph main at merged #1509 (42fa2a347cda22eaaa327bba514f2029cc9daa82). Read the plan `../plans/software-awareness-graph-v2-ruff-ona-closed-loop.md`, the evidence contract `../knowledge/software-awareness-provenance-parity.md`, and the primary-source shelf `../../.arxiv/2026-10_software_awareness_ona_ruff_research_excerpts.md` before editing code. + +## Mission + +Make the existing SoftwareGraph's predictions **independently falsifiable**, then determine experimentally whether feedback from Ruff or a runtime oracle can improve a subsequent prediction or decision. Preserve one Quack → mask-risc execution substrate; R2IL remains an alternate lowering frontend; OGAR remains sole authority for external effects. Treat #1496–#1501 as design/research and #1503–#1509 as partial implemented foundations. No second graph engine or ontology. + +## Read-first files + +- lance-graph: crates/lance-graph-glove-parity/src/{awareness,method,decl,gremlin}.rs; tests/{awareness,compose,declared,gremlin}.rs; examples/awareness_loop.rs. +- lance-graph: crates/lance-graph-quack/src/{bind,lib}.rs; crates/lance-graph-r2il/src/procs.rs; crates/lance-graph-contract/src/{class_view,hotplug}.rs; crates/lance-graph-dir-sim/src/{actors,view}.rs. +- Ruff: crates/ruff_spo_triplet/src/{ir,expand,reassemble,triple}.rs; crates/ruff_{python,ruby,cpp,csharp}_spo; crates/ruff_r2il; .claude/OGAR-POLYGLOT-AST-INTEGRATION.md. +- Existing plans/primary excerpts in PRs #1496, #1497, #1498, #1499, #1500, #1501, #1508 and #1509. Search actual code before asserting a function exists or a gate shipped. + +## Order of execution + +1. **Inventory on exact revisions.** Obtain repository HEAD SHA and each dependency revision; mark contract shipped/tested, research-only, or unknown. The initial plan uses #1509's merge; if main advanced, reconcile rather than silently substitute the branch. +2. **Try to refute three audit findings first.** Write small tests in existing glove-parity test modules: + - link() shared-edge ctx/provenance dedup versus partial reproject; + - project_compute() replacement across changed class DAG and cycle status; + - caller-issued Certificate with forged test name accepted as Verified. + For each: record failing reproduction or evidence that the claim was false. Do not implement fixes until the falsifier is real. Ensure that a historical receipt and a current projection are different concepts. +3. **Define the minimal receipt contract.** Exact source revision, snapshot, evidence source key, derivation, observed relation, method key, schema seal, reading, universe, oracle result, environment fingerprint. Distinguish verified test from user annotation and compiler verdict; a note must never promote itself. +4. **Ruff side, in read-only adapter/probe only.** Pin Ruff SHA. Select minimum supported fixtures: + - Odoo model and parent/extension view (`inherit_id`); + - Ruby model with same unordered body-facts but different ordered MethodOre; + - C file-scope `static` versus C++ static method, overloaded C++ methods; + - explicit unsupported round-trip (core-7) and unprojected free-function calls. + Build an exact crosswalk from Ruff identifiers/provenance to SAG identifiers or emit typed residuals. Do not infer universal cross-language equality. +5. **Impact forecasting.** Freeze A and produce a machine-readable PredictionReceipt **before** altering a fixture; edit to B in a separate commit; reharvest blind. Compare predicted and observed deltas with TP/FP/FN/Unknown (only on supported complete universe) and source-span evidence. +6. **One feedback mechanism, not a reasoning empire.** Choose the smallest revisable hypothesis over candidate impact/unknown, update it only from independently stamped outcomes. Repeat a paired case with evidence feedback disabled, same budget and candidate order. If the chosen subsequent action doesn't change or doesn't improve the predeclared target, report that; do not claim learning. +7. **Only after above gates:** compare scheduler variants (FIFO, confidence, Shannon, EIG, Moore/Staunen), evidence overlap/fission, and Rubicon commitment/rollback. Separate scheduling from inference law and permission checks. Keep effect execution unimplemented unless operator authorizes a future PR. +8. **H1 optimization stays a separate experiment.** Existing 1.59–1.78× scalar cost gap is not improvement. Benchmark a real fused implementation only if separately approved after correctness and NULL/UNKNOWN controls; publish native/v3 tiers. + +## Concrete acceptance tests + +- P01: shared field claim has two independent ownership witnesses; reprojecting one doesn't erase the other's claim. +- P02: compute dependency/cycle disappears in current projection at B, while history (if kept) is explicitly versioned. +- P03: forged run metadata cannot create independent Verified proof. +- P04–P09: class/seal/reading identity, dependent stamps, pinned snapshot, Ruby event order, C semantic distinction, restricted Ruff round-trip. +- P10–P13: Odoo view impact, explicit unknown, typed NoRelationCarrier, full 256-position DAG. +- P14–P16: preregistered forecast, failed-feedback ablation, irrelevant entropy distractors. +- P17–P20: Undetermined role cannot authorize, H1 mixed-workload/NULL counterexample, Hyperon four-branch cardinality, static ≠ runtime behavior. +- Every guard fixed must have disable-red-run evidence. A passing assertion against handwritten expected fixtures alone is not an independent oracle. + +## Mandatory outputs from the coding session + +Provide: exact files changed; design decision ledger; list of falsifiers with red/green and counterexamples; fixture and oracle identifiers; CI commands and *actual* outcomes; measured cost per variant; unresolved typed gaps; a source/revision table; and either a narrowly scoped implementation PR (only the passed wave) or a clear blocker report. + +Track predictions and observed outcomes separately, with timestamps or pinned revisions. Permit the correct conclusion to be "no improvement", "Unknown", or "this layer cannot express that relation". Keep the register/ISA bytes unchanged; any new semantic reading or method authority requires a separately reviewed contract. + +## PR hygiene + +- No editing the generated board index by hand; if adding a board entry run .claude/tools/entries_index.py --write and --check, retaining the curated finding column. +- Run plan_dids.py, append_only_gate.py and relevant repository CI gates as applicable; do not claim they passed unless executed. +- Avoid status-board inflation: distinguish shipped, measured locally, untested, proposed and blocked. +- Do not auto-merge, grant permissions, modify policy, deploy or overwrite source code as a side effect of an awareness conclusion. + +## Required deferred-probe supplement (read before implementation) + +Read `../knowledge/sag-v2-observability-causality-and-evaluation-addendum.md` and `../../.arxiv/2026-10_software_awareness_ona_observability_metamorphic_holdout_excerpts.md`; they add P21–P40 to the previous P01–P20. In particular: + +- Refutation by missing observation is legal **only** when Ruff/runtime collector positively certifies predicate support, scope completeness, matching frozen revision, successful scan and closed observation interval. Otherwise return `NotObservable`, `Incomplete`, `Pending` or `Stale`. ONA's published *Assumption of Failure* is a research mechanism, not a license for closed-world Ruff assumptions. +- Distinguish `NoOp` causal control, read-only `Probe` (it consumes resources), and inert `Proposal` before any OGAR-gated action. Try A→A no-op, semantic-preserving A→B, real change A→B, and A→B→A' revert. +- Obtain preregistered predicted deltas before editing. Compare full versus incremental reharvest; keep one evidence stamp for multiple pipeline copies of the same source fact; test independent-source twins. +- Use development / validation / protected holdout **grouped by repository and edit family**, not randomly selected lines, and count oracle reuse. On frozen holdout test no-feedback, correct-feedback, shuffled-feedback, and no-op arms with identical budget; record null or negative results honestly. +- Bound self-observation recursion: a Quack query sees snapshot k, its telemetry writes k+1; no query in the same epoch may certify itself. +- Preserve separate source-revision/event-time/ingestion-time/decision-time and treat late receipts or partial coverage explicitly. Never turn attention score, CARE heuristic or popcount of unknown cells into truth/authorization or alter CE64's byte/ISA contract. + +Run the original P01–P20 gates before claiming D-SAG-2 success. The deferred P21–P40 tests are additional hypotheses, not claims of implementation. +