Skip to content

Issue #1772: plug-in host — large files, folder/host/secret settings, secrets - #1858

Merged
emmertex merged 8 commits into
stagingfrom
plugin-host/step1-files
Dec 3, 2026
Merged

emmertex merged 8 commits into
stagingfrom
plugin-host/step1-files

Conversation

@emmertex

@emmertex emmertex commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1772
Part of #1771

Problem

Plug-ins can't handle real photo files: reads and writes are capped at 8 MiB per call with no copy, stat, mkdir or rename; roots and hosts are fixed in the manifest, so a plug-in can't work in a folder the user picks; there is nowhere safe to keep a password or token.

Change

  • fsFiles: fs.stat, fs.mkdir, fs.rename, fs.freeSpace, ranged fs.read, chunked atomic fs.writeBegin/Chunk/End, and fs.copy — a host-side verified copy with no size cap (copy + hash check through io_sched, never overwrites unless asked, link swaps refused). SDK wrappers, including the existing fs.list.
  • Lending split into read-only and read/write; beforeImport now lends the file read-only, as the docs always said.
  • folderSettings: setting kinds folder {write} and host; the user's choice becomes a granted root/host, shown on the Permissions tab with Revoke. The folder picker answers only with a one-time token, so a control-channel caller can't grant a path.
  • secrets: secrets.get/set/delete in the OS credential store under plugin:<id>; never in settings/<id>.json, never shown, left out of settings.get, redacted from the plug-in log; deleted on uninstall (also when the store was locked then).
  • Long calls: time inside a job's fs.copy doesn't count against the 120 s limit; it honours cancel and reports bytes.
  • SDK example sdk/examples/archive-tools.

Not in this PR: With keepData: true on uninstall, secrets stay but the pinned author key is dropped (same as kept data today). On Windows open_checked compares canonical paths, not file ids.

How it was checked

  • cargo xtask ci --quick on this branch, up to date with staging (merged in, not rebased): fmt, brand, docs,
    notes, i18n, windows, clippy, heif, stamp, parity, layers, assets and the wasm check pass. The test step
    fails on three lcc-ui-egui tests that are not touched by this stack and fail the same way on step 1 after
    merging staging:
    tests_pixel_shift::a_cancelled_pixel_shift_merge_leaves_no_file_and_no_photo (a sourceColour
    "Reading source colours" activity row from staging's own colour work is still open when the test looks),
    tests_pixel_shift::a_series_of_another_mode_is_refused_by_name_and_never_merged_as_16_shots, and
    tests_chart_profile::the_dialog_reads_the_chart_photo_and_suggests_a_name (passes when run alone).
    Every lcc-plugins test passes, and the full lcc-engine lib suite passes (3097 tests on step 2).
  • Tests that fail without the change, including hostile-input cases in crates/plugins/tests/{abi,robust}.rs
    for every new call (bad paths, huge lengths, bad handles, NaN/negative numbers).
  • App smoke over the control channel (Windows, debug build, scratch config and library) with the two first
    consumers installed: chromaforge-archive-copy and
    chromaforge-convert-on-import. Archive copy,
    hash mismatch, unwritable archive, retry, DNG conversion (built-in and an external stand-in), sidecars kept,
    fallback to the original and scratch clean-up all checked. Folder choices and grants were written into the
    scratch config (they can only be made by the user, by design), so the Choose…/Allow clicks were not driven.
  • Not run here: the #[cfg(unix)] link-swap and odd-name tests (Windows machine); the first unix CI run covers them.

Each step went through three independent reviews (crash safety, security/permissions, completeness against the
plan); every finding was fixed or answered.

Merging

Checklist

  • No new panic path in non-test code
  • New text on screen goes through tr() and has its key in every locale
  • LRC-SHELL-PLUGINS row and gap 19 updated in the same commits
  • Manual updated in the same commits (pages: automate/plugins.mdx, platforms/settings-and-privacy.md)
  • New code has a caller (SDK example + tests; the two plug-ins above)
  • No new assets

🤖 Generated with Claude Code

emmertex and others added 8 commits December 1, 2026 23:51
…me, chunked writes, fs.copy)

Plug-ins that list "fsFiles" in `requires` get fs.stat, fs.read {path,
offset, length} (8 MiB a call), fs.freeSpace, fs.mkdir, fs.rename and
chunked atomic writes (fs.writeBegin / fs.writeChunk / fs.writeEnd: temp
file beside the target, synced and renamed at the end; open writes are
dropped with their temp files when the call ends). fs.copy {from, to,
expectHash?, overwrite} is a host-side verified copy with no size cap:
import_move::copy_verified (now with a watched variant counting bytes and
honouring a cancel flag) run as an io_sched job, never overwriting unless
asked. Time inside fs.copy is paused against the 120 s wall budget; in a
job it reports bytes to the activity row and stops on cancel.

Lent files are split into read/write and read-only lists; the
beforeImport hook now lends its file read-only (as the docs said).

SDK wrappers: host::list, stat, read, free_space, mkdir, rename,
write_begin/write_chunk/write_end, write_large, copy. Hostile-input
tests in tests/abi.rs and a fuzz case in tests/robust.rs.

Manual: none (docs/plugins.md updated; manual page, example, notes in the
step's docs pass)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Host features folderSettings and secrets. Manifest settings gain three
types, for settings only, never prepared, with no default and set only by
the user on the plug-in's Settings tab:

- folder {write?}: the chosen folder is granted as an fs root while chosen
  (stored as {path, write}; write no more than the field asks for now),
  checked like a manifest root (absolute, no "..", never a folder holding
  the app's settings or plug-ins); settings.get gives its path.
- host: the chosen host (a plain DNS name) is granted as a network host.
- secret: kept in the session's secret store under
  Key("plugin:<id>", key), never in settings/<id>.json, never shown, left
  out of settings.get; plugin.settings says only whether one is stored.

Chosen folders and hosts are listed with the plug-in's requests
(setting: <key>) and on the Permissions tab ("chosen in Settings",
Revoke clears the choice; plugin.revoke does too). settings.set and
plugin.setSettings may only clear them and refuse secrets; the control
channel's clicks on the new buttons change nothing.

New permission group secrets and host calls secrets.get / secrets.set /
secrets.delete (the plug-in's own secrets only; 16 KiB cap; set/delete
are writes), served by SessionHost, relayed from workers (Relayed::Secret,
not tied to the open library), jobs and program.end hooks. A locked or
missing store fails with what to do. Every secret value a plug-in read,
kept or had typed for it is redacted as [secret] in its log and call
errors for the session. Removing a plug-in with its data deletes its
secret settings' secrets.

UI: Settings tab rows for the three types (Choose.../Clear, Allow/Clear,
a password field with Save/Remove), localized in every language. SDK:
host::secret, secret_set, secret_delete, chosen_folder, chosen_host.
Docs: docs/plugins.md (Folder, host and secret settings; Secrets;
permission and SDK tables; feature names). Tests: abi (secrets, redaction,
grant, hostile requests, chosen folder grants, hostile choices, manifest
checks), compat (features, secrets group), robust (fuzzed secrets and
settings calls), engine (session store, relay, uninstall), ui (drawing).

Manual: none (docs/plugins.md updated; manual page, example, notes in the
step's docs pass)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tings and secrets

- docs/plugins.md: the copy hash is photo.inspect's `content_hash`; Engine commands
  say how plugin.settings / setSettings / revoke / uninstall treat the new setting
  kinds and secrets; the Permissions tab lists chosen folders and hosts; the
  settings file never holds a secret; "Not done yet" no longer claims hosts are
  fixed in the manifest, notes that a secret kept under the plug-in's own name
  outlives removal and that a job's fs.copy stops at once; ten examples.
- New SDK example sdk/examples/archive-tools (fsFiles, folderSettings, secrets):
  Copy to Archive (free space, mkdir, stat, verified fs.copy against the photo's
  hash, rename, chunked writes), Verify Archive (ranged reads), Server Status /
  Forget Session (chosen host, secrets get/set/delete, log redaction); driven
  end to end in crates/plugins/tests/example.rs.
- permissions.rs: every fsFiles call and secrets.* fail ungranted and work once
  allowed; a chunked write not ended is dropped.
- What's New and changelog entries; parity row LRC-SHELL-PLUGINS, gap 19,
  ROADMAP log and target-app-parity line updated (status unchanged).

Manual: automate/plugins, platforms/settings-and-privacy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- fs.copy opens its source with open_checked and copies and verifies from
  that open file; the file it creates (or the temp file renamed over the
  target) must be in the target's own folder before any write and again
  before the rename, so a link swapped in after the check never reads,
  creates or replaces anything outside the roots (no after-the-fact
  remove_file any more).
- fs.copy's time is outside the wall budget only in a job; outside a job
  the copy stops when the call's deadline passes (CallContext::deadline).
- Secrets: the names a plug-in sets are listed in the store under a name no
  plug-in can use; uninstall (by id or file) deletes all of them; a locked
  store keeps a pending list, wiped before the id's next store use.
- Host settings are stored as {host}, so a value kept for a setting of
  another kind is never taken for the user's choice.
- plugins.chooseFolder takes a path only with the random token given to the
  picker it opened; the folder row and picker title say what is granted.
- group_label names secrets and libraryRemove, unknown groups by name.
- Parity change table back in date order.

Manual: automate/plugins

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The row added by #1732 (merged from staging) was painted in English in every
language; the i18n sweep failed after merging staging.

Manual: none, no user-visible change beyond the translation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Plug-in host step 1: fs calls, folder/host/secret settings, secrets, long calls

1 participant