Skip to content

An inserted structure's activator reads the inserted Parameter - #652

Merged
MerciHanrim merged 1 commit into
mainfrom
activator-ref-insert-extract
Nov 23, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
activator-ref-insert-extract

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #619 (item 2 only; items 3, 4, 1 and 5 stay for their own scopes).

What was wrong

An activator can compare with a Parameter (>= @p, < @p - 1, docs/parameter-activator.md §PA4). Structure insert re-issues every node id, and rewrites the @id in a Register expression and in a @param flow, but it left the activator's @id as it was:

  • inserted into a document that has its own node p, the activator read that node, not the inserted Parameter;
  • inserted into a document without p, it read no node.

Extract (Save selected structure…) let such an activator through without its Parameter, while it refuses a Register or a flow that does the same.

Found while fixing, not in the #619 text: a selection holding the activator and its Parameter was written as a version 1 file when nothing else in it needed version 2. In version 1 >= @p is not a Parameter reference (§PA4), so the insert could not re-issue it either, and the run did not open the gate.

The change (src/model/moduleGraph.ts)

  • Insert: an activator's @id is read with the engine's own parseActivatorExpr at the module's version and written back as the Inspector writes it, op @newId [± n]. A literal comparison is unchanged. An @id that is not a module node (a hand-made file) refuses the insert, as for a Register.
  • Extract: an activator whose Parameter is outside the selection is a dangling reference. The refusal names it in the same words as for a Register (m_act → m_th).
  • Extract: a selection with such an activator is a version 2 file at least.
  • docs/module-system.md §MS2.2, §MS2.4, §MS3.1 and B1 say the same.

Tests (src/model/moduleGraph.test.ts), written first

On main's code, 6 of the 9 new tests fail. The literal test and the two controls pass.

Test On main's code With the fix
Insert into a host with its own m_th (100): expr >= @m_th >= @<inserted id>
Same: first step moves the gated Source 0 1
Insert into an empty host: expr / first step >= @m_th / 0 rewritten / 1
Offset kept: < @m_th - 2 unchanged < @<inserted id> - 2
Module activator reading a node outside it: insert accepted refused, names elsewhere
Literal >= 3 unchanged unchanged (control)
Extract without the Parameter accepted refused, dangling = m_act → m_th
Extract with the Parameter accepted accepted
Extract then insert: file version / expr / first step 1 / >= @m_th / 0 2 / rewritten / 1
Control: Register @m_th + 1 rewritten, extract refused the same

The run checks step the engine (step) once on the inserted graph. The Source behind the activator moves 1 only when the activator reads the inserted Parameter (5 against a Pool of 10). The host's own m_th is 100.

Checks

  • npx tsc -b: clean.
  • npm run lint: 88 warnings, the baseline.
  • All check:* scripts: pass.
  • Unit suite: 5728 passed, 4 skipped.
  • Related e2e, one worker, no retries: e2e/module-system.spec.ts and e2e/structure-save-version.spec.ts, 17 passed. They hold no screenshot comparisons.

What it touches

  • Only structure insert and Save selected structure…; the engine and the activator grammar are unchanged.
  • Documents with an activator that reads a Parameter: the four gacha examples (one to nine such activators each) and user documents built the same way.
  • A structure file saved before this change with such an activator and its Parameter is version 1. Its comparison is not a Parameter reference, and this change does not repair it: save the structure again.
  • A file now written as version 2 for this reason turns a version 1 document it is inserted into into a version 2 document, with the existing promotion notice.

Insert re-issues an activator's @id (op @id [± n]) with the module's other ids and refuses one outside the module; Extract refuses an activator whose Parameter is outside the selection and writes such a selection as a version 2 file. Part of #619.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 23, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: 752d831
Status: ✅  Deploy successful!
Preview URL: https://55da8f68.cozy-loop-studio.pages.dev
Branch Preview URL: https://activator-ref-insert-extract.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit 9846dcf into main Nov 23, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the activator-ref-insert-extract branch November 23, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant