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
22 changes: 14 additions & 8 deletions src/inferrsi/knowledge/atomic_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .atomic_generation import FORMAT, PUBLIC_TASKS, SEAL, InstalledGeneration, digest, owned_path
from .atomic_json import matches_span, member_spans
from .atomic_reader import atom_material, permits_operations
from .atomic_skill_directory import directory_content, export_directory_skill, skill_spans
from .atomic_skill_directory import directory_dependencies, export_directory_skill, skill_spans
from .decision_cards import DecisionSource
from .knowledge_operations import IDENTITY, Bundle, _json, case_required_resources, safe_path
from .skill_catalog import _frontmatter_parts
Expand Down Expand Up @@ -151,23 +151,29 @@ def _authored(directory, path, field, descriptor, material, roots) -> tuple[Atom
if field not in metadata or ("atom" in metadata and "composition" in metadata):
raise ValueError(f"{path.name} must declare one {field}")
content = {}
directory_export = metadata[field].get("skill") == {"directory_entry": True}
if directory_export and "directory_resources" not in descriptor:
raise ValueError("Directory Skill export requires checked original directory resources")
dependencies = descriptor.get("dependencies", {})
directory_required = metadata[field].get("skill") == {"directory_entry": True}
if (field == "composition" and metadata["kind"] == "skill"
and descriptor.get("authority") == "checkout"):
original = next(iter(metadata.get("sources", [])), {}).get("path", "")
guide = PurePosixPath(metadata.get("entrypoint", "")).name == "SKILL.md"
directory_required |= guide or original.endswith(f"/{metadata['id']}/SKILL.md")
if directory_required and "directory_resources" not in descriptor:
raise ValueError("Directory Skill requires checked original directory resources")
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)
if "directory_resources" in descriptor:
if (field != "composition" or metadata["kind"] != "skill"
or descriptor.get("authority") != "checkout" or "content" in descriptor
or descriptor.get("dependencies")):
raise ValueError("Directory resources require a self-contained checkout Skill")
or dependencies):
raise ValueError("Checkout Skill directories must use source-declared dependencies")
bindings = descriptor["directory_resources"]
if not isinstance(bindings, dict):
raise ValueError("Skill directory resources must bind original relative names")
content, origins = _pinned_resources(metadata, bindings, material)
content = directory_content(metadata, bindings, content, origins, material, roots)
dependencies = directory_dependencies(metadata, bindings, content, origins, material, roots)
for name, value in descriptor.get("content", {}).items():
safe_path(name)
if isinstance(value, dict) and value.keys() == {"path"}:
Expand All @@ -186,7 +192,7 @@ def _authored(directory, path, field, descriptor, material, roots) -> tuple[Atom
if "navigation.json" in content:
raise ValueError("Explicit navigation content must declare its entrypoint")
content["navigation.json"] = _json(metadata[field])
bundle = Bundle(metadata, content, descriptor.get("dependencies", {}))
bundle = Bundle(metadata, content, dependencies)
ref = descriptor.get("authority", "package") + ":" + metadata["id"]
return AtomPin(ref, bundle.revision), bundle

Expand Down
31 changes: 20 additions & 11 deletions src/inferrsi/knowledge/atomic_skill_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from ._skill_selection import skill_procedure
from .atomic_composition import AtomPin, select_routes
from .atomic_generation import directory_skill_path, owned_path
from .atomic_generation import digest, directory_skill_path, owned_path
from .knowledge_operations import Bundle, _tree, safe_path
from .skill_catalog import _effective, _frontmatter_parts

Expand All @@ -27,21 +27,26 @@ def skill_spans(body: bytes) -> dict:
"procedure": ("L2", header.end(), len(body))}


def _verify_directory_routes(declaration, bindings, guide, source, material):
def _verify_directory_routes(declaration, bindings, guide, source, material, dependencies):
sections = skill_spans(guide)
if any(any(route.get(key) for key in ("when", "optional", "supersedes", "conflicts"))
for route in declaration["routes"].values()):
raise ValueError("Directory routes must preserve their unconditional delivery")
nodes = declaration["nodes"]
originals = {AtomPin(nodes[name]["ref"], nodes[name]["revision"]) for name in bindings.values()}
file_pins = {path: AtomPin(nodes[name]["ref"], nodes[name]["revision"])
for path, name in bindings.items()}
for layer, names in (("L0", ["navigation"]), ("L1", ["decision"]),
("L2", ["decision", "procedure"]), ("L3", [])):
selected = select_routes(declaration, layer=layer, context={}, case=None, finding=None)
pins = dict.fromkeys(use.pin for use in selected.required)
pins = list(dict.fromkeys(use.pin for use in selected.required))
if layer == "L3":
if pins.keys() != originals:
if set(pins) != set(file_pins.values()):
raise ValueError("Skill L3 must deliver the complete original directory")
continue
if layer == "L2":
if pins[len(names):] != [file_pins[path] for path in dependencies]:
raise ValueError("Skill L2 must deliver its declared original references")
pins = pins[:len(names)]
actual = []
for pin in pins:
if pin not in material:
Expand All @@ -54,8 +59,8 @@ def _verify_directory_routes(declaration, bindings, guide, source, material):
raise ValueError(f"Skill {layer} must deliver its own pinned guide sections")


def directory_content(metadata, bindings, content, origins, material, roots) -> dict[str, bytes]:
"""Keep all the original names and bytes of a self-contained checkout Skill directory."""
def directory_dependencies(metadata, bindings, content, origins, material, roots) -> dict[str, str]:
"""Verify the original Skill directory and derive the explicitly declared file revisions."""
entry = PurePosixPath(safe_path(metadata["entrypoint"]))
if (not isinstance(bindings, dict) or entry.as_posix() not in bindings
or entry.name != "SKILL.md" or entry.parent.name != metadata["id"]):
Expand All @@ -74,14 +79,18 @@ def directory_content(metadata, bindings, content, origins, material, roots) ->
raise ValueError(f"Skill resource differs from its original relative source: {name}")
root = roots[source["commit"]]
directory = owned_path(root, original.parent.as_posix())
if _effective(directory).get("references"):
raise ValueError("Self-contained directory cannot omit declared Skill references")
released = _tree(directory, entry.parent.as_posix(), root=root)
if content != released or metadata["required_resources"] != sorted(released):
raise ValueError("Skill directory bindings must cover the complete original directory")
dependencies = {}
for reference in _effective(directory).get("references", []):
path = (entry.parent / safe_path(reference)).as_posix()
if path not in released:
raise ValueError(f"Missing declared Skill reference: {path}")
dependencies[path] = "sha256:" + digest(released[path])
_verify_directory_routes(metadata["composition"], bindings, content[entry.as_posix()],
source, material)
return content
source, material, dependencies)
return dependencies


def export_directory_skill(bundle: Bundle) -> tuple[str, dict[str, bytes]]:
Expand Down
100 changes: 100 additions & 0 deletions src/inferrsi/knowledge/atoms/draft-acceptance-issue.original.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"authority": "checkout",
"metadata": {
"id": "draft-acceptance-issue.original",
"kind": "knowledge",
"entrypoint": "guide.md",
"title": "Draft a campaign acceptance issue with checklist, RunSpec, evidence paths, and placeholders for baseline/candidate SHAs.",
"origin": [
"first-party"
],
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/workflows/governance/draft-acceptance-issue/SKILL.md",
"sha256": "2c14533c067c51b9763f80a9df0bf5eb5acd398f4265790c57039fed96d4c497"
},
{
"type": "unknown",
"note": "Legacy provenance remains in procedure/readsets"
}
],
"applicability": {
"scope": "Opening a new acceptance campaign in an RSI-style repository, before any baseline or candidate run",
"prerequisites": "A chosen campaign subject and an empty evidence/<campaign-id>/ tree copied from evidence/_template/; SHAs may still be placeholders",
"input_contract": "A campaign id of the form {model-or-scenario}/{device}x{count}, any user-supplied criteria or accepted plan, and available workload/baseline/calibration evidence for deriving missing targets",
"produced_artifact": "An acceptance issue body with campaign id, pinned baseline and candidate SHAs, RunSpec, criteria source and derivation including gaps and freeze authority, gates, evidence paths, initial verdict and a downstream citation blurb",
"failure_modes": [
"Gates written after the search loop has already run",
"Campaign SHAs committed into recipes/, benchmarks/, skills or workflow defaults",
"PASS claimed without a validator/ freeze and a results/ rationale"
],
"refusal_point": "Refuses to state a verdict other than INCONCLUSIVE while the validator freeze or results rationale is absent"
},
"state": "candidate",
"limitations": [
"Drafts an issue only; it freezes no gate and runs no measurement.",
"The placeholder SHA convention depends on the campaign owner filling them in later.",
"Checkout-only local skill; no automatic execution or promotion.",
"Only declared references are required; other cross-skill links are navigation.",
"Historical revisions require a matching checkout or a retained store."
],
"attribution": [],
"empirical_validation": "not_run",
"atom": {
"when": {},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"layer": "L3",
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/workflows/governance/draft-acceptance-issue/SKILL.md",
"byte_range": [
0,
4373
],
"sha256": "2c14533c067c51b9763f80a9df0bf5eb5acd398f4265790c57039fed96d4c497"
}
}
},
"content": {
"guide.md": {
"path": "workflows/draft-acceptance-issue.md"
}
},
"parts": {
"navigation": {
"skill_section": "navigation",
"layer": "L0",
"byte_range": [
0,
167
],
"sha256": "58706d39daa9a09f6ffe2e9fc498095e8431b8bb31bc277d244e334704683c75"
},
"decision": {
"skill_section": "decision",
"layer": "L1",
"byte_range": [
0,
2861
],
"sha256": "8e6793ae5ee565507a43588828c25e66a7fd1d32fac153b5f7be76b72bcf3277"
},
"procedure": {
"skill_section": "procedure",
"layer": "L2",
"byte_range": [
2861,
4373
],
"sha256": "fe9aa75697f5223bf61fb31b6eeec4ee8a1983891545398bdeeed8cb5a5e0700"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"authority": "checkout",
"metadata": {
"title": "Capability presence audit",
"sources": [
{
"type": "git",
"repo": "https://github.com/InferMatrixLab/InferRSI",
"commit": "e2f3be102c66c358803ed2186ed67bf627ebcbdf",
"path": "src/inferrsi/knowledge/data/skill_library/workflows/research/repository-evolution-analysis/references/capability-presence-audit.md",
"sha256": "c21eb4a6aabe811a49a6540a34c54dbcfdcf7efae3052a79b54034c7838026a5"
}
],
"origin": [
"external"
],
"attribution": [
{
"url": "https://github.com/LearningToCommit/LearningToCommit",
"commit": "7e5a1d77",
"paths": [
"data_construction/s1_scan_commits.py",
"data_construction/s3_tag.py",
"data_construction/s4_sample.py",
"data_construction/s5_build.py",
"modules/agent.py",
"modules/prompt_builder.py",
"modules/trajectory_to_md.py",
"system_prompts/solve_with_skill.txt",
"system_prompts/learn_reflect.txt",
"evaluation/pairwise_judge.py",
"evaluation/programmatic_metrics.py"
],
"type": "git",
"revision_precision": "prefix"
},
{
"url": "https://github.com/yetone/magpie",
"commit": "77800032",
"paths": [
"internal/",
"docs/"
],
"type": "git",
"revision_precision": "prefix"
},
{
"url": "https://github.com/yetone/magpie",
"commit": "4b5d6d725fae3d8a263f6e43c707400e3765b84f",
"paths": [
"internal/library/rtk.go",
"internal/library/rtk_upgrade.go",
"internal/proc/path_other.go",
"internal/proc/path_windows.go",
"internal/provider/install_windows.go"
],
"type": "git",
"revision_precision": "full"
},
{
"url": "https://github.com/yetone/magpie",
"commit": "9848a9062a65c49e074c09770dc7de73dd012bea",
"paths": [
"internal/library/rtk.go",
"internal/library/rtk_upgrade.go",
"internal/proc/path_other.go",
"internal/proc/path_windows.go",
"internal/provider/install_windows.go",
"internal/library/rtk_path.go",
"internal/library/rtk_path_other.go",
"internal/library/rtk_path_windows.go",
"internal/library/rtk_path_test.go",
"internal/library/rtk_test.go",
"internal/library/rtk_upgrade_test.go",
"internal/library/library_test.go",
"internal/gui/library.go",
"internal/gui/assets/library.js",
"internal/gui/tests/library-rtk-path.test.cjs",
"library_cli.go",
"LICENSE"
],
"type": "git",
"revision_precision": "full"
}
],
"applicability": {
"scope": "any software repository with a recoverable git history",
"prerequisites": "git history access, optionally LearningToCommit-style benchmark for evaluation"
},
"state": "candidate",
"limitations": [
"Source-derived candidate; no local efficacy validation.",
"The RTK transition is a learning example, not an independent heldout task; upstream tests were inspected, not executed.",
"Existing audit and synthetic KV comparison adapters are not a generic historical coding-task evaluator.",
"Checkout-only local skill; no automatic execution or promotion.",
"Only declared references are required; other cross-skill links are navigation.",
"Historical revisions require a matching checkout or a retained store."
],
"empirical_validation": "not_run",
"id": "repository-evolution-analysis.capability-presence-audit",
"kind": "knowledge",
"entrypoint": "capability-presence-audit.md",
"atom": {
"when": {},
"license": "Apache-2.0",
"permissions": {
"read": true,
"retain": true,
"redistribute": true
},
"layer": "L3",
"source_span": {
"source_index": 0,
"path": "src/inferrsi/knowledge/data/skill_library/workflows/research/repository-evolution-analysis/references/capability-presence-audit.md",
"byte_range": [
0,
11461
],
"sha256": "c21eb4a6aabe811a49a6540a34c54dbcfdcf7efae3052a79b54034c7838026a5"
}
}
},
"content": {
"capability-presence-audit.md": {
"path": "workflows/repository-evolution-analysis/references/capability-presence-audit.md"
}
}
}
Loading
Loading