Skip to content

Add Mosaic Add-on Studio: development, validation, and review environment for Mosaic Companion extensions - #22

Open
BitSempre wants to merge 1 commit into
hypercycle-development:mainfrom
BitSempre:feat/mosaic-addon-studio
Open

BitSempre wants to merge 1 commit into
hypercycle-development:mainfrom
BitSempre:feat/mosaic-addon-studio

Conversation

@BitSempre

@BitSempre BitSempre commented Nov 3, 2026 •

Copy link
Copy Markdown

Add Mosaic Add-on Studio (mosaic-addon-studio). Self-contained Studio for Mosaic Companion. MIT License. Signed-off-by BitSempre.

@BitSempre
BitSempre force-pushed the feat/mosaic-addon-studio branch 2 times, most recently from d26b990 to a845c47 Compare November 24, 2026 23:34
zephyrnova added a commit that referenced this pull request Nov 27, 2026
The same review pass checked whether the base-revision property actually holds —
that everything judging a submission runs from the base revision and never from
the pull request's own tree. It does, for every step: each `node` invocation and
every policy file comes from the `base` worktree, `adjudicate.mjs` and its
`--repo` are the same checkout so the policy-beside-itself trap is avoided, and
nothing before the gates executes anything from the submitted tree.

THE EXCEPTION IS THE WORKFLOW ITSELF. On a `pull_request` event GitHub executes
the workflow YAML from the pull request's merge commit, not from the base. The
comment in this file saying a gate "cannot be the thing that protects itself" is
true of `addon-pr.yml` too: a submission that adds `addons/x/**` and replaces
this file with a job of the same name that exits 0 produces a green check, and
stage 1 never runs because stage 1 is inside the replaced file. The exposure is
bounded — a forged check, no CI privilege, and the `.github/` change is visible
in the diff — but nothing addressed it.

`.github/CODEOWNERS` makes that require a maintainer's review, and records the
standing rule that matters more than the mechanism: an add-on submission has no
reason to touch the review machinery, the licensing terms or the publisher keys,
so one that does is refused on sight rather than read. It needs "Require review
from Code Owners" set on `main` to have effect; without that it is advisory.

Four smaller things in the workflow.

The commit counter was wrong, and in the worst direction. On a `pull_request`
event the checkout is the synthetic merge commit, so `git rev-list --count`
returned 2 for a one-commit submission and the "squash and force-push" error
fired on every pull request. `format-patch` omits merges, so stage 0 was right
all along and only the advice was wrong — which teaches contributors to distrust
a correct gate. `--no-merges`.

The add-on id was interpolated into shell steps as a `${{ }}` expression, which
is substituted into the script text before bash parses it. The id is cut out of
a path by `sed`, and git C-quotes only `"`, `\` and control bytes — so `$`, `(`,
`)`, `|`, `;` and spaces survive a path intact. Nothing exploitable could reach
those steps, because stage 3 refuses a bad id first; but that protection lives
in another file behind another gate, which is the pattern this workflow warns
about everywhere else. The id now goes through `env:`, and the identify step
refuses anything that is not `[a-z][a-z0-9-]{1,40}` before any later step sees
it.

The checkout persisted credentials into `.git/config`, and a later step runs the
submission's own build and test scripts, which can read them. Nothing here needs
them: `fetch-depth: 0` has already fetched everything and the only subsequent
remote operation is an anonymous clone of a public repository.

And the job summary is writable from those same steps, so a submission could
append its own Markdown to this job's report. It cannot alter what is already
there, so the verdict is now written before any submitted code runs and anything
appended appears below it.

Two correctness fixes beside those. The surface artifact records the commit it
was generated from, and nothing compared it to what the pinned tag resolves to —
a moved tag would judge submissions against one revision while testing them
against another; that is now checked. And the two halves of this pull request
disagreed about lockfiles: the `lockfile-present` gate failed a missing one while
this workflow carried on with a `::notice`. The gate is right, because
publication runs `npm ci` and `npm ci` fails outright without a lockfile, so the
build step now says so and stops.

`dco-matches-author` compared two sets over the whole patch, which let a
multi-commit submission pass on the strength of one correct pair. Measured on
#22, whose second commit is authored `...+BitSempre@...` and signed off
`...+BitSiempre@...` — an inserted letter, in the address and not just the
display name — and the set check saw the first commit's correct sign-off and
passed. The DCO is an assertion by the author of each commit, so it is now
checked commit by commit.

Signed-off-by: Robert Moir <130709596+zephyrnova@users.noreply.github.com>

@zephyrnova zephyrnova left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this — and for a submission that passes every mechanical gate on its own merits. Zero permissions declared and none needed, licence and lockfile clean, scoped entirely to its own directory, and 4,871 lines of reviewable source. Two specific things are worth naming before anything else: capability-rules.mjs blanks comments before scanning, which is the same conclusion our own post-mortem reached after a comment explaining why an add-on deliberately did not call an API was read as a call to it; and src/host.js sets canReachUserProjects: false and says so in a comment, which is a tool stating a capability it does not have. Neither is common.

Two clerical items, and one squash fixes both.

The branch carries two commits, and a submission is one logical commit (CONTRIBUTING.md). Separately, the second commit is authored 26889439+BitSempre@users.noreply.github.com and signed off 26889439+BitSiempre@users.noreply.github.com — an inserted letter, in the address rather than only the display name — so the DCO check does not match it to its author. Correcting the trailer while squashing resolves both:

git reset --soft $(git merge-base origin/main HEAD) && git commit -s && git push --force-with-lease

Neither is a judgement about the second commit, which is a good change: it makes npm test actually run, and our own review never caught that because stage 7 was not run on this pull request.

One change request, and it is a request to delete code rather than write any.

shared/mosaic-app-reference.data.mjs carries a provenance block naming electron/addon-preload.ts, electron/addons/api/*.ts and src/components/Sidebar.tsx at v0.1.13, generated 2026-11-01. Those are the same three sources, at the same release, that this repository's own adjudicator is built from. So the Studio contains a second implementation of the gate a submission has to pass — and the two already disagree. Our renderable tab.icon set has 32 names; the Studio's has 31, missing Eth. Ours is the compiler-enforced one: the app holds the list to the sidebar's own icon map through a Record<AddonIconName, ...>, so a name missing from it fails the build. As it stands, the Studio would tell an author that a manifest the app renders perfectly well is invalid.

That is a false block produced by a mirrored list, and it is the failure mode this repository has paid for repeatedly — nine times by our own count, every one of them a defect in our checking rather than in a submission.

The app now publishes that description as an artifact precisely so nobody has to mirror it. It is at scripts/adjudicate/addon-surface.json on main, pinned to a release and carrying the commit it was generated from, and it is attached as an asset to each app release. It states the window.addonAPI namespaces and their methods, the permission each requires, the grantable and reserved vocabularies, the reserved IPC namespaces, the manifest patterns and limits, the renderable icon set and its fallback — and the app version at which each method and permission first appeared.

So the request is that the Studio read that file instead of generating its own description. The benefit is not tidiness: a builder whose rules are a hand-copy of ours is wrong every time we change something, and the only version of this that survives contact with a moving app is one where the rules come from the app. We would rather not be in a position where people building with the Studio produce manifests our gate rejects.

This does not make anything here depend on the Studio. The dependency runs the other way, and only on a file already published.

What this review did not establish.

The mechanical tiers were run; the reading tier was not. The 854-line App.jsx and the 585-line capability-rules.mjs have not been read against their own claims, and that is the layer that found every honesty defect in the previous four review rounds — a button reporting work it had not done, a badge over demo data, a status that was always green. That reading is the next pass, not a finding against this submission. Stage 7 is also outstanding: renderer/ is build output here, so the bundle a user would install has not been seen by anyone.

Four network hosts appear in the code, after our own scan was corrected to stop counting npm's lockfile URLs and SVG namespace declarations: github.com, example.com, www.apache.org and www.gnu.org. All four read as licence and documentation strings rather than endpoints, and the only live call is to 127.0.0.1. That will be confirmed in the reading pass rather than taken on trust.

Three of this round's gate failures were defects in our own checks, not in this submission, and all three are now fixed: RegExp.prototype.exec being read as process execution — which fired twice on the Studio's own manifest validator — the host list diluted from four real hosts to nine by npm's, and src/host.js reported as imported by nothing while App.jsx imports it.

…ment for Mosaic Companion extensions

Adds the Mosaic Add-on Studio as an add-on under addons/mosaic-addon-studio/.

- Checks add-ons against the official add-on surface
  (scripts/adjudicate/addon-surface.json, pinned at cf3f5f7 and vendored
  with provenance and an integrity check) instead of a hand-copied
  description of the app. The renderable icon set now matches the app's:
  32 names, including Eth.
- Capability scanner: reads comments, strings, templates and regex literals
  correctly, runs in linear time, and reports code it cannot read instead of
  skipping it.
- One generator for starter projects and licence texts, shared by the
  in-Mosaic host and the validator.
- Manifest rules: strict SemVer, buckets:publish requires a publishes list,
  input and homepage validation.
- Host fixes (appVersion, validateProject contract, jail path normalisation)
  with regression tests.
- Tests: 221 in this directory, all passing, none skipped. Tests that need
  the Studio development repository stay in that repository (273 there, all
  passing).

Signed-off-by: BitSempre <26889439+BitSempre@users.noreply.github.com>
@BitSempre
BitSempre force-pushed the feat/mosaic-addon-studio branch from a845c47 to ce67614 Compare December 2, 2026 19:00
@BitSempre

Copy link
Copy Markdown
Author

Thank you for the careful review. The branch is updated: feat/mosaic-addon-studio now holds one commit, ce67614 (parent cd6bee7, the merge base with main). A heads-up before the points: shared/capability-rules.mjs is no longer the 584-line file you looked at. It is now 1,178 lines, so the reading pass should be done on the new version.

1. One logical commit. Done. The two earlier commits have been consolidated into a single commit on cd6bee7, pushed with --force-with-lease.

2. DCO. You were right: the second previous commit had a Signed-off-by email containing an extra i compared with the author's email. The new commit is authored and signed off as BitSempre <26889439+BitSempre@users.noreply.github.com>, and the GitHub DCO check passes. It carries a DCO sign-off only, not a cryptographic signature.

3. Read the published surface instead of mirroring it.

  • shared/mosaic-app-reference.mjs and shared/mosaic-app-reference.data.mjs have been deleted.
  • shared/addon-surface.json is a vendored copy of scripts/adjudicate/addon-surface.json. It is byte-identical to the corresponding file on upstream main at the time of this check (Git blob f0533d5d97cf7b7158ad72ee6d5a192668100108, SHA-256 748c5d28e25c43f8e1d59c94e2d60c3b5d063ee2fb139b7b4a8e49ee5b3ac31e). shared/addon-surface.provenance.json records the source repository and path, the commit that last changed the file (cf3f5f7), the app version it describes (v0.1.13), and the retrieval date. It also records that the file was taken from main, because the v0.1.13 release had no addon-surface.json asset when retrieved.
  • API namespaces and methods, permissions, reserved namespaces, manifest patterns and limits, and the icon set are read from that file by shared/mosaic-schema.mjs. The artifact contains 32 icon names, including Eth, which is covered by a test.
  • The loader validates the file. If it is unusable, the UI shows an error and every check fails rather than silently proceeding without the surface definition. An integrity test checks its SHA-256 and size against the provenance record.
  • Still hand-maintained, not from the artifact: the allowed npm script names (ALLOWED_ADDON_SCRIPTS, transcribed from policy.mjs), the update-check modes (UPDATE_CHECK_MODES), and the preferred starter icon (Sparkles).
  • Limit: the Studio reads a pinned copy, not the live upstream file, so the pin only changes when someone explicitly re-vendors it. The drift check and scheduled workflow that compare the pin with upstream live in the Studio development repository and are not part of this PR. Some comments in shared/ also point to files or commands available only in that development repository (docs/ADDON_SURFACE.md, npm run surface:verify).
  • Source-text tests check that the three shared rule modules (mosaic-schema, manifest-rules, and capability-rules) do not contain fetch( or imports of node:fs, node:http, node:child_process, or node:net. These checks do not constitute a sandbox or a complete network-security guarantee.

4. What the review did not establish.

  • Reading pass. Changed since the version you saw: src/App.jsx (+35 −43: name and description limits come from the shared rules, the starter manifest comes from one shared builder, the "capability checks ran against" line shows the pinned surface and its hash, and an error card appears if the surface is unusable); src/host.js (+12 −141: it uses the shared generator and the licence classifier; canReachUserProjects: false for the in-Mosaic host remains unchanged); and shared/capability-rules.mjs, which has been substantially rewritten.
  • Network hosts. The hostname strings found in the published source, tests and NOTICE are example.com, fsf.org, github.com, lucide.dev, react.dev, www.apache.org, and www.gnu.org. These findings do not establish that each hostname is an active network destination. The only fetch call found is in src/host.js:52; it uses relative /api/... URLs, served by the local development server. I have not performed a broader network-behaviour audit.
  • Stage 7. renderer/ is build output and is not included in this change. The add-on directory's npm run build succeeded in the recorded validation, but I have not independently verified the stage-7 result.

5. What changed and what is still open.

  • Capability scanner: comments, strings, template literals and regex literals are handled by the scanner. Alias tracking was also changed to avoid repeated scans. In one recorded 489 KB adversarial benchmark, execution time fell from 63 seconds to under one second. This is a measured result for that input, not a claim that every possible input has been exhaustively tested. Code the scanner cannot read (an oversized interpolation, regex or destructuring pattern) is reported as an error with file and line instead of being silently skipped.
  • Shared generation: one generator for starter projects and licence texts is used by the host and validator. Previously, the host wrote shortened Apache and GPL texts that the validator rejected.
  • Manifest rules: strict SemVer for minAppVersion, requiring a publishes list for buckets:publish, input and homepage validation, and rejection of control and format characters (including bidi characters) in names and descriptions.
  • Tests: in the last recorded PR test run before the push, all 221 tests passed, with none skipped. The separate Studio development repository had 273 passing tests in its last recorded run. A mutation run of 103 deliberate faults killed all 103, with no survivors or unapplied mutants. These results were not rerun while preparing this response; the mutation tooling and Studio-only tests are not included in this PR.
  • Automated review: an automated, AI-assisted adversarial review approved on its sixth round, after earlier rounds raised findings that were subsequently fixed. This was not a human review. The OpenCode review was not completed, and I do not present it as a completed independent review.
  • Adjudicator gate: the final recorded run over the full diff returned REVIEW: 13 gates passed, none failed, and three items were left for human judgment. They were not suppressed:
    1. test/addon-surface.test.mjs:451 — a source-text test checking for the absence of fetch( in the shared modules.
    2. test/addon-surface.test.mjs:470 — a source-text test listing node:fs, node:http, node:child_process and node:net as forbidden imports.
    3. src/host.js:52 — the existing fetch(endpoint, options) call, which uses relative /api/... URLs served by the local development server.

Known, open, and minor issues:

  1. x=1.\naddonAPI.files.nope() (a number ending in a dot, followed by a line break) is not reported.
  2. The check for the unknown global mosaicAPI is less precise than the main scanner: foo . window.mosaicAPI.x is a false positive and [...window.mosaicAPI] is a false negative.
  3. normalizeSource does not preserve text length (it preserves line count); only one rewrite keeps offsets.
  4. Alias tracking ignores scope: function g(a){ a.files.nope() } can be reported if a was an alias elsewhere.
  5. Homepage validation accepts invisible characters.
  6. handleApiError and the drift verifier's --fetch-upstream --dry-run have edge behaviours that only matter in the Studio development repository.
  7. npm run lint in the add-on directory fails because the directory has no ESLint configuration; this was already the case in a845c47.

This is a summary of the checks and evidence available to me, not a claim that all possible issues have been eliminated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants