The wire contract is merged into docs/design/03-apps-platform.md (§2.1, §2.4, §2.4.1, §2.5, §2.8, §8.2.1). This note
records what changed in the code, what was decided, and what is still open.
Each item is in the code of this package (sd_ipc, the agent) unless marked otherwise.
- sd_ipc:
sd_ipc_broadcast_countreturns the number of recipients queued, filtered by capability and an excluded client.sd_ipc_broadcaststays as a void wrapper. - sd_ipc:
sd_ipc_topic_subscriberscounts hello-completed subscribers of a topic with a capability filter. - sd_ipc:
subscribevalidates topic names ([a-z0-9._-], at most 23 bytes). Invalid names are dropped from the reply; valid unknown names are kept, as before.on_subscribehook insd_ipc_server_cfgruns once per accepted new topic. - sd_ipc: the hello reply carries
featuresfromsd_ipc_server_cfg.features. The client side exposessd_ipc_conn_has_feature.sd_ipc_client_kindreturns the helloclientof a connected client. - sd_ipc: named objects
SD_IPC_OBJ_UI_MUTEX(Local\com.librestatic.shelldrive.ui.<SID>, mutex) andSD_IPC_OBJ_STATE(Local\com.librestatic.shelldrive.state.<SID>, file mapping of 256 KiB). The state section hassd_ipc_state_create/sd_ipc_state_open; both verify the owner and label on the handle and fail closed.sd_ipc_state_openusesFILE_MAP_READ | READ_CONTROL, marked [verify] on XP and 7 (lead decision 2). - sd_ipc: exit code
secret_not_found(3) added to the table.busy(SD_E_BUSY) is exit 8 (03 §6.2, the code thatsd_ipcalready maps; existing replies do not move). Exit 10 isconflict. The earlier note that proposed 10 is resolved. - Prompt routing (agent): initiator, then UI subscribers of
promptwithprompts.ui, excluding the initiator (no duplicate event). Delivery accounting uses the count ofsd_ipc_broadcast_count. With no recipient the agent startsshelldrive-ui.exe --prompt-host(rate-limited to once per 30 s, skipped while the UI mutex is held, a missing executable is not an error) and queues the prompt. - Queue: 16 prompts. The oldest queued prompt is evicted with
prompt.closedreasonsuperseded. A UI that subscribes topromptreceives the queue oldest first, withqueued: trueand the remainingdeadline_ms. - Deadlines: 120 s, or 600 s for a reconnect. A 1 s sweep on the control thread rejects expired prompts with reason
timeoutand fails the mount withprompt_unavailable(exit 4). prompt.closedreasons:answered(withanswered_bycliorui),cancelled,timeout,superseded. The reason is set before the answer reaches sd_mount, so the existing sd_mount callback is unchanged (no change toon_prompt_closed's signature was needed).- Initiator disconnect (lead decision 5): the initiator's prompts are cancelled only when no client with
prompts.uiis subscribed toprompt. Otherwise the mount keeps routing to that UI. - Warnings:
listgains awarningsarray (recent warning codes, at most 32). Themountcopies ofwarningandhostkeys.announcedstay through proto 1 (lead decision 6). - Methods added:
status(withoutstats),config.reload(user scope),log.tail(withoutfollow),selftest,prompt.list.prompt.answernow takes the answering client's kind intoanswered_by. log.tail: a ring of 4096 records (about 4.5 MiB), fed by ansd_logsink. The cursor is"<pid hex>.<boot tick hex>.<seq dec>"withresetanddropped(lead decision 12).- Test hooks (only in
SD_HOST_TEST_HOOKSbuilds):SHELLDRIVE_TEST_PROMPT_MS,SHELLDRIVE_TEST_RECONNECT_PROMPT_MS,SHELLDRIVE_TEST_PROMPT_QUEUE_MAXandSHELLDRIVE_TEST_PROMPT_NO_ROUTE(prompts are queued even when a client could take them, which makes the queue tests deterministic).SHELLDRIVE_TEST_UI_LAUNCH(default 0 in test builds,1enables the launch): the agent starts no prompt UI unless it is set. Every test that runs an agent sets it to0, so a test run never leaves ashelldrive-ui.exebehind. - Features advertised by this build:
status,config.reload,log.tail,selftest,prompt.list,prompt.queued.
- New module
sd_state(src/sd_state): layout v1 codec (encode, copy-then-validate decode), the section writer andsd_state_read_section(8.2.1, 8.8). Depends on sd_base, sd_platform and sd_ipc only, so the shell DLL can link it. - Agent: the snapshot section is created before the pipe accepts clients, published on every mount add, state change
and removal, and emptied with the shutdown flag at exit (
state_producer.c). Warnings do not publish (no field). - Agent: drive icons per user (
HKCU\Software\Classes\Applications\Explorer.exe\Drives\<L>\DefaultIcon), listed instate\explorer.ini; SHChangeNotify on present changes; Network location folders in NetHood withdesktop.ini[ShellDrive] profile=marker andtarget.lnk(explorer_data.c, 8.3, 8.7). Labels are not written here (WebDAV label stays insd_webdav_map). - sd_config: profile key
mount.network_locationis parsed (defaultyes, 3.4.1 table) and written back only when set tonoor already present. The table already listed it; the parser did not read it before. - Floor lists:
GetFileSize,FindFirstFileW,GetPrivateProfileStringWandWritePrivateProfileStringWadded totests/os-imports/xp-sp2-x64.txtandxp-sp3-x86.txt(XP-era APIs the agent now imports; the lists are per-function reviews, so this is the review entry). - Test hooks (SD_HOST_TEST_HOOKS builds only):
SHELLDRIVE_TEST_UI_LAUNCH(0 by default: noshelldrive-ui.exelaunch),SHELLDRIVE_TEST_EXPLORER_KEYandSHELLDRIVE_TEST_NETHOOD(test locations for icons and Network locations).
Implemented in this package and advertised in features: refresh, cache.clear, profile.test, mount.attach_info,
the status details status.stats and status.proxy_legs, and the events config.changed and agent.stopping (03 §2.4,
§2.8). The table rows of 2.4 say what each returns.
- sd_vfs:
sd_vfs_write_behind_bytes(queued write-behind bytes),sd_vfs_cache_clear(v, disk_too)(this mount's memory blocks; the disk tier throughvfs_disk_clear, which skips entries in use). A clear never drops queued write-behind data. - sd_mount:
sd_mount_refresh,sd_mount_cache_clear(m, disk_too, force)(SD_E_BUSYwhile write-behind data is queued, unless forced),sd_mount_get_stats(session, vfs, pool members, write-behind bytes),sd_mount_get_attach(backend, drive, WebDAV loopback port),sd_mount_stop_ex(m, force)(a forced stop gives the write-behind drain no budget: what is queued is reported aswrite_failed), andsd_mount_get_probefor thetest_onlymount ofsd_mount_params.profile.testis thetest_onlymount: connect, authenticate, realpath ofremote_path(session_probe), then UNMOUNTED with a probe. No vfs, no drive.sd_mount_backendhas seven new pointers at the end (NULL-tolerant). Stats and cache calls count themselves inm->readers; the control thread drains them before it frees the session or the vfs (no backend call runs underm->lock). - sd_mount: the proxy hops of the chain are copied by the host before
sd_mount_create(host_leg), sostatusreports them without the hops being kept. - sd_ipc:
sd_ipc_defer(client, &id)inside a handler makes the pipe thread send no reply;sd_ipc_reply_deferredsends it later from any thread (profile.testruns for seconds, prompts included).sd_ipc_broadcast_allsends an event to every client that completed hello (config.changed,agent.stopping); the topic*is not a valid topic name, so no subscription matches it. - sd_ipc, TM-R26 (lead decision):
ipc_verify_object_ownerfails closed on Vista+ when the label cannot be read; there is no owner-only fallback. XP keeps the owner check alone. The decision isipc_owner_decision(exposed assd_ipc_test_owner_decisionfor the unit test). - Exit codes:
not_mounted(3) andwrite_behind_pending(8, busy). Clients that do not know these codes exit 1 (the table of 6.2 needs the two rows; the CLI mapping and its localized texts are the CLI package's job, see below). - Agent:
unmount {force}applies to the first unmount of a mount (a second request does not re-stop it). Test mounts are not inlist,status,unmount, the snapshot, Explorer data ormount.state; their warnings still go towarning. config.changed(apps/shelldrive-host/config_watch.c): one thread, two overlappedReadDirectoryChangesWwatches (the config root forsettings.iniand the creation of the profiles folder, the profiles folder for*.ini), one stop event, 500 ms debounce, XP-compatible (no post-XP import).idsare read from the changed files withsd_profile_load_file; a removed profile is not named. Nothing is reloaded in flight.agent.stopping {reason}:request(agent.shutdown),event(the shutdown event) oridle. It goes out at the start of the shutdown sequence, after the watch stops; the agent then waits 100 ms so the pipe thread writes it (there is no flush call in sd_ipc).status {stats: true}returnsstats.session(srtt, rates, byte totals, inflight, queued, channels, generation, reconnect attempts),stats.pool(ready,wanted,members[]per SFTP connection),stats.cache(vfs hits, misses, bytes, write_failed, write_behind_bytes, reconnects). The counters are per mount; the process-wide memory tier is not included.
Not implemented in this package, and not advertised in features:
diag.collect: M4 (10.5). Not started: the anonymization rules (10.5) and the bundle layout need the lead's review first.log.tail {follow}and thelogtopic: M4 (2.4.1).follow: truestaysunsupported.mount.attach_infoWebDAV port is read from the fake in the tests; the realsd_webdav_mount_portpath is not exercised by the harness (lab: a WebDAV mount with the WebClient service).- Service side of
refresh,cache.clear,profile.test,mount.attach_infoandstatus stats: M5 (the service mutating methods need the elevated admin check; the non-admin list rules of 2.2 apply to them). - CLI: done in the M3 profile-keys package (see the section "M3 profile keys, CLI and autostart" below).
update.check/update.apply: M4 (decision 10).secret.set/secret.delete: M5 (decision 4).- Session lock state is not probed before a UI launch (the UI would start while locked and wait for a subscription).
config.reloadreturnsrestart_required: []; the restart-required keys are not computed yet (decision 9 lists them).- Service side of prompts (
prompt.answerfor the service,prompt.listfor admins) andhostkey.announced.liston the service: M5.
-
tests/unit/sd_ipc:test_ipc_m3.ccovers topic validation and the subscribe reply,featuresin hello, theon_subscribehook, broadcast counts with capability filter and exclusion, per-topic subscriber counts, the new object names and the state section create/open with owner checks. -
tests/apps:test_agent_m3.cruns the agent over the real pipe, against the scripted fake backend: UI-only prompts (one copy each, answered by the UI), prompt deadline (injected to 1.5 s), queue eviction and drain on subscribe, the initiator-disconnect rule (both branches), and the new methods (selftest, status, config.reload, log.tail cursors, list warnings, prompt.list, hello features). -
tests/unit/sd_state: round trip, truncation (cut and surrogate-safe), the seqlock reader under a live writer thread (never a torn snapshot), a stuck odd seq, every corrupt header field, bad entries dropped, layout skew (v1 reader and v2 writer), unknown layouts, the section round trip and a squatted low-integrity section (Vista+; no XP label). A foreign-owner squat needs an administrator and is not tested. -
tests/apps:m3_snapshot_and_icon_follow_mount(section entry and drive icon while mounted, both gone after unmount) andm3_network_location_entries_at_start(the profile's folder with the marker,target.lnkand the placeholder; a stale marked folder removed; an unmarked folder kept). All registry and NetHood writes go to test locations (see 8.8); test builds never startshelldrive-ui.exeunlessSHELLDRIVE_TEST_UI_LAUNCH=1.target.lnkcontents and the icon on real Explorer are not checked (lab). -
The CLI is unchanged. Its replies gained only additive fields (
queued,deadline_msonprompt.request,warningsonlist,featureson hello), which the CLI ignores. -
M3 agent methods (WP-A part 3):
tests/apps/test_agent_m3.c(m3_profile_test_results_and_errors,m3_config_changed_and_agent_stopping,m3_refresh_cache_attach_and_status_stats,m3_cache_clear_refuses_queued_writes; the agent runs against the fake backend,SHELLDRIVE_TEST_UI_LAUNCHstays 0),tests/unit/sd_mount/test_mount.c(mount_m3_*), andtests/unit/sd_ipc(ipc_deferred_reply_roundtrip,m3_owner_label_fails_closed).
Code: apps/shelldrive-shellext/ (COM server, reader, registration), tests: tests/shellext/. Strings: l10n/shell/*.po.
- Classic context menu handler (
IShellExtInit+IContextMenu, noIContextMenu3, no icons) for drive roots (X:\) that are ShellDrive mounts in the snapshot. One selected drive root only; any other selection gets no items. - Items: Open in ShellDrive (every entry), Unmount (per-user entries not unmounting or unmounted), Reconnect
(per-user entries offline, auth required or failed). Global entries (
GLOBALflag) get Open only (8.2.1). GetCommandString:GCS_VERBA/W(machine namesshelldrive.open|unmount|reconnect),GCS_HELPTEXTA/W(catalogshell.help.*),GCS_VALIDATEA/W. TheGCS_*constants are compared in their ANSI form: withUNICODEdefined the SDK mapsGCS_VERBtoGCS_VERBW, so comparing againstGCS_VERBsilently matches nothing.InvokeCommandaccepts a resource offset (MAKEINTRESOURCE) or an ANSI verb string naming one of our items (case insensitive). It starts"<dll dir>\shelldrive-ui.exe" --action <open|unmount|reconnect> <X:>withCreateProcessW, closes the handles and returns. It never waits and never calls the network or the IPC pipe.- Registration (
DllRegisterServer/DllUnregisterServer), per user only, under HKCU:Software\Classes\CLSID\{clsid}(+InprocServer32,ThreadingModel = Apartment),Software\Classes\Drive\shellex\ContextMenuHandlers\ShellDrive, and theShell Extensions\Approvedvalue. Unregister deletes the leaves; shared parents are deleted only when empty. - Exports:
DllGetClassObject,DllCanUnloadNow(object and lock counts, interlocked),DllRegisterServer,DllUnregisterServer(shelldrive-shellext.def).DllMainonly stores the module handle and disables thread calls. - Built with
sd_add_dll(version resource, import audit, ISA audit). Built and tested on x64-modern, x64-xp (Debug), x86-ia32 (Release) and x64-analysis: zero warnings,ctest -R "shellext|l10n|importcheck"green everywhere.
- Thin reader of the section layout v1 (03 §8.2.1), written so the lead can replace it with
sd_state: the rest of the DLL only seesshx_entryand the count. - Production open:
sd_ipc_state_open(fixed name, owner and label checked there, fail closed). - Seqlock: up to three tries of {read seq (odd = retry), copy the header and
total_sizebytes into a heap buffer, read seq again (changed = retry)}. Everything after the copy works on the copy only, so a concurrent writer can never change what is parsed. Three failures, a bad header, or a stable bad header are all "no data" (0 entries). - Validation as in 8.2.1: magic, layout 1 or 2,
header_size >= 64and not pasttotal_size,total_sizeat most 256 KiB and equal toheader_size + entry_count * entry_size,entry_sizein [1792, 4096] and a multiple of 8,entry_count <= 128. Per entry: IN_USE set, no bits above 6, letterA..Zor 0, well-formed UTF-16 in every string slot (no unpaired surrogate),profile_idempty or 32 hex digits. A bad entry is dropped; unknownstateandbackendvalues read as 0. - Not done in the reader: bidi and zero-width stripping (no string is displayed by the menu yet),
NEEDS_ADMINhandling.
SHELLDRIVE_TEST_STATE_NAME: section name to open instead of the state section. The test variant applies the same owner and label checks itself (GetSecurityInfoon the handle, mandatory label at least medium).SHELLDRIVE_TEST_SHELLEXT_CMDLINE_FILE: when set,InvokeCommandwrites the UTF-16 command line to this file instead of startingshelldrive-ui.exe.sd-test-shellext-dllis the same source built with the define (shelldrive-shellext-test.dll);sd-test-shellextcompiles the reader too and loads that DLL from its own directory.
- Reader: valid entries and capacity, bad entries dropped one by one, bad headers (nine variants), odd seq (no data), missing section, low mandatory label refused, 400 randomly corrupted images (bounded result, no fault).
- COM through the DLL: exports, class factory arguments, items for a mounted drive (ids and texts), failed drive (three
items,
GetCommandStringin all forms,E_INVALIDARGout of range), global drive (Open only), other selections andCMF_DEFAULTONLY(no items), corrupt snapshot (no items),InvokeCommandcommand lines (resource offset and string verb; unknown verb and out of range launch nothing), unload and lock counting. - Registration:
RegOverridePredefKeyredirects HKCU to a temporary key for the test; the real HKCU keys are checked for unchanged existence before and after, the temporary tree is removed.
- The menu shows only what the snapshot says. Reading the section is the only input; nothing is read from the pipe, the network or profile files, so the 8.2 "never touches the network" rule holds by construction.
- Explorer-facing code runs under
__tryonly in the snapshot read (sx_fault_filtercatches access violation and in-page error, nothing else). COM entry points are plain code. - Language:
sd_l10n_init(catalog, NULL)once per process, on firstInitialize(policyUILanguage, then the Windows UI language). A second thread waits up to one second for the first to finish. Thesettings.inilanguage is not read here. - Global vtables and the factory are static and writable (the SDK declares
lpVtblnon-const); the factory has no reference count of its own. - Verb strings for
--actionare the names the UI grammar uses; GCS verb names areshelldrive.*ASCII identifiers.
- UI grammar: resolved:
ui_wire.caccepts--action open <X:>(the profile editor package) and opens the drive in Explorer. - Not implemented from 8.2: Copy remote path (drive, directory,
*); the Directory,*and This PC registrations; "Mount with ShellDrive" under This PC (needsmenu.cache); menu icons (hbmpItem, Vista+). .sdmountverb: the Mount item for.sdmountfiles is the staticHKCR\LibreStatic.ShellDrive.Mountverb of 8.1, not a handler item; no code here (the doc does not list.sdmountamong the handler registrations).- 8.6 (IExplorerCommand): not implemented, as instructed.
- Architectures (8.5): registration writes the native view of HKCU only. An x86 DLL on x64 needs the same registration
in the 32-bit view (
KEY_WOW64_32KEY/Software\Classes\Wow6432Node); the x86 DLL is built and tested but not registered by these functions on WOW64. - Approved list: written under HKCU, which is the per-user place. Whether Explorer honours the per-user list under
EnforceShellExtensionSecurityis [verify on Windows 10 and 11]; the installer writes the HKLM list (04). - Import floors:
DisableThreadLibraryCalls,ReleaseStgMedium,DragQueryFileWandInsertMenuItemWappended totests/os-imports/xp-sp2-x64.txtandxp-sp3-x86.txt(documentation only, pending the XP lab capture, 04 §11.4). The win10 list is whole-DLL and needed no change. - Label check in production (TM-R26): the production open is
sd_ipc_state_open. Itsipc_verify_object_ownerchecks the label only on Vista and later, and whenGetSecurityInforefuses the label it falls back to the owner alone. The test path applies the stricter rule (label must be absent or at least medium, no fallback). Lead to decide whethersd_ipcshould fail closed when the label cannot be read. - Error UI: a failed launch returns
E_FAILto Explorer and shows nothing; the UI's own error path is not reached. - Lab: not run in Explorer. The behaviour inside a real Explorer (menu placement on Windows 11, the classic submenu, drive roots only) is untested here and belongs to TST-24.
- Registry: nothing was registered in the real registry and Explorer was not restarted; only the redirected test registration ran.
Contract changes made in this package. Spec corrections are in 03 §3.4.1 and the changelog at its end.
Profile keys (src/sd_config/profile_m3.c, fields in sd_profile, parsed and validated; round trip writes a key only
when it differs from its default or is already present; legacy cache.metadata_ttl, directory_ttl,
read_cache_disk are read once and removed on save, read_cache_memory is ignored with a log line):
- Applied, with the consumer named:
security.trustandmount.shell_active_files:block_shell_active=shell_active_filesor the D41 default from trust.mount.hide_dotfiles,mount.show_special,mount.map_readonly,mount.case,mount.remote_case,mount.umask,mount.fsync_on_flush,mount.fs_name(Dokany):sd_vfs_optionsthroughsd_mount_params.tuning.cache.attr_ttl,cache.dir_ttl,cache.neg_ttl,cache.open_revalidate,cache.max_readahead:sd_vfs_options.mount.identity_probe = exec:SD_SFTP_OPT_IDENTITY_EXECin the sftp options (sd_mount).mount.autostart = logonandmount.autostart_sessions: the agent starts the mount at its start (work_autostart, no client, prompts off, no open).bootis logged and left to the service (M5).mount.open_after_mountand theopenrequest ofmount --open: the agent postswork_openat the first MOUNTED of a user-initiated mount (never on a reconnect or a logon mount);ShellExecuteW(..., "explore", "X:\"). Test builds never open a window: they append the drive root to the file named bySHELLDRIVE_TEST_OPEN_FILE.
- Parsed only (no consumer, or the consumer refuses the value today):
mount.exec_hint,mount.atomic_put,mount.strict_acl: no reader in sd_vfs or sd_webdav.mount.remote_charset:sd_vfsrefuses a non-zero code page (SD_VFS_E_UNSUPPORTED), so UTF-8 is used.mount.mark_of_the_web:sd_vfsrefuses it until a later milestone (SD_VFS_E_UNSUPPORTED). 02 §1.1 and TST-21 apply.mount.offline_hint_over_mb: no reader (sd_webdavdoes not read the field yet).security.crypto_backend:sd_ssh_algo_cfg.crypto_backendexists but nothing reads it; the mount does not set it.
- M5, parsed and validated only:
profile.scope(user | users | service),profile.service_access,profile.service_access_write(a subset ofservice_access, by name or SID string, ASCII case-insensitive; names are not resolved here),mount.allow_system(the vfs option stays FALSE in this build, as before). - Validation:
scope = serviceneedsservice_access;autostart = bootneedsscope = service. Bounds: TTLs 1 ms to 1 h,open_revalidate1 ms to 1 h ornever,max_readahead64 KiB to 1 GiB,umask001 to 777 (octal),offline_hint_over_mbup to 1048576. Zero is refused where the vfs would read it as its default. - Behaviour change:
hide_dotfiles,map_readonlyandfsync_on_flushdefault to yes, so the mounts now hide dot files and map read-only bits by default (the agent passed FALSE before).
Agent and IPC:
refresh,cache.clear,profile.test,status {stats}andmount {open}are the existing methods; this package adds theopenboolean tomount(ignored byprofile.test). Nothing new was added tofeatures.not_mounted(exit 3) andwrite_behind_pending(exit 8) are insd_ipc_exit_code_for_codesince M3 and now have CLI texts.
CLI (apps/shelldrive, new file cli_cmds3.c):
refresh <X:|X:\path>:refreshIPC; drive letters only (folder targets need Dokany folder mounts).cache clear [<profile>|X:|m-N] | --all [--force]:cache.clear. Without an agent,--allreports 0 and a named target ismount_not_found.profile test <profile>:profile.teston a worker thread; the main thread answersprompt.requestevents of the connection (the samehandle_promptas mount). Result lines are localized;--jsonprints the reply.status --statsand thestats <X:>alias:list, thenstatus {mount_id, stats: true}per matching mount.- Exit codes:
not_mounted(3) andwrite_behind_pending(8) have localized texts. Spec 6.2 lists both. - New strings (19 msgctxt ids, all six locales,
cli.*): seel10n/cli/en.po(theM3block). sdl10n: Spanish, French, Italian and Portuguese plurals have three forms, German and English two (the checker's rule).
Tests:
tests/unit/sd_config/test_config_m3.c: defaults, every M3 key's values and bounds (49 cases), umask octal, the derived shell-active default, legacy names, round trip.tests/apps/test_cli_m3.c(cli_parse_m3_commands): refresh, cache clear, profile test, status --stats, the stats alias, mount --open, and the option limits per command.tests/apps/test_agent_m3.c(m3_autostart_and_open_after_mount): the logon autostart and the session check (read from the agent log throughlog.tail), no autostart forautostart = no, and one open of the drive root after the first MOUNTED of a user mount. No Explorer window is started.
Open items:
- The lab check of
open_after_mounton a real Explorer and ofShellExecuteWon XP (TST, not run here). profile testprompts: exercised only through the agent test harness, not with the real console prompt.