Skip to content
Closed
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
138 changes: 138 additions & 0 deletions docs/apps-module-migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,143 @@
"tests/test_apps_module_migrations.py",
"tests/test_benchmark_compare.py"
]
},
{
"old": "inferrsi.apps.cannbot",
"canonical": "inferrsi.apps.integrations.cannbot",
"exports": [
"CannbotChannel",
"project"
],
"consumers": [
"src/inferrsi/apps/cli/__init__.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py"
],
"package": true,
"module_exports": {
"project": {
"old": "inferrsi.apps.cannbot.project",
"canonical": "inferrsi.apps.integrations.cannbot.project"
}
}
},
{
"old": "inferrsi.apps.cannbot.project",
"canonical": "inferrsi.apps.integrations.cannbot.project",
"exports": [
"MAX_BYTES",
"PLATFORMS",
"ChannelFailure",
"project_root",
"load_grant",
"describe",
"search",
"read",
"enable",
"disable"
],
"consumers": [
"src/inferrsi/apps/integrations/cannbot/__init__.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_cannbot_boundaries.py"
]
},
{
"old": "inferrsi.apps.cannbot.read_worker",
"canonical": "inferrsi.apps.integrations.cannbot.read_worker",
"exports": [
"OutputLimitError",
"capture",
"discover",
"search",
"read"
],
"consumers": [
"src/inferrsi/apps/integrations/cannbot/project.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_cannbot_boundaries.py"
]
},
{
"old": "inferrsi.apps.mindie",
"canonical": "inferrsi.apps.integrations.mindie",
"exports": [],
"consumers": [
"docs/architecture.md",
"docs/external-channels.md",
"docs/module-layout.md",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py"
],
"package": true
},
{
"old": "inferrsi.apps.mindie.context",
"canonical": "inferrsi.apps.integrations.mindie.context",
"exports": [
"MAX_BYTES",
"export_context"
],
"consumers": [
"docs/module-layout.md",
"src/inferrsi/apps/cli/__init__.py",
"src/inferrsi/apps/integrations/mindie/mcp.py",
"src/inferrsi/apps/integrations/mindie/project.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_mindie_context.py",
"tests/test_mindie_runtime.py"
]
},
{
"old": "inferrsi.apps.mindie.project",
"canonical": "inferrsi.apps.integrations.mindie.project",
"exports": [
"ReadFailure",
"project_root",
"enable",
"disable",
"describe",
"call",
"dispatch"
],
"consumers": [
"docs/module-layout.md",
"src/inferrsi/apps/cli/__init__.py",
"src/inferrsi/apps/integrations/mindie/mcp.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_mindie_project.py",
"tests/test_mindie_runtime.py"
]
},
{
"old": "inferrsi.apps.mindie.mcp",
"canonical": "inferrsi.apps.integrations.mindie.mcp",
"exports": [
"serve"
],
"consumers": [
"docs/module-layout.md",
"src/inferrsi/apps/integrations/mindie/project.py",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py",
"tests/test_mindie_project.py"
]
},
{
"old": "inferrsi.apps.mindie.read_worker",
"canonical": "inferrsi.apps.integrations.mindie.read_worker",
"exports": [
"read"
],
"consumers": [
"docs/module-layout.md",
"tests/check_installed.py",
"tests/test_apps_module_migrations.py"
]
}
]
20 changes: 13 additions & 7 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,16 @@ src/inferrsi/
skill_evaluation.py Composed bundle export, trial run and summary
skill_eval_engineering.py Composed artifact check: task rules around sandbox replay
improvement.py Composed assessment, selection, rerun and holdout acceptance
mindie/
project.py Opt-in per-checkout grant, the worker launch and the recorded read
context.py Export supplied MindIE reads into a caller-reviewed campaign trace
mcp.py Stdio MCP for the two approved local MindIE reads
read_worker.py Standalone worker run by the approved MindIE interpreter
integrations/
cannbot/
__init__.py CannbotChannel implementation and channel result adaptation
project.py Opt-in checkout/interpreter grant and read-only operations
read_worker.py Standalone worker run by the approved Cannbot interpreter
mindie/
project.py Opt-in per-checkout grant, worker launch and recorded read
context.py Export supplied MindIE reads into a reviewed campaign trace
mcp.py Stdio MCP for the two approved local MindIE reads
read_worker.py Standalone worker run by the approved MindIE interpreter
views/
summary_chart.py Stdlib SVG gain chart (chain/branch) and report figure spec
optimization_chart.py Managed optimization objective/token curves and final result
Expand Down Expand Up @@ -290,8 +295,9 @@ tests/fixtures/legacy/ Frozen historical validation dependencies for regres
```

The package root holds exactly two tracked files: `__init__.py` and `__main__.py`.
#452 M1 moved the MindIE adapter to `apps/mindie/` (`project.py`, `context.py`,
`mcp.py` and the standalone `read_worker.py`) and deleted root `mindie_project.py`,
#452 M1 moved the MindIE adapter into Apps; #490 groups it at
`apps/integrations/mindie/` (`project.py`, `context.py`, `mcp.py` and the standalone
`read_worker.py`). M1 deleted root `mindie_project.py`,
`mindie_context.py`, `mindie_mcp.py` and `_mindie_read_worker.py` with no forwarding
shell or alias. #408 A2 moved the chart renderer to
`apps/views/summary_chart.py` and the task launcher to `apps/workflows/benchmark_operations.py`
Expand Down
2 changes: 1 addition & 1 deletion docs/external-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ conclusion.
| --- | --- |
| `cannbot enable / disable / describe / search / read` | implemented |
| `find` integration with gating, budgets, per-channel states | implemented |
| MindIE as a second channel | not yet; `apps/mindie/` has the reader, not the adapter |
| MindIE as a second channel | not yet; `apps/integrations/mindie/` has the reader, not the adapter |
| `cannbot serve` (stdio MCP proxying `discover` / `search` / `read_card`) | not yet |
| `campaign import-cannbot` (receipts into evidence) | not yet |
| Automatic clone, index build or deployment | deliberately absent |
Expand Down
49 changes: 38 additions & 11 deletions docs/module-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ its dashboard views and templates are in `apps/views/`, and the
collected-context projection is in `knowledge/context_projection.py`.
#371 owns the Apps composition. Its accepted directory follow-up
[#490](https://github.com/InferMatrixLab/InferRSI/issues/490) groups the implemented
storage, handoff and workflows slices described below.
storage, handoff, workflows and integrations slices described below.

The old `run` chain is split by owner. Its gates are in
`benchmark/legacy_run_v0.py`, its execution facts stay in `harness/`, and
Expand Down Expand Up @@ -41,8 +41,8 @@ through these exports; new pickles use the canonical definition. The retired
root `inferrsi.evidence_paths` has no alias and remains unavailable.

Shim removal requires a separate reviewed PR recording consumer migration,
wheel and plugin validation, and the first removal version. Integrations and
integrated acceptance remain subsequent #490 slices.
wheel and plugin validation, and the first removal version. Integrated acceptance
remains the final #490 slice.

### Apps handoff migration

Expand Down Expand Up @@ -89,6 +89,32 @@ map remains incompatible with a new runtime, including for `status` and `recover
Do not edit a frozen plan to bypass this check. Use the original pinned runtime
to resume, following [release-boundary recovery](optimization-workflow-unification.md#release-boundary-recovery).

### Apps integrations migration

`apps/integrations/cannbot/` owns the Cannbot channel, its project grant and its
reader worker. `apps/integrations/mindie/` owns the MindIE grant, context export,
stdio MCP and reader worker. CLI commands import these canonical packages on
demand. The new `integrations` initializer and the MindIE initializer import
nothing. Cannbot retains its existing `CannbotChannel` definition in its package
initializer; importing it does not read grants or start workers.

The [migration inventory](apps-module-migrations.json) records packages with
`package: true`. Compatibility packages and modules use explicit static imports
and literal `__all__`. Cannbot historically exports a `project` module, so
`module_exports` records its two-level mapping: the old package exports its old
project shim, whose public functions and classes are the canonical objects.
The shim and implementation retain their own module identities; no module alias
is installed. Both parent-first and child-first imports preserve that binding.
Private helper patches use the canonical modules.

Both project adapters resolve their sibling worker in the canonical directory.
The registered launchers use those files with the approved interpreter and the
existing `-I -B` flags. Each worker loads without InferRSI installed or a package
context, and its top-level imports are standard-library-only. Legacy worker
paths retain Python import compatibility; external interpreters are launched
against the canonical files. Grant schemas, read-only access, limits, revocation
and receipts are unchanged. MCP still starts through `inferrsi mindie serve`.

### Core and technical packages

The four target modules are peers: `knowledge`, `harness`, `benchmark`, and
Expand All @@ -114,7 +140,8 @@ root to an exact file set: 23 tracked files after C1, 21 after C2, 10 after R1
The two are `__init__.py` and `__main__.py`. M1 moved root `mindie_project.py`,
`mindie_context.py`, `mindie_mcp.py` and `_mindie_read_worker.py` to
`apps/mindie/project.py`, `context.py`, `mcp.py` and `read_worker.py` and deleted
the four root files with no forwarding shell or alias. A2 moved root
the four root files with no forwarding shell or alias. The integrations slice
later moved that Apps package into `apps/integrations/`. A2 moved root
`summary_chart.py` to
`apps/views/summary_chart.py` and root `benchmark_operations.py` to
`apps/benchmark_operations.py` and deleted both root files the same way. The workflows
Expand Down Expand Up @@ -188,7 +215,7 @@ Several flat modules remain shared seams until their slice starts.
| `knowledge/knowledge_operations.py`, `knowledge/knowledge_store.py`, `knowledge/catalog.py`, `knowledge/research.py`, `knowledge/skill_catalog.py`, `knowledge/_skill_selection.py`, `knowledge/_source_snapshot.py` | The seven Knowledge implementations, moved by K01 | Interfaces unchanged; the same-named root shells were deleted by R1 |
| `harness/records/` | Campaign manifests, traces, logs, profile captures and delivered-context captures | Imports no Knowledge or Apps module; `apps/workflows/campaign.py` supplies the backend names, the selection default and the context projection |
| `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/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 |
| `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/scenarios/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 |
| `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 |
Expand Down Expand Up @@ -606,15 +633,15 @@ M1 (#452) deleted the four root MindIE files the same way:

| Retired root module | Canonical module or file |
| --- | --- |
| `inferrsi.mindie_project` | `inferrsi.apps.mindie.project` |
| `inferrsi.mindie_context` | `inferrsi.apps.mindie.context` |
| `inferrsi.mindie_mcp` | `inferrsi.apps.mindie.mcp` |
| `inferrsi._mindie_read_worker` | `src/inferrsi/apps/mindie/read_worker.py`, a file run by path and not imported |
| `inferrsi.mindie_project` | `inferrsi.apps.integrations.mindie.project` |
| `inferrsi.mindie_context` | `inferrsi.apps.integrations.mindie.context` |
| `inferrsi.mindie_mcp` | `inferrsi.apps.integrations.mindie.mcp` |
| `inferrsi._mindie_read_worker` | `src/inferrsi/apps/integrations/mindie/read_worker.py`, a file run by path and not imported |

The four files moved with their code unchanged except the imports that name
their neighbours and the package version. `apps/mindie/__init__.py` imports
their neighbours and the package version. `apps/integrations/mindie/__init__.py` imports
nothing and does not re-export `__version__`; `mcp.py` reads it with
`from ... import __version__`. The worker is still started as
`from .... import __version__` after the integrations move. The worker is still started as
`python -I -B read_worker.py` with a private working directory, a 20 second limit
and a 2 MiB cap, opens SQLite read-only, imports only the standard library at
the top level and takes `mindie_knowledge` inside `read()`. It is not described
Expand Down
105 changes: 2 additions & 103 deletions src/inferrsi/apps/cannbot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,107 +1,6 @@
"""The cannbot-knowledge channel: an external read-only corpus beside ours."""
"""Compatibility exports for :mod:`inferrsi.apps.integrations.cannbot`."""

from __future__ import annotations

import time
from pathlib import Path

from ...knowledge.channels import (
ChannelHit,
ChannelRequest,
ChannelResult,
ChannelStatus,
)
from ..integrations.cannbot import CannbotChannel
from . import project

__all__ = ["CannbotChannel", "project"]

SCORE_SCALE = "cannbot/knowledge-search.v5"


class CannbotChannel:
"""Approved cannbot-knowledge checkout, queried through its own interpreter."""

def __init__(self, *, root: Path | None = None, timeout: float = 8.0):
from . import project

self._project = project
self.root = root
self.timeout = timeout
# `hint` records why this channel cannot answer before any search runs.
# Keeping it lets `find` report "not enabled" instead of telling the
# caller to declare a backend for a source that is not approved yet.
self.hint: ChannelStatus | None = None
try:
grant = project.load_grant(root)
except project.ChannelFailure as exc:
grant = {}
self.hint = ChannelStatus(exc.state, detail=str(exc), fix=exc.fix)
except (OSError, ValueError) as exc:
grant = {}
self.hint = ChannelStatus("rejected", detail=str(exc))
self.backend = "ascend"
self.declared_backend = grant.get("backend")
self.name = "cannbot-knowledge"

def describe(self, *, request: ChannelRequest) -> ChannelStatus:
try:
info = self._project.describe(self.root, timeout=request.remaining(), request=request)
except self._project.ChannelFailure as exc:
return ChannelStatus(exc.state, detail=str(exc), fix=exc.fix)
state = info.get("state", "rejected")
if state != "ok":
return ChannelStatus(
state if state != "rejected" else "rejected",
detail=str(info.get("detail") or ""), fix=str(info.get("fix") or ""),
)
return ChannelStatus("ok", revision=info.get("revision"))

def search(
self, query: str, *, platform: str | None, limit: int, request: ChannelRequest
) -> ChannelResult:
started = time.monotonic()
try:
payload = self._project.search(
query, platform=platform, limit=limit, root=self.root,
timeout=request.remaining(), request=request,
)
except self._project.ChannelFailure as exc:
return ChannelResult(
name=self.name, status=ChannelStatus(
exc.state, detail=str(exc), fix=exc.fix,
),
elapsed_ms=max(1, int((time.monotonic() - started) * 1000)),
)
elapsed = int((time.monotonic() - started) * 1000)
items = tuple(
ChannelHit(
locator=str(row.get("locator") or ""),
title=str(row.get("title") or ""),
summary=str(row.get("summary") or ""),
score=float(row.get("score") or 0),
score_scale=str(payload.get("score_scale") or SCORE_SCALE),
status=str(row.get("status") or ""),
platforms=tuple(row.get("platforms") or ()),
card_sha256=str(row.get("card_sha256") or ""),
source_card_sha256=str(row.get("source_card_sha256") or ""),
)
for row in payload.get("items") or []
if row.get("locator")
)
return ChannelResult(
name=self.name,
status=ChannelStatus("ok", revision=payload.get("revision")),
items=items,
elapsed_ms=elapsed,
score_scale=str(payload.get("score_scale") or SCORE_SCALE),
read_prefix="inferrsi cannbot read",
)

def read(self, locator: str, *, expected_sha256: str | None = None,
expected_revision: str | None = None) -> str:
payload = self._project.read(
locator, expected_sha256=expected_sha256, root=self.root,
expected_revision=expected_revision,
timeout=max(self.timeout, 15.0),
)
return str(payload.get("text") or "")
Loading
Loading