Skip to content

[model_edit] Rewiring a masked SPS physical port can select the wrong transformer endpoint #63

Description

@chengshaokang36-lgtm

Bug Report

BUG-001: [Simulink model_edit] — Rewire masked SPS physical port — Wrong endpoint or target not found

Reporter: Codex/Sol-Luna
Date: 2026-08-11
Severity: High
Reproducibility: Always


Summary

model_edit cannot reliably address conserving ports on the masked Specialized Power Systems Saturable Transformer used by the supplied model. Explicit disconnects fail to resolve, while a wildcard disconnect followed by a nominal RConn1/LConn1 restore reports success but restores the wrong transformer endpoint.

Expected Behavior

For each phase, the stable endpoint SID394/395/396 PortHandles.RConn(1)SID398/399/400 PortHandles.LConn(1) must disconnect and restore. After restore, the handle-level endpoint set and shared physical line must equal the original set exactly, with no additional branch or connection to LConn2, RConn2, RConn3, or RConn4.

Actual Behavior

Three edit attempts were observed. Explicit r/l and y/l targets were rejected and the old line remained. The R1 canonical target was normalized to a nonexistent out1 alias. R2 wildcard removal succeeded, but restoring RConn1LConn1 produced a connection to the transformer's LConn2 endpoint instead of the original RConn1.

Reproduction Steps

Prerequisites: MATLAB R2024b with Simulink Agentic Toolkit, the read-only Stage 1 checkpoint below, no model edits saved, and model_edit/model_read available.

  1. Verify the Stage 1 SHA-256 is 169F2C7C9F3A55AAD2FAAB05BE917A076A27B388484E574166D9368F2C7D9F76, then make a disposable copy named migration/stage2/PV_Boost_MMC_10kV_GFM_MIGRATION_STAGE2.slx.
  2. Open the copy and run model_read at root depth 0. Record the A connection blk_398.y1 <-> blk_394.r1 and independently resolve the ports from SID and PortHandles.
  3. Run model_edit in incremental mode with disconnect target blk_398.LConn1 <-> ?. Confirm with model_read and PortConnectivity that only the A direct attachment is absent and unrelated branches are unchanged.
  4. Run model_edit with connect target blk_394.RConn1 <-> blk_398.LConn1. Compare the restored endpoint set and shared line against the pre-disconnect capture.
  5. Observe that the A restore resolves to LConn2 rather than RConn1; close without saving and delete the disposable copy. The minimal reproduction stops here. B and C belong to the fix-acceptance test, not to the captured failure run.

This report reconstructs the reproduction from the exact Phase 7F/R1/R2 captures and Phase 7F-D1 read-only handle evidence. It was not rerun while filing because the user prohibited model creation and editing during Phase 7F-D2.

Minimal Reproduction

model_read(root, depth=0)
model_edit disconnect: blk_398.LConn1 <-> ?
model_read(root, depth=0)          % canonical A pair absent
model_edit connect: blk_394.RConn1 <-> blk_398.LConn1
model_read(root, depth=0)          % reports blk_398.y1 <-> blk_394.l2, not ...r1

No simulation is required.

Environment

Toolkit & Agent

Detail Value
SATK Version 2026.07.02
Agent / Client Codex desktop
Agent Workspace Root D:/PV_Inrush_New_Project
MCP Server Mode attach-to-existing (inferred from the active MATLAB connector)
Available MCP Tools check_matlab_code, detect_matlab_toolboxes, evaluate_matlab_code, model_check, model_edit, model_overview, model_query_params, model_read, model_resolve_params, model_test, run_matlab_file, run_matlab_test_file
MCP Config Project .vscode/mcp.json absent

Skills

Skills · 35 registered · 0 name-only · 1 invoked · 4 unregistered Simulink SATK manifests

SATK model-based-design-core · 11 registered

  • building-simulink-models, configuring-block-policy, curating-library-kg, filing-bug-reports, generate-requirement-drafts, managing-simulink-projects, setup-custom-libraries, simulating-simulink-models, specifying-mbd-algorithms, specifying-plant-models, testing-simulink-models
  • ✓ Unregistered in this host session but present as SATK manifests: check-authoring, checking-model-compliance, building-architecture-models, simulink-single-precision-conversion

SATK matlab-core · 7 registered

  • matlab-create-live-script, matlab-debugging, matlab-install-products, matlab-list-products, matlab-read-doc, matlab-review-code, matlab-testing

Other registered skill namespaces · 17

  • browser, documents, gmail, pdf, presentations, sites (2), spreadsheets (2), template-creator, visualize, plus unprefixed imagegen, openai-docs, plugin-creator, skill-creator, skill-installer, and hatch-pet

No registered skill was name-only. ◆ invoked · ✓ unregistered SATK manifest.

Skill Conflict Analysis

N/A — fewer than 2 skills were invoked for this documentation task.

MATLAB

Detail Value
MATLAB Version 24.2.0.2712019 (R2024b)
MATLAB Working Directory D:\PV_Inrush_New_Project
Simulink Version 24.2 (R2024b)
Relevant Toolboxes Simulink; Simulink Test not installed
satk_initialize Status Toolkit initialized in the attached session; which('model_read') resolved to C:\Users\<REDACTED_USER>\.matlab\agentic-toolkits\simulink\tools\model_read\model_read.p
Connector Port 31515

Platform

Detail Value
OS Microsoft Windows 11 Home China, version 10.0.26200, 64-bit
Architecture win64

Error Output

Phase 7F explicit targets:

Target not found: blk_394.r1 <-> blk_398.l1
Target not found: blk_394.y2 <-> blk_398.l1

Only the two A-phase target strings above were preserved verbatim in the execution record. No B/C error text is reconstructed as though it were captured output.

Phase 7F-R1:

status: error
message: Target not found: blk_398.out1 <-> blk_394.r1

Phase 7F-R2 restore:

status: ok

The subsequent model_read topology was:

blk_398.y1 <-> blk_394.l2

The original topology was:

blk_398.y1 <-> blk_394.r1

Visual Evidence

None. The defect is captured by model topology and handle-level evidence.

Impact

  • Scope: Workflows that edit conserving ports on this masked Specialized Power Systems topology through model_edit.
  • Risk: A reported-success rewiring can silently connect the wrong transformer winding terminal.
  • Workaround: None known through model_edit; wildcard removal alone is insufficient because exact safe restoration is unavailable.
  • Blocking: Blocks Phase 7F Stage 2 and downstream protection migration that depends on the LV measurement insertion.

Related Files

File Relevance
migration/stage1/PV_Boost_MMC_10kV_GFM_MIGRATION_STAGE1.slx Read-only reproduction source; SHA-256 169F2C7C9F3A55AAD2FAAB05BE917A076A27B388484E574166D9368F2C7D9F76
PV_Boost_MMC_10kV_GFM_PROTECTION_RESEARCH.slx Read-only topology reference; SHA-256 1B114229B3D3E448143AB97B636546F484F7DB51B66589B7A533123649C51C01
PV_Boost_MMC_10kV_GFM_WORK.slx Read-only formal source; SHA-256 BAB86683CB6640A1121040CBAAE6C1138D5BE3B372B3212A5BB6A74282C4B245
docs/specs/algorithms/transformer-protection-migration/transformer-protection-migration-stage2-physical-port-diagnostic.md Stable SID/PortHandles, masked-port, line-handle, and rollback evidence
docs/specs/algorithms/transformer-protection-migration/transformer-protection-migration-stage2-physical-wiring-contract-r1.md Blocking gate and required handle-level qualification
docs/specs/algorithms/transformer-protection-migration/transformer-protection-migration-stage2-satk-fix-survey.md Official release/known-issue survey through SATK 2026.08.05; no qualifying fix found

Stage 1 D1 session-local handle evidence: A transformer block 116740.073974609, RConn1 116743.073974609; LV-open block 118570.038574219, LConn1 118571.038574219; shared line 117007.074340820. Numeric handles are session-local; stable selectors are SID plus PortHandles field/index.

Rollback Record

Attempt Stop condition Saved Stage 2 Final Stage 2 artifact Source-hash result
Phase 7F Explicit physical pair could not be disconnected; adding the measurement path would have left the original line in parallel No Deleted Research 1B1142..., formal BAB866..., Stage 1 169F2C... unchanged
Phase 7F-R1 Canonical alias normalized to nonexistent out1 and returned target-not-found No Deleted All three frozen hashes unchanged
Phase 7F-R2 Wildcard removal succeeded, but restore connected to transformer LConn2 rather than RConn1 No Deleted All three frozen hashes unchanged

Notes

The topology diagnostic independently confirms the intended endpoints and phase order. Observation/hypothesis only: the tool appears to apply an alias mapping for masked SPS ports that can map a requested RConn1 token to another conserving port. This is not a root-cause conclusion and does not prescribe a fix.

Fix Acceptance Test

  • Use a disposable copy only; resolve ports dynamically from stable SID plus PortHandles field/index. Never persist numeric handles.
  • Capture the original A/B/C port-handle pairs, line handles, line endpoint sets, and full physical connectivity inventory.
  • In one run, perform A/B/C disconnect and exact restore sequentially.
  • After each disconnect, prove only the intended direct line is absent; no unrelated network branch is removed or merged.
  • After each restore, prove the handle-level endpoint set exactly equals the pre-disconnect pair and the full normalized connectivity inventory returns to its original value.
  • Explicitly reject any endpoint involving LConn2, RConn2, RConn3, or RConn4 where RConn1 is required.
  • Include negative tests for displayed y, r, and l aliases; an invalid alias must fail explicitly and must never silently select another endpoint.
  • Verify all three phases in the same run with no phase crossover or extra branch.
  • Verify research, formal, and Stage 1 source hashes remain unchanged and no source is saved.
  • On any failure, close without saving and leave no Stage 2 or passed-test artifact.

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions