Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
/evidence/README.md text eol=lf
/evidence/_template/** text eol=lf

/src/inferrsi/knowledge/atoms/casebooks/* -text

# Retain this upstream license's original CRLF Git blob bytes.
/src/inferrsi/knowledge/data/skill_library/systems/frameworks/torch-npu/torch-npu/references/licenses/op-plugin-LICENSE.txt -text

Expand Down
1 change: 1 addition & 0 deletions docs/apps-module-migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@
"tests/apps/test_apps_knowledge.py",
"tests/apps/test_optimization_session.py",
"tests/harness/test_harness_generation_seal.py",
"tests/knowledge/test_atomic_casebooks.py",
"tests/knowledge/test_atomic_records.py"
],
"status": "retired",
Expand Down
10 changes: 10 additions & 0 deletions docs/guides/knowledge/knowledge-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ entrypoint and content. The builder derives its navigation record. A Case
provides the original `case.json` so a finding can be reopened by stable ID or
by its JSON pointer at the requested revision.

For a Case backed by released files, `case_resources` maps each public resource
name to a pinned L3 node. The builder derives the entrypoint and required
resource order from the original `case.json`, checks relative paths against the
same source snapshot, and retains both names when the release exposed its JSON
under two names. The public L1 route takes one finding and delivers its source
span with the Case's original applicability, state, limits, credit and sources.
L0 opens the Case's navigation, L2 its guide, and L3 both complete originals.
The [Case migration tests](../../../tests/knowledge/test_atomic_casebooks.py)
replay the released Reader's decision cards through the installed public refs.

A self-contained Record keeps its released JSON bytes under `atoms/records/`.
Its L3 descriptor can declare named `parts`, each with a layer, source JSON
pointers, a half-open byte range and a digest. The builder seals each part as
Expand Down
104 changes: 103 additions & 1 deletion src/inferrsi/knowledge/atomic_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .atomic_json import matches_span, member_spans
from .atomic_reader import atom_material, permits_operations
from .decision_cards import DecisionSource
from .knowledge_operations import IDENTITY, Bundle, _json, safe_path
from .knowledge_operations import IDENTITY, Bundle, _json, case_required_resources, safe_path

_PUBLISH = {"read", "retain", "redistribute"}

Expand Down Expand Up @@ -41,11 +41,113 @@ def _record_content(metadata: dict, node: str, material: dict) -> bytes:
return _json(record)


def _verify_case_finding_routes(metadata, raw, record, material):
case = DecisionSource(metadata["id"], "", "case", "case.json", record["content"], record)
declaration = metadata["composition"]
members = member_spans(raw)
source = metadata["sources"][0]
nodes = declaration["nodes"]

def required_spans(roots):
pending, visited, spans = list(roots), set(), set()
while pending:
name = pending.pop()
if name in visited:
continue
visited.add(name)
if name not in nodes:
raise ValueError(f"Undeclared Case decision node: {name}")
node = nodes[name]
pin = AtomPin(node["ref"], node["revision"])
if pin not in material:
raise ValueError(f"Missing pinned Case decision node: {pin.ref}")
_, origin = material[pin]
if origin["source"] != source:
raise ValueError("A source-backed Case decision must use its original Case")
if origin["layer"] != "L1":
raise ValueError("A Case decision must use original L1 fields")
spans.add(tuple(origin["source_byte_range"]))
pending.extend(node.get("requires", []))
return spans

findings = members["/findings"]
for route in declaration["routes"].values():
if route["layer"] != "L1":
continue
selector = route.get("finding")
if not isinstance(selector, str):
raise ValueError("A Case L1 decision route needs one original finding")
index, _ = case.finding(selector)
member = members[f"/findings/{index}"]
selected = {(member.start, member.end)}
required = required_spans(route["required"])
optional = required_spans(route.get("optional", []))
overlapping = {span for span in required | optional
if span[0] < findings.end and findings.start < span[1]}
if not selected <= required or overlapping != selected:
raise ValueError("Case decision route must bind only its selected original finding")
declared = case.project(finding=selector)["card"]["declared"]
for field in declared.keys() - {"finding"}:
member = members["/" + field]
if not any(lo <= member.start and member.end <= hi for lo, hi in required):
raise ValueError(f"Case route omits a required original decision field: {field}")
for index in range(len(record["findings"])):
selected = select_routes(declaration, layer="L1", context={}, case=case,
finding=case.finding_locator(index))
if selected.refusal:
raise ValueError("Case must provide a decision route for every original finding")


def _case_content(metadata: dict, bindings: dict, material: dict) -> dict[str, bytes]:
"""Resolve the original Case and its declared relative resources from pinned L3 nodes."""
if not isinstance(bindings, dict) or "case.json" not in bindings:
raise ValueError("Case resources must bind the original case.json")
content, origins = {}, {}
nodes = metadata["composition"]["nodes"]
for name, key in bindings.items():
safe_path(name)
if not isinstance(key, str) or key not in nodes:
raise ValueError(f"Undeclared Case resource node for {name}")
node = nodes[key]
pin = AtomPin(node["ref"], node["revision"])
if pin not in material:
raise ValueError(f"Missing pinned Case resource for {name}")
body, origin = material[pin]
if not _complete_original(body, origin):
raise ValueError(f"Case resource requires a complete L3 original: {name}")
content[name], origins[name] = body, origin["source"]

source = origins["case.json"]
record = json.loads(content["case.json"])
if (not isinstance(record, dict) or record.get("kind") != "case"
or record.get("id") != metadata["id"] or source != metadata["sources"][0]):
raise ValueError("Case identity or pinned source differs from the original")
required = case_required_resources(record)
if (len(set(required)) != len(required) or set(bindings) != set(required)
or metadata.get("entrypoint", record["content"]) != record["content"]
or metadata.get("required_resources", required) != required):
raise ValueError("Case resource bindings must cover the original relative resources")
parent = PurePosixPath(source["path"]).parent
for name, origin in origins.items():
if name == "case.json":
continue
if (origin.get("repo") != source.get("repo") or origin.get("commit") != source.get("commit")
or origin.get("path") != (parent / name).as_posix()):
raise ValueError(f"Case resource differs from its original relative source: {name}")
metadata.update(entrypoint=record["content"], required_resources=required)
_verify_case_finding_routes(metadata, content["case.json"], record, material)
return content


def _authored(directory, path, field, descriptor, material) -> tuple[AtomPin, Bundle]:
metadata = descriptor["metadata"]
if field not in metadata or ("atom" in metadata and "composition" in metadata):
raise ValueError(f"{path.name} must declare one {field}")
content = {}
if "case_resources" in descriptor:
if field != "composition" or metadata["kind"] != "case" or "content" in descriptor:
raise ValueError("Only a Case composition may bind its content through case_resources")
content = _case_content(metadata, descriptor["case_resources"], material)
for name, value in descriptor.get("content", {}).items():
safe_path(name)
if isinstance(value, dict) and value.keys() == {"path"}:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"authority": "checkout",
"metadata": {
"id": "case.admission-drain-occupancy.guide",
"kind": "knowledge",
"title": "Admission occupancy is not whole-run occupancy",
"backend": "cuda",
"origin": [
"internal"
],
"state": "historical_observation",
"applicability": [
"Continuous admission, mixed prefill/decode and final drain",
"Recorded Drama3 B300 C64 diagnostic only"
],
"limitations": [
"Campaign INCONCLUSIVE",
"No new measurement or trace reproduction",
"Selected-phase occupancy is not service throughput",
"Raw evidence remains under its existing owner"
],
"attribution": "InferRSI issue #10 diagnostic evidence; extraction retains the original observation and its limits",
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/casebooks/inference/inference-optimization-casebook/cases/admission-drain-occupancy.md",
"sha256": "e88bbac5d253a8e7e3a3d5e21047f23f2970c11ac23887d4303ab94fca52dd27"
},
{
"type": "internal",
"issue": "https://github.com/InferMatrixLab/InferRSI/issues/10",
"run": "drama3-mixed-20261016",
"artifact": "vllm-continuous-schedule.json",
"sha256": "29e5cafe329cb85eaba69db7536a28a83fb7e3ac29bc154fc8747f317f6a4b3f",
"request_metadata_sha256": "bd50166976a4753b33c8aeb5a774ebb5711c74ccbba0df1843885f353ecdc996",
"integrity_status": "reported_not_rehashed",
"evidence_url": "https://github.com/InferMatrixLab/InferRSI/blob/c13027983b853fee3700de6aabde52b72e61885a/evidence/drama3-b300-scale150/results/diagnostic-lessons.md#continuous-admission-profile-and-mixed-backbone-2026-10-16"
}
],
"entrypoint": "admission-drain-occupancy.md",
"atom": {
"layer": "L3",
"when": {},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/casebooks/inference/inference-optimization-casebook/cases/admission-drain-occupancy.md",
"byte_range": [
0,
3134
],
"sha256": "e88bbac5d253a8e7e3a3d5e21047f23f2970c11ac23887d4303ab94fca52dd27"
}
}
},
"content": {
"admission-drain-occupancy.md": {
"path": "casebooks/admission-drain-occupancy.md"
}
}
}
Loading
Loading