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
Binary file modified analysis/uml/nn.vpp
Binary file not shown.
12 changes: 11 additions & 1 deletion docs/knowledge/architecture/browser-mcp.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
kind: knowledge
status: current
updated: 2026-08-30
updated: 2026-09-14
---

# Browser-backed MCP architecture
Expand Down Expand Up @@ -116,6 +116,16 @@ counterparts use the distinct routes above.
| Format view | `FlowCanvas` calls `diagram.autoLayout` for horizontal/vertical **Disponi**. No MCP tool or browser RPC case exposes it. `fit_view`, `center_view` and `move_nodes` are not equivalent. |
| Screenshot | CDP capture supports optional reload and output-handle hover. It neither performs layout nor waits for the editor's layout/render completion, so it does not enforce the required layout-before-capture workflow. |
| Open a project | MCP exposes `create_project({projectPath,id,version,name,description})` and `open_project({projectPath})` through a confined `NNM_PROJECT_ROOT`; the server prepares/loads bytes and the browser bridge owns activation and model-save notifications. A live browser tab is still required before activation; `import_diagram`/`reset_diagram` remain distinct operations. |
| Create stereotype | `create_stereotype` validates the complete JSON form shape at MCP, then delegates the unchanged semantic request to the selected browser's shared project-authoring service and stereotype coordinator. The browser writes, stages and activates the project package. |
| Delete stereotype | `delete_stereotype({id,version,path})` delegates exact ownership, graph-use and dependency checks to the shared browser coordinator. The UI uses the same operation with confirmation; core, missing, in-use and dependency-required packages are rejected without cascade. |
| Create dataset | `create_dataset` exposes the complete dataset form shape. Optional file bytes use canonical base64 only across JSON and are decoded before the shared browser dataset coordinator validates and writes them. |
| Delete dataset | `delete_dataset({id,version,path})` delegates to the same coordinator as the UI. It removes the project manifest/directory/catalog/training descriptor while preserving backend archives and historical jobs. |

The four authoring operations are serialized by the browser-owned project
authoring service. Package-scope transitions temporarily suppress the visible
catalog and reject package-node additions until the runtime commit or rollback
finishes, so asynchronous create/delete/import work cannot reintroduce an
identity absent from the committed project scope.

### Implementation evidence

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
kind: decision
status: accepted
updated: 2026-09-10
updated: 2026-09-14
---

# Writable project workspaces and model-owned stereotype authoring
Expand Down Expand Up @@ -58,6 +58,18 @@ the user can edit the Lua and PyTorch implementations outside NNModelling.
`inference.lua`, and `pytorch.py`, adds the exact relative entry to the
model's `manifest.customPackages`, stages the resulting package scope, and
exposes the stereotype in the current palette.
- An exact project-owned stereotype may be deleted from the visible manager or
through browser-backed MCP. Core packages are immutable. Deletion is rejected
when the graph uses the exact package identity or another project-owned package
resolves it as a dependency; the operation never cascades into nodes or rewrites
dependencies. The editor runtime resolves dependency ranges against the complete
model scope while loading project package records and exposes those exact keys
through `packageExports()` for the shared UI/MCP deletion guard.
- Successful deletion removes the exact `manifest.customPackages` entry,
project-relative package directory and active runtime/catalog entry. The next
scope is staged before commit. On write, removal or activation failure, the
previous manifest, package bytes and runtime scope are restored; unrelated
project resources are never removed.
- Generation is transactional from the application's perspective: validate
all content and the staged package scope before committing it; on a later
filesystem or activation failure, restore the previous model and remove only
Expand Down Expand Up @@ -85,6 +97,9 @@ the user can edit the Lua and PyTorch implementations outside NNModelling.
automatic saving.
- Project creation, opening, graph editing, package authoring, and backend
export all operate on the same `core + current-model-custom` package scope.
- UI and browser-backed MCP creation/deletion call the same project authoring
coordinators. The MCP boundary adapts JSON transport but does not own a second
generator, package catalog or filesystem model.
- Direct edits made by another application are not watched automatically.
Reloading a project or an explicit future refresh action is the boundary for
rereading those files.
Expand All @@ -100,5 +115,8 @@ the user can edit the Lua and PyTorch implementations outside NNModelling.

## Implementation

The executable work is defined in
The base workspace and authoring work is defined in
[`../../plans/active/project-workspaces-and-stereotype-authoring/plan.md`](../../plans/active/project-workspaces-and-stereotype-authoring/plan.md).
UI/MCP creation and deletion parity is tracked by the
[`../../plans/active/mcp-project-authoring-parity/plan.md`](../../plans/active/mcp-project-authoring-parity/plan.md)
initiative.
62 changes: 44 additions & 18 deletions docs/knowledge/uml/mcp-use-case-parity.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
---
kind: decision
status: accepted
updated: 2026-08-30
updated: 2026-09-14
---

# MCP use-case parity with the editor

## Context and authority

The MCP interface must expose the agent-facing modeling and training workflows
below, not merely a collection of low-level graph and HTTP operations. This is
The MCP interface must expose the agent-facing modeling, project-authoring and
training workflows below, not merely a collection of low-level graph and HTTP operations. This is
an accepted functional constraint, not a claim that the server already
implements it. The [browser-backed MCP architecture](../architecture/browser-mcp.md)
describes actual implementation and gaps separately. The
[adaptation plan](../../plans/active/mcp-use-case-parity/plan.md) maps these
requirements to implementation tasks and verification gates; its existence does
not mean the server already satisfies this constraint.
[adaptation plan](../../plans/active/mcp-use-case-parity/plan.md) and the
[project-authoring parity plan](../../plans/active/mcp-project-authoring-parity/plan.md)
map these requirements to implementation tasks and verification gates; their
existence does not mean the server already satisfies this constraint.

The diagram preserves the user-supplied use cases, associations, extension and
notes. `Agent` is the single primary actor. The two groups are capability areas,
Expand All @@ -31,21 +32,25 @@ flowchart LR

subgraph TRAINING["Training"]
direction TB
T1(["Collegarsi al backend"])
T2(["Modificare parametri"])
T3(["Lanciare training"])
T4(["Monitoraggio training"])
T1(["Connect to backend"])
T2(["Edit training parameters"])
T3(["Start training"])
T4(["Monitor training"])
T5(["Download wheel"])
end

subgraph MODELLAZIONE["Modellazione"]
subgraph MODELING["Modeling"]
direction TB
M1(["Aggiungere nodo al canvas"])
M2(["Collegare nodi"])
M3(["Modificare parametri nodi"])
M4(["Formattare la vista"])
M5(["Screenshot<br/>─────────────<br/>extension points<br/>Formattare la vista"])
M6(["Aprire un progetto"])
M1(["Add node to canvas"])
M2(["Connect nodes"])
M3(["Edit node parameters"])
M4(["Format view"])
M5(["Screenshot<br/>─────────────<br/>extension points<br/>Format view"])
M6(["Open a project"])
M7(["Create stereotype"])
M8(["Delete stereotype"])
M9(["Create dataset"])
M10(["Delete dataset"])

M4 -. "«extend»" .-> M5
end
Expand All @@ -62,19 +67,28 @@ flowchart LR
A --- M4
A --- M5
A --- M6
A --- M7
A --- M8
A --- M9
A --- M10

N1["«note»<br/>Every training parameter shown in the sidebar<br/>must be editable through MCP."]

N2["«note»<br/>Create a node by filling in its stereotype parameters.<br/>Creation must behave exactly like selecting the stereotype<br/>in the browser sidebar and clicking Create."]

N3["«note»<br/>Use the editor's Arrange (Disponi) operation<br/>to place nodes in a standard layout.<br/>Run it BEFORE capturing the browser screenshot.<br/>Support both horizontal and vertical layouts."]
N3["«note»<br/>Use the editor's Arrange operation<br/>to place nodes in a standard layout.<br/>Run it BEFORE capturing the browser screenshot.<br/>Support both horizontal and vertical layouts."]

N4["«note»<br/>The MCP server must create a new project<br/>or open an existing one.<br/>Project creation must use the same parameters and behavior<br/>as the graphical interface, sharing as much code as possible."]
N5["«note»<br/>MCP stereotype and dataset creation uses the same semantic<br/>parameters, validation, defaults and project transaction as the UI.<br/>Deletion is available in both UI and MCP and removes only project-owned resources."]

T2 -.- N1
M1 -.- N2
M4 -.- N3
M6 -.- N4
M7 -.- N5
M8 -.- N5
M9 -.- N5
M10 -.- N5
```

## Required observable behavior
Expand All @@ -92,6 +106,18 @@ flowchart LR
| M4 | Format view | Apply the editor's **Disponi** auto-layout in either horizontal or vertical direction. Panning, zooming, fitting the viewport, or manually guessing node coordinates are not equivalent. |
| M5 | Screenshot | Capture the browser diagram after the required layout has been applied and rendered. |
| M6 | Open a project | Create a new project or open an existing one through the browser's shared project workflow. Creation exposes the same form parameters, defaults, validation and behavior as the UI; opening activates the same writable project and resource scope. |
| M7 | Create stereotype | Create one project-owned stereotype with the UI form's complete semantic request: identity, directory, display metadata, kind, view, dependencies, parameter definitions and optional objective metadata. The shared browser transaction writes and activates the package. |
| M8 | Delete stereotype | Delete only an exact project-owned stereotype through a UI confirmation or MCP request. Reject core, missing, graph-used or dependency-required packages. Success removes the exact manifest entry, project directory, active catalog/runtime entry and palette entry without deleting nodes or cascading to other packages. |
| M9 | Create dataset | Create one project-owned dataset with the UI form's complete semantic request: identity, directory, display metadata, parameter definitions, named input/target slots, class metadata and optional data files. Binary file transport may be adapted to JSON-safe base64 without changing domain semantics. |
| M10 | Delete dataset | Delete only an exact project-owned dataset through a UI confirmation or MCP request. Success removes its manifest entry, exact project directory, browser catalog entry and active training descriptor; immutable backend uploads and historical jobs are preserved. |

Creation and deletion are project authoring operations, not graph-node creation
or backend archive administration. Both entry points must call the same
browser-owned coordinators. Destructive calls identify the exact project
resource by ID, version and relative path; display names are never identities.
Failures preserve the previous manifest, runtime/catalog state and unrelated
files. No deletion operation may cascade into graph nodes, dependent packages,
backend dataset archives or historical jobs.

The original `«extend»` relation is retained faithfully. Its note explicitly
requires layout **before** screenshot; this ordering is the acceptance rule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# T05 final QA evidence

**Run date:** 2026-09-14
**Result:** PASS — automated gates and disposable live UI/MCP QA passed.

## Automated gates

| Gate | Result | Evidence |
| --- | --- | --- |
| `pnpm --dir front-end check` | Pass | 0 errors; 35 warnings across 8 files. |
| `pnpm --dir front-end test` | Pass | 50 files; 302 tests passed. |
| `pnpm --dir front-end guard:package-only` | Pass | `package-only guard: ok` with the current `data.package` identity contract (`id` and `version`). |
| `pnpm --dir mcp-server test` | Pass | TypeScript build succeeded; 7 files and 74 tests passed. |
| `git diff --check` | Pass | No whitespace errors. |

The implementation owner also reported 10/10 focused authoring tests passing. The full frontend suite above was rerun after the final runtime dependency-resolution fix.

## Disposable live-project QA

Used a temporary copy of the existing VAE project at `/tmp/nnmodelling-t05-commit-qa`; all live authoring and failure injection targeted this clone. The public MCP registry exposed all four authoring tools.

- Created semantically equivalent stereotypes through the UI (`qa.ui-layer`) and MCP (`qa.mcp-layer`). Their project folders contained the expected four package files and appeared in the live catalog.
- Created equivalent named-slot datasets through the UI (`qa.ui-dataset`) and MCP (`qa.mcp-dataset`), plus an MCP dataset with `dataFiles`. The manifests, generated source and live catalog reflected the submitted contracts; `data/probe.bin` contained exactly `00 01 02 03 04`.
- Created `qa.guard-target` and `qa.guard-dependent` through MCP. Runtime diagnostics were clear, and deleting the target while required was rejected with “required by another project stereotype” and no mutation. Deleting the dependent then allowed the target deletion.
- Core stereotype deletion and deletion of graph-used `example.vae.sampling@0.1.0` were both rejected without mutation.
- UI cancellation of `qa.mcp-dataset` left it listed and present. Confirmed UI deletion then removed it. UI deletion of `qa.ui-layer` and MCP deletion of `qa.mcp-layer`, `qa.ui-dataset` and the file-backed dataset succeeded through their respective paths.
- Injected an `EACCES` failure by removing write permission from the package parent before deleting `qa.ui-layer` through MCP. The operation failed; SHA-256 hashes of `model.json` and all stereotype files were unchanged, the package remained, and the parent permission was restored.
- Reopened the clone through MCP. The existing VAE graph returned as Saved with `resourceCount: 17`, and no QA resources remained in its project folders or catalogs.

The earlier live failure of the dependency guard is superseded by this run: the latest runtime resolves dependency ranges against the complete package scope, and the live guard now rejects the dependent deletion before mutation.

## Cleanup and final state

Removed the disposable project and rollback snapshots. Stopped the temporary-root MCP server and restarted the local server against the repository's existing `Variational Autoencoder` project (`example.vae-mnist`, `resourceCount: 17`). The original project opened successfully in the in-app editor. `git status --short -- examples/` is empty; no QA changes remain in `examples/` or `transformer.spam`.
Loading
Loading