diff --git a/.github/knowledge-model-policy.json b/.github/knowledge-model-policy.json index db1c8d15f..0e65d0699 100644 --- a/.github/knowledge-model-policy.json +++ b/.github/knowledge-model-policy.json @@ -3,8 +3,6 @@ "base_branch": "main", "protected_paths": [ "src/inferrsi/knowledge/data/skill_library/**", - "src/inferrsi/knowledge/data/knowledge_packs/**", - "src/inferrsi/knowledge/data/repo_packs/**/knowledge/**", "docs/reference-matrix.md", "docs/searchspace-matrix.md", "docs/knowledge-base.md", diff --git a/.github/workflows/skill-eval-pr.yml b/.github/workflows/skill-eval-pr.yml index 29de41eb2..ec94d8cb6 100644 --- a/.github/workflows/skill-eval-pr.yml +++ b/.github/workflows/skill-eval-pr.yml @@ -10,8 +10,6 @@ on: types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled, closed] paths: - src/inferrsi/knowledge/data/skill_library/** - - src/inferrsi/knowledge/data/knowledge_packs/** - - src/inferrsi/knowledge/data/repo_packs/**/knowledge/** - tools/skill_eval_* - tests/fixtures/skill-comparison/** - .github/workflows/skill-eval-pr.yml diff --git a/AGENTS.md b/AGENTS.md index 39b196eda..75e7f9908 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ Coding agents (Cursor, Codex, Claude, etc.) should treat this file as the **entr ## What this repo is -**InferRSI** is InferMatrixLab’s canonical home for a **portable RSI / evidence-driven scaffold**. Work is organized as **SIAS**: harness × model × infra seams under `src/inferrsi/` (rename on copy), with runnable examples and a first-class `evidence/` tree. +**InferRSI** is InferMatrixLab’s canonical home for a **portable RSI / evidence-driven scaffold**. Work is organized as **SIAS**: harness × model × infra planes of the system being optimized, with runnable examples and a first-class `evidence/` tree. InferRSI's own code lives under `src/inferrsi/` (rename on copy) in four cores: Knowledge, Harness, Benchmark and Apps. This entry contract is portable for derived scaffolds. The repository itself is the maintained workbench: delivering an independent engine uses the [engine delivery template](docs/template/README.md) and does not copy or depend on this runtime. Route your task: modify InferRSI via [contributing](docs/contributing.md) and [agent collaboration](docs/agent-collaboration.md); run experiments via [quickstart](docs/quickstart.md); find any CLI/Python operation via the [operation guide](docs/operations.md). @@ -69,7 +69,7 @@ Parameterized or manual acceptance runs are issue-scoped; they are not the defau - **Resolve acceptance criteria** — preserve user-supplied criteria; when absent, use [performance-ceiling-analysis](src/inferrsi/knowledge/data/skill_library/playbooks/measurement/performance-ceiling-analysis/references/acceptance-criteria.md) to derive evidence-backed campaign targets. Retain partial requirements and derive only missing fields; unresolved evidence stays explicit. - **Freeze gates before search** — checklist and `validator/` locked in `plan/` before Phase 3 candidate experiments ([validation levels](docs/contributing.md#validation-levels)). -- **One plane per campaign step** — change only the declared SIAS plane per step: `harness` | `model` | `infra` (under `src/inferrsi/`). +- **One plane per campaign step** — change only the declared SIAS plane of the target system per step: `harness` | `model` | `infra`. These planes are not InferRSI packages. - **Emit RunSpec snapshots** — record repo × revision × backend × device × model × scenario (`contracts/runspec.py`, campaign `plan/`). - **Evaluator + evidence win** — never treat agent narrative as `PASS`; verdicts follow frozen gates and `evidence//` artifacts. diff --git a/docs/architecture.md b/docs/architecture.md index e46e0a14b..231a3d657 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -91,12 +91,13 @@ interfaces; existing CLI commands remain supported. ![Implemented modules and their dependencies](assets/modular-components-en.svg) -| Layer | Owns | Does not own | +| Module | Owns | Does not own | | --- | --- | --- | -| Entry and knowledge | CLI arguments, immutable RunSpec, cited knowledge/context export | Model execution or automatic source editing | -| Harness | AB/BA order, deadlines, source checks, scenario composition, evidence, performance adjudication and reporting | Device-specific conditions, request schemas or kernel dispatch | -| Model | Anthropic provider adapters and their request authorization | Scheduling, worker lifetime, hardware selection, request payloads, metric contracts or quality checks | -| Apps | CLI, host bindings (source identity, device discovery/qualification, environment facts), artifact digests and JSON writes, provider integrations | Model constants, campaign gates or performance verdicts | +| Knowledge | The skill library and knowledge records, search, cited knowledge/context export and the collected-context projection | Execution, task grading or campaign composition | +| Harness | Command execution and process domains, AB/BA order, deadlines, source checks, optimization sessions, retained records and evidence | Task grading and verdicts, report presentation, device-specific conditions, request schemas or kernel dispatch | +| Benchmark | Task discovery and packages, graders, metric validation, assessments and the old-run gates | Process execution, knowledge search or presentation | +| Apps | CLI and the assembly of the three cores, host bindings (source identity, device discovery/qualification, environment facts), artifact digests and JSON writes, provider integrations including the Anthropic adapters, views and reports | Model constants, task rules or performance verdicts | +| `contracts/`, `resources/` | The immutable RunSpec, JSON, claim and evidence-path helpers, and the neutral repository-pack reader | Business DTOs or core initialization; neither package is a fourth core | Dependencies flow from entrypoints to Harness. #498 removed the Infra and Model packages, so Harness reaches neither. None diff --git a/docs/contracts/function-owners.md b/docs/contracts/function-owners.md index 3a1d3f620..dbf010194 100644 --- a/docs/contracts/function-owners.md +++ b/docs/contracts/function-owners.md @@ -18,12 +18,12 @@ Status: **Proposed baseline**; individually **adopted** entries are identified b | `harness/knowledge_capture` `assemble_context_text`/`_item` | K pure knowledge text projection | Apps connects K/H; Apps gives H the fixed expected text/hash; H stores the actually delivered text/hash; `verify_capture` byte integrity belongs to H and does not call K assembly in reverse; it is not a task-benefit verdict | | `harness/trials/external` `execute_trial`/`collect_trial_checks` | H: run one command through `execute_command`, retain its record, and collect the trial checks; semantic metric validation (`read_metric`/`validate_metric`) is B and lives in `benchmark/metrics.py` | `execute_trial` applies only the metric callable the caller injects and holds no metric rule; offline assess executes nothing | | `campaign_records` `STAGES`/claim capture/reconciliation | H records; dashboard/report presentation → Apps | first remove the `campaign_records → dashboard_data` reverse dependency; #333 is Proposed and no claim is made that a unified event envelope is accepted | -| `catalog.repository_pack`/`REPO_TYPES` | D020 neutral raw-data technical leaf; target interpretation stays H | K does not expose the pack reader publicly; `infra` changes only its same-leaf import; seven K bodies/root entries/tests move together | +| `catalog.repository_pack`/`REPO_TYPES` | D020 neutral raw-data technical leaf; target interpretation stays H | K does not expose the pack reader publicly; `apps/host/inspection` (the former `infra/inspection`, moved by #498) changes only its same-leaf import; seven K bodies/root entries/tests move together | | `apps/views/dashboard_workflow` `command_state`/`run_workflow`/`validation_progress` (added with the OBS dissolve; **adopted owner: Apps views; RSI-master architecture decision 2026-11-14 Asia/Shanghai, recorded in the [D008 wave-2 ownership decision](d008-wave2-ownership-decision.md#dashboard-workflow); independent PR review remains separate**) | Apps views: read-only presentation projection of workflow and command state | The module imports only the standard library and reads records the caller already loaded; it has no H, K or Benchmark edge. A group `state` such as `completed` is a display state for the run workflow, not a verdict, and must not be read as the legacy `Verdict`. `validation_progress` only validates counters from a snapshot `dashboard_data` has already read; it opens no file. | | `harness/records/profile_timeline` `attach_profile`, `_compile` (builds the bounded dashboard overview stored with the record), fixed-byte verification, and digest reads (`read_profiles`/`profile_event_table`) (added with the OBS dissolve; **adopted owner: H records; RSI-master architecture decision 2026-11-14 Asia/Shanghai, recorded in the [D008 wave-2 ownership decision](d008-wave2-ownership-decision.md#profile-records-and-overview); independent PR review remains separate**) | H records: attach a reviewed profile, compile the stored overview from those bytes, and verify stored bytes | Record, overview-compile and byte-integrity paths stay in H because the overview is record content: it is computed once at attach from a bounded trace and published content-addressed, so the stored bytes cannot depend on who renders them. Its top-lane, longest-event and top-kernel selection reduces one trace for a bounded record; it ranks no candidate, run or claim and produces no verdict. UI route decoration, including `events_url`, belongs to Apps views, not H. Issue #413's broad timeline-to-Apps placement is refined here: persisted factual records and bounded overview encoding stay in H; UI projections and route decoration belong to Apps. The route decoration is removed from H in this PR, preserving stored bytes, digest verification and the external view response. | | `apps/views/profile_searches` `pre_profile_searches` (added with the OBS dissolve; **adopted owner: Apps views; RSI-master architecture decision 2026-11-14 Asia/Shanghai, recorded in the [D008 wave-2 ownership decision](d008-wave2-ownership-decision.md#pre-profile-searches); independent PR review remains separate**) | Apps views: Dashboard-consumed presentation list relating a profile capture to named searches completed before it | It joins an H record with ledger read models, which only Apps may assemble. Its `verified`/`not_before`/`unknown_time` values are display annotations over an existing search state; they are not evidence for a claim, and using them that way needs a new owner decision. | -| `benchmark/sampling` `collect_samples` (moved out of `harness/scenarios/media` by the old-run split; **ownership disposition: B sampling; RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#benchmark-sampling); independent PR review remains separate**) | B sampling: seed ordering, timing records and artifact hashes | Request transport stays with the caller's injected `request(item, path)` callback; Benchmark hashes artifacts with its own `_sha256`, pinned to `infra.artifacts.sha256` by `tests/test_legacy_run_split.py::test_sampling_sha256_matches_the_infra_hasher`, and imports no H or `infra` module. The per-group progress line on stdout is the old `run` protocol output kept for D022 and is a protocol constraint, not a presentation owner. | -| `harness/runner` `snapshot` port `(repo, exclude) -> dict` (separated from the runner by the old-run split; **ownership disposition: H port contract, Apps legacy binding, `infra/targets` implementation; RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#snapshot-port); independent PR review remains separate**) | H owns the port and its contract; the Apps legacy composition owns the binding; `infra/targets` owns the Git identity implementation | H keeps the port required and keyword-only with no default and holds no copy of the implementation. `apps/legacy/run.py` binds `snapshot=repository_identity` for the old run and the root `execution.py` forwards it. A change of the binding owner needs its own review. Out-of-tree callers that used the removed H defaults are not covered by this row. | +| `benchmark/sampling` `collect_samples` (moved out of `harness/scenarios/media` by the old-run split; **ownership disposition: B sampling; RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#benchmark-sampling); independent PR review remains separate**) | B sampling: seed ordering, timing records and artifact hashes | Request transport stays with the caller's injected `request(item, path)` callback; Benchmark hashes artifacts with its own `_sha256`, pinned to `apps.artifacts.sha256` by `tests/test_legacy_run_split.py::test_sampling_sha256_matches_the_apps_hasher` (the Infra hasher and its test name were retired by #498), and imports no H or Apps module. The per-group progress line on stdout is the old `run` protocol output kept for D022 and is a protocol constraint, not a presentation owner. | +| `harness/runner` `snapshot` port `(repo, exclude) -> dict` (separated from the runner by the old-run split; **ownership disposition: H port contract, Apps legacy binding, `apps/host/targets` implementation (moved from `infra/targets` by #498); RSI-master [adopted decision, 2026-11-14 Asia/Shanghai](d008-wave2-ownership-decision.md#snapshot-port); independent PR review remains separate**) | H owns the port and its contract; the Apps legacy composition owns the binding; `apps/host/targets` owns the Git identity implementation | H keeps the port required and keyword-only with no default and holds no copy of the implementation. `apps/legacy/run.py` binds `snapshot=repository_identity` for the old run; the root `execution.py` forwarder was deleted by #412 R1, and the CLI imports `apps/legacy/` itself. A change of the binding owner needs its own review. Out-of-tree callers that used the removed H defaults are not covered by this row. | D008 rows are architecture decisions under the delegation recorded at the top of this file. An independent reviewer verifies the cited code, tests and dependency direction and may block on a missing adoption record; a reviewer does not choose the owner, and a PR approval is not the D008 adoption record. The architecture owner records adoption in the governed contract or decision record; the rows cite that decision record, independently of PR approval. diff --git a/docs/knowledge-model-policy.md b/docs/knowledge-model-policy.md index c91d3eadf..33d2e9648 100644 --- a/docs/knowledge-model-policy.md +++ b/docs/knowledge-model-policy.md @@ -31,14 +31,15 @@ prospective; do not reconstruct unknown identities or rewrite historical commits The exact protected scope is: - `src/inferrsi/knowledge/data/skill_library/**` -- `src/inferrsi/knowledge/data/knowledge_packs/**` -- `src/inferrsi/knowledge/data/repo_packs/**/knowledge/**` - `docs/reference-matrix.md`, `docs/searchspace-matrix.md` - `docs/knowledge-base.md`, `docs/knowledge-operations.md`, `docs/knowledge-store.md` - `src/inferrsi/knowledge/catalog.py`, `src/inferrsi/knowledge/skill_catalog.py`, `src/inferrsi/knowledge/knowledge_operations.py`, the Knowledge implementations. The three root compatibility shells of the same names were deleted by #412 R1, - and their paths left this list with the files. The implementations stay protected + and their paths left this list with the files. The implementations stay protected. + #516 moved the former `knowledge_packs/**` and `repo_packs/**/knowledge/**` + content into `skill_library/records/`, which `skill_library/**` covers, so those + two patterns left this list. Deletions and both rename paths count. Mechanical/generated changes have no automatic exemption. Running a generator or obtaining an approved-model review diff --git a/docs/module-layout.md b/docs/module-layout.md index ffcdf79a9..293d9a108 100644 --- a/docs/module-layout.md +++ b/docs/module-layout.md @@ -217,7 +217,7 @@ Several flat modules remain shared seams until their slice starts. | `apps/views/`, `apps/workflows/campaign.py` | Dashboard views, templates and the Knowledge-to-records connection | Apps composition under #371; campaign composition is grouped under workflows by #490 | | `apps/integrations/mindie/` (`project.py`, `context.py`, `mcp.py`, `read_worker.py`) | The local MindIE adapter: project grant, stdio MCP, context export and the read worker | M1 (#452) moved the four root MindIE files here; no Harness, Knowledge or Infra module names MindIE, and the initializer imports nothing | | `harness/` | Mixed legacy tree, not target isolation | Not redefined | -| `harness/runner.py`, `harness/trials/external.py`, `harness/atomic_json.py` | Old run execution facts and Harness-owned JSON writes | Ports injected; no Model edge, and no Infra edge except the local process executor | +| `harness/runner.py`, `harness/trials/external.py`, `harness/atomic_json.py` | Old run execution facts and Harness-owned JSON writes | Ports injected; the local process executor is `harness/local_process.py` | | `benchmark/legacy_run_v0.py`, `benchmark/sampling.py` | Old run gates and metric validation; image/video sample collection | Imports only `benchmark/metrics.py`; owns its rule inputs and verdict labels | | `apps/legacy/` | Old run composition, old `evaluate` entry and HTML report | Supplies the Git source snapshot from `apps/host/targets`; remains in Apps | | `apps/inspection.py` | Prepared-environment inspection bound to this host | Binds the `apps/host/inspection.py` facts API to `apps.host.commands.probe_command` and `apps.host.targets.repository_identity`; replaces root `inspection.py`, which R1 deleted with the three old-run root forwarders | diff --git a/src/inferrsi/harness/README.md b/src/inferrsi/harness/README.md index f05cdbf8f..023c25656 100644 --- a/src/inferrsi/harness/README.md +++ b/src/inferrsi/harness/README.md @@ -2,8 +2,9 @@ `runner.py` owns the common AB/BA loop, source checks and evidence lifecycle. Its `execute`, `snapshot`, `assess` and `report` ports are injected; it records -the assessment it receives and judges nothing. `scenarios/external.py` runs one -command trial and applies the caller's metric validation. `atomic_json.py` +the assessment it receives and judges nothing. `trials/external.py` runs one +command trial, retains its record and collects the trial checks; metric reading +and validation live in `benchmark/metrics.py`. `atomic_json.py` writes the retained JSON evidence. `api.py` is the public H entry (`allocate` / `execute` / `read`) for ordinary @@ -20,8 +21,9 @@ injected by `apps/`. `artifact_sandbox.py` captures a submitted artifact and rep it under bubblewrap. `improvement.py` advances the search over injected assessments. `atomic_json.py` and `input_binding.py` supply Harness-owned writes and digests. -Compose `scenarios/external.py` with a metric reader for a new engine, or -`scenarios/media.py` with a request callback for image/video sample collection. +Compose `trials/external.py` with a metric reader from `benchmark/metrics.py` +for a new engine, or `benchmark/sampling.py` with a request callback for +image/video sample collection. Keep model payloads and backend branches outside the shared loop. See [the architecture and extension contracts](../../../docs/architecture.md). diff --git a/tests/test_knowledge_declaration_paths.py b/tests/test_knowledge_declaration_paths.py index 1c2b5c465..6a6431f0c 100644 --- a/tests/test_knowledge_declaration_paths.py +++ b/tests/test_knowledge_declaration_paths.py @@ -6,7 +6,6 @@ POLICY = { "protected_paths": [ "src/inferrsi/knowledge/data/skill_library/**", - "src/inferrsi/knowledge/data/repo_packs/**/knowledge/**", "docs/reference-matrix.md", ], "policy_paths": [".github/knowledge-model-policy.json"], @@ -14,9 +13,7 @@ LIBRARY = "src/inferrsi/knowledge/data/skill_library" SKILL = f"{LIBRARY}/methods/a/SKILL.md" MOVED = f"{LIBRARY}/methods/b/old.md" -RECORD = ( - "src/inferrsi/knowledge/data/repo_packs/inferrsi/knowledge/common/skills/c.json" -) +RECORD = f"{LIBRARY}/_compiled/common/skills/c.json" def _git(root, *args): diff --git a/tests/test_knowledge_model_policy.py b/tests/test_knowledge_model_policy.py index a846d104b..a1d0ef6fa 100644 --- a/tests/test_knowledge_model_policy.py +++ b/tests/test_knowledge_model_policy.py @@ -46,7 +46,7 @@ ROOT = Path(__file__).resolve().parents[1] HEAD = "a" * 40 BASE = "b" * 40 -KNOWLEDGE = "src/inferrsi/knowledge/data/repo_packs/example/knowledge/cuda/case.json" +KNOWLEDGE = "src/inferrsi/knowledge/data/skill_library/records/cuda/case.json" CONTROL = ".github/knowledge-model-policy.json" @@ -204,7 +204,7 @@ def test_stale_head_and_unsupported_schema_fail(): @pytest.mark.parametrize("path", [ "src/inferrsi/knowledge/data/skill_library/methods/example/SKILL.md", "src/inferrsi/knowledge/data/skill_library/skill-index.json", - "src/inferrsi/knowledge/data/knowledge_packs/peer/example/case.json", KNOWLEDGE, + KNOWLEDGE, "docs/reference-matrix.md", "docs/searchspace-matrix.md", "docs/knowledge-base.md", "docs/knowledge-operations.md", "docs/knowledge-store.md", "src/inferrsi/knowledge/catalog.py", "src/inferrsi/knowledge/skill_catalog.py", diff --git a/tools/knowledge_declaration_paths.py b/tools/knowledge_declaration_paths.py index ab793297c..0daaccbf2 100644 --- a/tools/knowledge_declaration_paths.py +++ b/tools/knowledge_declaration_paths.py @@ -15,8 +15,7 @@ PROJECT = Path(__file__).resolve().parents[1] POLICY = ".github/knowledge-model-policy.json" -GENERATED = ("src/inferrsi/knowledge/data/skill_library/_compiled/", - "src/inferrsi/knowledge/data/repo_packs/inferrsi/knowledge/", "docs/skill-coverage.md") +GENERATED = ("src/inferrsi/knowledge/data/skill_library/_compiled/", "docs/skill-coverage.md") GIT = ("git", "--no-replace-objects", "--no-lazy-fetch")