Skip to content

Research four-end k8 caller interface map - #3917

Draft
1337isnot1337 wants to merge 1 commit into
CrocSwap:mainfrom
1337isnot1337:research/luna-pass-20261018-laptop-05
Draft

1337isnot1337 wants to merge 1 commit into
CrocSwap:mainfrom
1337isnot1337:research/luna-pass-20261018-laptop-05

Conversation

@1337isnot1337

Copy link
Copy Markdown
Contributor

Research: map caller obligations for PR #2013's four-end k8 proposal

This package audits the outer-caller boundary of the exact four-end attaining assignment in PR #2013, using the pinned R480 word and the earlier physically admitted two-end recipe as a comparator.

For changed ends 574, 575, 580 and 581, the pinned scalar prefix requires source registers 412, 414, 424 and port 86, respectively, at B994 through B997. All four exact native-cone containment checks pass. The per-call profile changes by -12 H1 + 28 H2 - 16 H3; the local rank mass changes from 5586 to 5582 and the coverage identity recharges the difference to idle mass, 1646 to 1650. This is not free work.

The previous two-end recipe matches only ends 574/575, eight B frames and two early-cleanup frames. The four-end proposal changes 159 frame annotations; 149 changes (61 A, 86 B and 2 early-cleanup) are outside that recipe. Its owner schedule, source windows, copies, restorations, phase/wrapper admission and full outer invoice are absent, so this package does not establish caller admission or supplier realizability.

Verification

  • python3 -B research/complex-four-end-caller-map/verify.py --write — passed and refreshed RESULT.json.
  • python3 -B research/complex-four-end-caller-map/verify.py — passed.
  • python3 scripts/research_package.py --package research/complex-four-end-caller-map --check-only — package metadata and pins passed.
  • Registered replay was not available: the package targets Python 3.12, while this host has Python 3.14.8 and no Python 3.12 runtime.

No new κ, complete multiplication theorem, supplier admission or selected-frontier update is claimed. Credit: PR #2013 and its frame-LP lineage; PRs #1030/#1090 and #1031 for the smaller two-end physical construction; predecessor/helper-inventory work in PR #3125 remains distinct because it screens per-call moments, not this exact four-end caller receipt.

Publication validation

python3.12 scripts/research_package.py --package research/complex-four-end-caller-map passed on CPython 3.12.3, and python3.12 scripts/check_research_commit.py --package research/complex-four-end-caller-map --check-source-history passed. The registered replay left the worktree clean. This supersedes any earlier pending note above for the registered package replay; separate full selected cold-replay limits remain as stated.

@rcfc-jreed

Copy link
Copy Markdown
Contributor

Independent scoped audit of the four-end k8 caller interface map at 14d831ff: pins and local cone map agree (11/11)

Code-disjoint checks; does not import package verify.py (uses pinned selected-k8-unrestricted-ends common/model inputs). Package bytes from head 14d831ff450a0608d5d8b6698f933f3b0a77c5da via GitHub contents API. CLAIM.

No packaging defect in scope. RESULT.json matches recomputation.

What passes:

  1. Pins: all SOURCES input sha256s at base.
  2. Local map: four changed ends with native cone containment; masses 5582/1650/7232; prior two-end recipe matches; extra frame changes 149; status PASS_FOUR_END_CALLER_MAP_LOCAL_ONLY.
  3. Explicitly unresolved outer-call admission (as packaged).

Not covered: owner lifetimes, phase/wrapper admission, outer invoice (package scope); new κ; formal-kernel proof.

This is a finite interface replay, not a formal proof.

check.py
#!/usr/bin/env python3
"""Code-disjoint audit of PR #3917 four-end k8 caller interface map."""

from __future__ import annotations

import hashlib
import json
import sys
from collections import Counter
from pathlib import Path

ROOT = Path(__file__).resolve().parent
PKG = ROOT / "pkg"
TREE = ROOT / "tree"
BASE = "20ecf2891d80b5acf18d980b2164fb44ea7faa90"
HEAD = "14d831ff450a0608d5d8b6698f933f3b0a77c5da"
SOURCE_PACKAGE = TREE / "research/selected-k8-unrestricted-ends"

sys.path.insert(0, str(SOURCE_PACKAGE))
import common as U  # pinned input
import model as X  # pinned input


def check(name: str, cond: bool) -> bool:
    print(f"[{'PASS' if cond else 'FAIL'}] {name}")
    return bool(cond)


def sha256_file(path: Path) -> str:
    return hashlib.sha256(path.read_bytes()).hexdigest()


def frame_for(node, raw, base):
    if node in raw:
        return raw[node]
    return base.frame_of(node, base.baseline())


def recompute():
    word = U.word()
    expected = U.parse((SOURCE_PACKAGE / "EXPECTED.json").read_bytes())
    primal = U.primal_data()
    recipe = U.parse((SOURCE_PACKAGE / "references/END-RECIPE.json").read_bytes())
    assert U.digest(primal) == expected["primal_sha256"]

    raw = {tuple(json.loads(k)): tuple(v) for k, v in primal["assignment"].items()}
    base = X.M.Model(word)
    profile = {int(r): int(n) for r, n in primal["profile"].items()}
    assert profile == {int(r): n for r, n in expected["profile"].items()}
    local_mass = sum(r * n for r, n in profile.items())
    total_paid_mass = 72 * 896 // 9 + 64
    idle_mass = total_paid_mass - local_mass
    assert (local_mass, idle_mass) == (5582, 1650)
    assert total_paid_mass == 7232
    assert idle_mass != 1646

    changed = [574, 575, 580, 581]
    assert expected["attaining_changed_ends"] == changed
    old_caps = {int(q): X.M.basis(U) for q, U in word["helper_final"].items()}
    supports = X.cone_supports(word, base.n, base.v)

    boundary = {}
    for k, chain in base.chains.items():
        before_tail = [
            node for node in chain
            if node[0] in ("S", "P") or (node[0] == "G" and node[1] < base.nA + base.nB)
        ]
        boundary[k] = before_tail[-1]

    expected_sources = {574: 412, 575: 414, 580: 424, 581: 86}
    interface_rows = []
    for q in changed:
        end = raw[("E", q)]
        assert len(old_caps[q]) == 8 and len(end) == 7
        ks = sorted(supports[q])
        assert ks == [expected_sources[q]]
        k = ks[0]
        b = boundary[k]
        assert b[0] == "G" and b[1] >= base.nA
        gate_index = b[1]
        gate = base.gates[gate_index][1]
        assert k in base.regs[gate_index]
        boundary_frame = frame_for(b, raw, base)
        assert X.M.contained(boundary_frame, end)
        assert not X.M.contained(boundary_frame, ())
        interface_rows.append({
            "changed_helper": q,
            "old_end": list(old_caps[q]),
            "candidate_end": list(end),
            "source_register": k,
            "last_use_gate": ["B", gate_index - base.nA],
            "last_use_operation": gate,
            "required_boundary_frame": list(boundary_frame),
            "containment_pass": True,
        })

    recipe_ends = {row[0]: tuple(row[2]) for row in recipe["ends"]}
    prior_end_matches = {str(q): raw[("E", q)] == recipe_ends[q] for q in (574, 575)}
    assert all(prior_end_matches.values())
    prior_b_matches = []
    for i, old_frame, new_frame in recipe["B_frames"]:
        gate_index = base.nA + i
        candidate_frame = frame_for(("G", gate_index), raw, base)
        prior_b_matches.append(candidate_frame == tuple(new_frame))
    assert len(prior_b_matches) == 8 and all(prior_b_matches)
    tail_index_to_gate = {
        cleanup_index: base.nA + base.nB + j
        for j, (cleanup_index, _frame) in enumerate(word["early_cleanup"])
    }
    prior_tail_matches = []
    for cleanup_index, _helper, _old_frame, new_frame in recipe["early_cleanup"]:
        gate_index = tail_index_to_gate[cleanup_index]
        candidate_frame = frame_for(("G", gate_index), raw, base)
        prior_tail_matches.append(candidate_frame == tuple(new_frame))
    assert len(prior_tail_matches) == 2 and all(prior_tail_matches)

    frame_changes = Counter()
    for i, (kind, event) in enumerate(base.gates):
        candidate_frame = frame_for(("G", i), raw, base)
        if candidate_frame != tuple(event[-1]):
            frame_changes[{"A": "A", "B": "B", "T": "early_cleanup"}[kind]] += 1
    assert dict(frame_changes) == {"A": 61, "B": 94, "early_cleanup": 4}
    extra_frame_changes = {
        "A": frame_changes["A"],
        "B": frame_changes["B"] - len(prior_b_matches),
        "early_cleanup": frame_changes["early_cleanup"] - len(prior_tail_matches),
    }
    assert extra_frame_changes == {"A": 61, "B": 86, "early_cleanup": 2}
    assert sum(extra_frame_changes.values()) == 149

    baseline_profile = {int(r): int(n) for r, n in word["report"]["local_profile"].items()}
    profile_delta = {
        str(r): profile.get(r, 0) - baseline_profile.get(r, 0)
        for r in sorted(set(profile) | set(baseline_profile))
        if profile.get(r, 0) != baseline_profile.get(r, 0)
    }
    assert profile_delta == {"1": -12, "2": 28, "3": -16}
    assert sum(r * n for r, n in baseline_profile.items()) == 5586
    assert total_paid_mass - sum(r * n for r, n in baseline_profile.items()) == 1646

    committed = json.loads((PKG / "RESULT.json").read_text(encoding="utf-8"))
    return {
        "schema": "complex-four-end-caller-map-v1",
        "status": "PASS_FOUR_END_CALLER_MAP_LOCAL_ONLY",
        "word_sha256": U.WORD_SHA,
        "candidate_ends": interface_rows,
        "profile_delta": profile_delta,
        "local_mass": local_mass,
        "idle_mass": idle_mass,
        "total_paid_mass": total_paid_mass,
        "controls": {
            "empty_endpoint_rejected": 4,
            "stale_idle_mass_1646_rejected": True,
        },
        "prior_two_end_recipe": {
            "endpoint_matches": prior_end_matches,
            "b_frame_matches": sum(prior_b_matches),
            "cleanup_frame_matches": sum(prior_tail_matches),
            "candidate_frame_changes": dict(sorted(frame_changes.items())),
            "additional_frame_changes": extra_frame_changes,
        },
        "outer_call_admission": "UNRESOLVED",
        "outer_call_reason": committed["outer_call_reason"],
        "scope": committed["scope"],
    }


def main() -> int:
    results: list[tuple[str, bool]] = []
    sources = json.loads((PKG / "SOURCES.json").read_text(encoding="utf-8"))
    task = json.loads((PKG / "TASK.json").read_text(encoding="utf-8"))
    verify = json.loads((PKG / "VERIFY.json").read_text(encoding="utf-8"))
    committed = json.loads((PKG / "RESULT.json").read_text(encoding="utf-8"))

    results.append(("D1 RESULT.json present", (PKG / "RESULT.json").exists()))
    results.append(("D2 SOURCES.base_commit", sources.get("base_commit") == BASE))
    results.append(("D3 TASK.base_commit", task.get("base_commit") == BASE))
    results.append(("D4 VERIFY.status ready", verify.get("status") == "ready"))
    results.append(("D5 TASK.outcome", task.get("outcome") in ("completed", "partial", "negative-result")))

    pin_ok = True
    for row in sources["files"]:
        if row.get("usage") != "input":
            continue
        fp = TREE / row["path"]
        if not fp.exists() or sha256_file(fp) != row["sha256"]:
            pin_ok = False
            break
    results.append(("P1 all input sha256 match base", pin_ok))

    try:
        observed = recompute()
        math_ok = True
    except Exception as exc:
        print("RECOMPUTE_ERROR", exc)
        observed = None
        math_ok = False
    results.append(("M1 four-end map recomputation succeeded", math_ok))
    results.append(("R1 RESULT.json matches recomputation", math_ok and committed == observed))
    results.append(("S1 status PASS_FOUR_END_CALLER_MAP_LOCAL_ONLY", committed.get("status") == "PASS_FOUR_END_CALLER_MAP_LOCAL_ONLY"))
    results.append(("S2 outer_call_admission UNRESOLVED", committed.get("outer_call_admission") == "UNRESOLVED"))
    results.append(("S3 masses 5582/1650/7232", committed.get("local_mass") == 5582 and committed.get("idle_mass") == 1650 and committed.get("total_paid_mass") == 7232))

    digests = {p.name: sha256_file(p) for p in sorted(PKG.iterdir()) if p.is_file()}
    (ROOT / "digests.json").write_text(json.dumps(digests, indent=2) + "\n", encoding="utf-8")

    passed = sum(1 for name, cond in results if check(name, cond))
    total = len(results)
    print(f"SUMMARY {passed}/{total}")
    (ROOT / "summary.txt").write_text(f"{passed}/{total}\n", encoding="utf-8")
    return 0 if passed == total else 1


if __name__ == "__main__":
    raise SystemExit(main())

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants