Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/evidence/** -text
/tests/fixtures/legacy/** -text
/tests/fixtures/atomic-reader/** -text whitespace=-blank-at-eof
# Migrated task paragraphs and YAML headers retain their original LF separators.
/src/inferrsi/knowledge/atoms/task-*.md text eol=lf whitespace=-blank-at-eof
/src/inferrsi/knowledge/compositions/*-header.yaml text eol=lf whitespace=-blank-at-eof
# A session started by an older runtime keeps its exact bytes; its plan pins file hashes.
/tests/fixtures/optimization-session/pre-infra-removal-session/** -text
/tests/fixtures/optimization-session/pre-trials-rename-session/** -text
Expand Down
11 changes: 11 additions & 0 deletions docs/guides/knowledge/knowledge-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ by its JSON pointer at the requested revision.
builder appends their original bytes, including whitespace, to the L0 body.
A Reader request for L0 still returns the composition's L0 route. Each of
the seven public task names has one owner.
To preserve native host fields during migration, `skill.frontmatter` can
name a content resource in the pinned composition. The builder verifies its
name and description, requires exactly one header with no procedure text,
and emits its original bytes, including invocation settings and attribution.
The [executable authoring example](../../../tests/knowledge/test_atomic_generation.py)
builds all seven entries and a supporting skill.
- For the task-domain migration, read the [v0.3.4 owner and byte
map](../../../tests/fixtures/atomic-reader/task-domain-v0.3.4.json). Run
`inferrsi skills --root <generation>/skills enter task-debug` against a
built candidate to open the complete primary procedure. Use the same root
with `resource inference-task-router references/routes/debug.json` for its
original routing card. The card's candidate skill IDs identify owners to
consult in the other domains.
- The installer writes `knowledge/{atoms,compositions}/`, the generated catalog
and file digests in `knowledge/generation.json`, and `skills/<name>/SKILL.md`
with the declared references, assets and scripts. Two builds of the same
Expand Down
22 changes: 18 additions & 4 deletions src/inferrsi/knowledge/atomic_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import re
from collections.abc import Callable, Mapping
from io import BytesIO
from pathlib import Path, PurePosixPath
from tempfile import TemporaryDirectory

Expand All @@ -13,6 +14,7 @@
from .atomic_reader import atom_material, permits_operations
from .decision_cards import DecisionSource
from .knowledge_operations import IDENTITY, Bundle, _json, safe_path
from .skill_catalog import _frontmatter_parts

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

Expand Down Expand Up @@ -42,7 +44,8 @@ def _authored(directory: Path, path: Path, field: str) -> tuple[AtomPin, Bundle]
return AtomPin(ref, bundle.revision), bundle


def _host_skill(declaration: dict, nodes: dict, material: dict) -> tuple[str, dict[str, bytes]]:
def _host_skill(bundle: Bundle, nodes: dict, material: dict) -> tuple[str, dict[str, bytes]]:
declaration = bundle.metadata["composition"]["skill"]
name, description = declaration["name"], declaration["description"]
if (not isinstance(name, str) or len(name) > 64
or not re.fullmatch(r"[a-z0-9]+(?:-[a-z0-9]+)*", name)):
Expand All @@ -62,8 +65,19 @@ def _host_skill(declaration: dict, nodes: dict, material: dict) -> tuple[str, di
raise ValueError(f"Repeated host skill section in {name}")
body = b"".join(material[pin][0] for pin in pins)
markdown = body.decode("utf-8")
quoted = json.dumps(description, ensure_ascii=False)
header = f"---\nname: {json.dumps(name)}\ndescription: {quoted}\n---\n\n".encode()
if "frontmatter" in declaration:
path = safe_path(declaration["frontmatter"])
if path not in bundle.content:
raise ValueError(f"Missing pinned host frontmatter for {name}")
header = bundle.content[path]
stream = BytesIO(header)
host, _ = _frontmatter_parts(stream)
if (host.get("name") != name or host.get("description") != description
or stream.read().strip() or not header.endswith(b"\n")):
raise ValueError(f"Invalid host frontmatter for {name}")
else:
quoted = json.dumps(description, ensure_ascii=False)
header = f"---\nname: {json.dumps(name)}\ndescription: {quoted}\n---\n\n".encode()
output = {f"skills/{name}/SKILL.md": header + body}
resources = declaration.get("resources", {})
for relative, node in resources.items():
Expand Down Expand Up @@ -150,7 +164,7 @@ def _prepare(source: Path, permits: Callable[[AtomPin, str], bool], roots: Mappi
if route["layer"] not in layers:
raise ValueError(f"No required root supplies {route['layer']} for {pin.ref}")
if "skill" in declaration:
name, output = _host_skill(declaration["skill"], nodes, material)
name, output = _host_skill(bundle, nodes, material)
if name in skills:
raise ValueError(f"Multiple compositions export host skill {name}")
skills[name] = pin.ref
Expand Down
55 changes: 55 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-acceptance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"metadata": {
"id": "task-accuracy-acceptance",
"kind": "knowledge",
"entrypoint": "body.md",
"title": "Acceptance and handoff",
"state": "candidate",
"applicability": {
"scope": "Modality-specific reference parity and accuracy regression repair.",
"input_contract": "Actual hardware, model, engine, script and flags, benchmark, acceptance criteria, current diagnosis, permitted changes and budget.",
"produced_artifact": "First-divergence trace, before/after oracle results and held-out end-to-end quality checks.",
"refusal_point": "Record missing evidence or an exhausted search budget and identify the smallest discriminating test before declaring success."
},
"limitations": [],
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/tasks/task-accuracy/SKILL.md",
"sha256": "a441eb5565cd39674307f2cc870cb0d8d4c90314bb7df80245162df1dc3d1ae3"
}
],
"attribution": "InferRSI contributors",
"empirical_validation": "not_run",
"atom": {
"layer": "L1",
"when": {
"task": [
"task-accuracy"
]
},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/tasks/task-accuracy/SKILL.md",
"byte_range": [
4261,
4767
],
"sha256": "142403a4ec7eb056ee229f3cd153e64a37cc8f44a97eec4aedab53d81bbf1837"
}
}
},
"content": {
"body.md": {
"path": "task-accuracy-acceptance.md"
}
}
}
5 changes: 5 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-acceptance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Acceptance and handoff

Finish when the first divergence is explained, the original and held-out end-to-end outputs meet the user's tolerance on the actual target, and trade-offs are reported. If only an analogue exists (for example Ascend evidence for Windows TTS), identify the missing target sample and the smallest stage replay that tests transfer.
If the allowed search space or budget is exhausted, record the blocker, the
evidence already obtained and the smallest remaining discriminating test.
55 changes: 55 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-condition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"metadata": {
"id": "task-accuracy-condition",
"kind": "knowledge",
"entrypoint": "body.md",
"title": "Inference completes but output violates a reference, quality metric or tolerance.",
"state": "candidate",
"applicability": {
"scope": "Modality-specific reference parity and accuracy regression repair.",
"input_contract": "Actual hardware, model, engine, script and flags, benchmark, acceptance criteria, current diagnosis, permitted changes and budget.",
"produced_artifact": "First-divergence trace, before/after oracle results and held-out end-to-end quality checks.",
"refusal_point": "Record missing evidence or an exhausted search budget and identify the smallest discriminating test before declaring success."
},
"limitations": [],
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/tasks/inference-task-router/references/routes/accuracy.json",
"sha256": "5a672842ec26262d8827f7ce8d92de9bd956859ff5244189c0519b8f0dd188e3"
}
],
"attribution": "InferRSI contributors",
"empirical_validation": "not_run",
"atom": {
"layer": "L1",
"when": {
"task": [
"task-accuracy"
]
},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/tasks/inference-task-router/references/routes/accuracy.json",
"byte_range": [
92,
173
],
"sha256": "d9bad2e989c2bfa1463001c8a0eac3a6ea9bb88f1d88df1b5d20669d26f16753"
}
}
},
"content": {
"body.md": {
"path": "task-accuracy-condition.md"
}
}
}
1 change: 1 addition & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-condition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inference completes but output violates a reference, quality metric or tolerance.
51 changes: 51 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-navigation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"metadata": {
"id": "task-accuracy-navigation",
"kind": "knowledge",
"entrypoint": "body.md",
"title": "Repair a numerical or output-quality regression",
"state": "candidate",
"applicability": {
"scope": "Modality-specific reference parity and accuracy regression repair.",
"input_contract": "Actual hardware, model, engine, script and flags, benchmark, acceptance criteria, current diagnosis, permitted changes and budget.",
"produced_artifact": "First-divergence trace, before/after oracle results and held-out end-to-end quality checks.",
"refusal_point": "Record missing evidence or an exhausted search budget and identify the smallest discriminating test before declaring success."
},
"limitations": [],
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/tasks/task-accuracy/SKILL.md",
"sha256": "a441eb5565cd39674307f2cc870cb0d8d4c90314bb7df80245162df1dc3d1ae3"
}
],
"attribution": "InferRSI contributors",
"empirical_validation": "not_run",
"atom": {
"layer": "L0",
"when": {},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/tasks/task-accuracy/SKILL.md",
"byte_range": [
1346,
1397
],
"sha256": "10477fc3d5e6501291a3cd48b91857681a5c15a829743b4617335baf97939cf6"
}
}
},
"content": {
"body.md": {
"path": "task-accuracy-navigation.md"
}
}
}
2 changes: 2 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Repair a numerical or output-quality regression

55 changes: 55 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-procedure.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"metadata": {
"id": "task-accuracy-procedure",
"kind": "knowledge",
"entrypoint": "body.md",
"title": "Run the procedure",
"state": "candidate",
"applicability": {
"scope": "Modality-specific reference parity and accuracy regression repair.",
"input_contract": "Actual hardware, model, engine, script and flags, benchmark, acceptance criteria, current diagnosis, permitted changes and budget.",
"produced_artifact": "First-divergence trace, before/after oracle results and held-out end-to-end quality checks.",
"refusal_point": "Record missing evidence or an exhausted search budget and identify the smallest discriminating test before declaring success."
},
"limitations": [],
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/tasks/task-accuracy/SKILL.md",
"sha256": "a441eb5565cd39674307f2cc870cb0d8d4c90314bb7df80245162df1dc3d1ae3"
}
],
"attribution": "InferRSI contributors",
"empirical_validation": "not_run",
"atom": {
"layer": "L2",
"when": {
"task": [
"task-accuracy"
]
},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/tasks/task-accuracy/SKILL.md",
"byte_range": [
1899,
2905
],
"sha256": "222d4b2c6c9ac9d09aad49980e2ffd163645514e6e8ac20fef4e28de52734322"
}
}
},
"content": {
"body.md": {
"path": "task-accuracy-procedure.md"
}
}
}
7 changes: 7 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-procedure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Run the procedure

1. Freeze the model revision, reference outputs, inputs, seeds, preprocessing, dtype and sampling flags. Define the user's end-to-end tolerance and how the oracle handles ordinary variation. Replay both the reference and failing target with the supplied script.
2. Compare aligned stage outputs, then the first divergent token, frame or tensor. For TTS, distinguish text normalization, codec tokens and decoded audio. Feed a saved reference intermediate to the target stage to distinguish an upstream handoff error from a local math error.
3. If quality changed after an upgrade, replay the last-good and current combinations on identical inputs. Add version alignment as a secondary task if only the target combination fails. If both fail, continue tracing the divergence against the reference.
4. Change one in-scope implementation or configuration. Re-run the original and held-out inputs, including the complete postprocessing path, and report any latency or resource trade-off.

57 changes: 57 additions & 0 deletions src/inferrsi/knowledge/atoms/task-accuracy-route-card.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"metadata": {
"id": "task-accuracy-route-card",
"kind": "knowledge",
"entrypoint": "body.json",
"title": "Restore numerical or output quality",
"state": "candidate",
"applicability": {
"scope": "Modality-specific reference parity and accuracy regression repair.",
"input_contract": "Actual hardware, model, engine, script and flags, benchmark, acceptance criteria, current diagnosis, permitted changes and budget.",
"produced_artifact": "First-divergence trace, before/after oracle results and held-out end-to-end quality checks.",
"refusal_point": "Record missing evidence or an exhausted search budget and identify the smallest discriminating test before declaring success."
},
"limitations": [
"The cards describe routes and acceptance evidence; hardware support and task success require separate validation."
],
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/tasks/inference-task-router/references/routes/accuracy.json",
"sha256": "5a672842ec26262d8827f7ce8d92de9bd956859ff5244189c0519b8f0dd188e3"
}
],
"attribution": "InferRSI contributors",
"empirical_validation": "not_run",
"atom": {
"layer": "L3",
"when": {
"task": [
"task-accuracy"
]
},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/tasks/inference-task-router/references/routes/accuracy.json",
"byte_range": [
0,
1411
],
"sha256": "5a672842ec26262d8827f7ce8d92de9bd956859ff5244189c0519b8f0dd188e3"
}
}
},
"content": {
"body.json": {
"text": "{\n \"task\": \"accuracy\",\n \"title\": \"Restore numerical or output quality\",\n \"choose_when\": \"Inference completes but output violates a reference, quality metric or tolerance.\",\n \"required_inputs\": [\n \"fixed inputs, weights and reference implementation\",\n \"quality metric and tolerance\",\n \"seed, dtype and preprocessing\",\n \"modality-specific outputs\"\n ],\n \"steps\": [\n \"Confirm preprocessing, sampling and evaluation parity.\",\n \"For a post-upgrade regression, compare the last-good and current revisions on identical inputs. If only the upgraded combination fails, add version-align and bisect the changed boundary. If both fail against the reference, keep tracing the quality divergence.\",\n \"Find the first diverging stage, tensor, frame or token.\",\n \"For TTS, collect reference audio or codec tokens at the target revision. Report target-matched evidence separately from observations on other devices. When target evidence is missing, record where you searched, the missing owner and the smallest target parity check.\",\n \"Verify the correction on the reproducer and held-out inputs before rechecking speed.\"\n ],\n \"acceptance_evidence\": \"A localized divergence, reproducible quality recovery and held-out results; include any latency cost.\",\n \"candidate_skill_ids\": [\n \"audit-fixed-workload-claim\",\n \"diffusers-invocation-state\",\n \"torch-npu\",\n \"claim-contract\"\n ]\n}\n"
}
}
}
Loading
Loading