Repository navigation
Conversation
|
评审(head
|
|
已按评审修改,head
两个检查通过。 |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Scope: this PR adds four target contracts for the session storage owners (SessionStore, SessionFiles, ManagedWorktrees, SqliteStorage) under design rules section 7, refs #2018 and #2015. I checked the claims against the current storage code and against resource-faces, service-faces, resource-owner-operations, session-files, Attachments, SessionTitle, ADR 002 and ADR 013, and against section 7 of the principles text in PR #2029.
Verdict: REQUEST_CHANGES. The four docs agree with each other on most of the owner split, but several P2 contract defects remain: a creation and removal race in the stated order, error tables that contradict their own flows, SessionFiles read and import shapes that break the existing Attachments contract, a register check the owner cannot perform, unreconciled conflicts with the existing store, timelineStore, sqliteStorage and title contracts, and a binding appendix that would not produce the documented codes or compile.
Findings
P2: create validates the workspace before taking the exclusion
- Problem: SessionStore.md:147 gives the order "Validate the id and the workspace, take the exclusion". The exclusion invariant at line 16 and the verification at line 169 require the workspace check inside the exclusion. The current code takes
ownershipfirst (crates/dim-app-server/src/storage/timeline.rs:1628) and checksconfig.cwdnext (1629-1636). - Failure scenario: create checks a cwd under a worktree root; removeWorktree holds the exclusion, removes the root and deletes the directory record; create takes the exclusion, inserts the directory record and the association, and commits a Session whose cwd is gone. The verification "either sees the surviving directory or fails on the missing workspace" does not hold.
- Fix: state "validate the id, take the exclusion, validate the workspace, write ..." and keep the code order.
P2: SessionStore error lists omit closed and delete omits invalid
- Problem: the flows say new
createandremoveWorktreecalls are refusedclosed(147, 154) and pending reads endclosed(150), but those operations do not listclosed(107, 120, 126).deletelists onlystorage(108), while the errors table definesinvalidfor "an id that is not one path component" (134), anddelete_sessionrejects such ids (timeline.rs:1551-1554; resource-faces.md:754-755). - Failure scenario: a caller uses a closing generation for
title, getsstorage, and retries the same generation; a caller sends an id with a slash todelete, getsstorage, and retries instead of fixing it. - Fix: add
closedwherever the flow names it, and addinvalidtodelete.
P2: SessionFiles read removes offset paging and claims every caller needs the whole file
- Problem: SessionFiles.md:71 and 77 make
readwhole-file, and line 110 says "every caller needs the whole file". The current contract returns at most 64 KiB per call with an offset (docs/design/appserver/session-files.md:419; crates/dim-app-server/src/storage/files.rs:619-620). Attachments A.1 definesattachment.read {sessionId,fileId,offset}returning{data,eof}at most 64 KiB (docs/design/plugins/Attachments.md:148-149; crates/dim-agent-attachments/src/lib.rs:169-178). The web download streams by offset (crates/dim-app-server/src/web_entry/uploads.rs:234,257), and image materialization pages by offset (crates/dim-agent-capabilities/src/session_files.rs:23-41). - Failure scenario:
attachment.readand the HTTP download either stop compiling or must load a 16 MiB file (about 21 MiB base64) for each 64 KiB request. The stated reason, "a page protocol would push the read id's lifetime to callers", is not true of the existing stateless offset read. - Fix: keep
offsetand the 64 KiB chunk, or update Attachments and the web API and state the memory bound. Line 77 also calls a file id outside the Sessioninvalid, while line 121 and the current read returnnot_found; pick one.
P2: SessionFiles import reply drops path
- Problem: SessionFiles.md:69 returns
{fileId, size}whileputandwritereturn{fileId, path, size}(68, 70). Attachments A.1 usessessionFiles.importand returns{attachmentId, path, bytes, image}(Attachments.md:143-145; dim-agent-attachments/src/lib.rs:203-223). The current contract returns{fileId, path, bytes}(session-files.md:419). - Failure scenario: Attachments cannot produce the path for a text import or for
attachment.import; the caller would have to reconstruct the owner's private<db>.session-files/<fileId>/<name>path, which the contract does not expose. - Fix: return
{fileId, path, size}fromimport; alignsizeandbyteswith Attachments and session-files or update those contracts.
P2: SessionFiles register requires a check the owner cannot perform
- Problem: SessionFiles.md:23 leaves the output directory with WorkspaceTools, but line 31 requires the owner to keep a registered path "inside the Session's output directory", and line 83 makes a path outside it
invalid. The current contract has the caller check its own root (crates/dim-agent-capabilities/src/host.rs:1526-1527), and ADR 013 D2 has two roots, one owned by HostPlatform (docs/adr/013-command-output-ownership.md:36-39). - Failure scenario: WorkspaceTools registers
command-output/<session>/...and ShellSession registers.dim/exec/<session>/<branch>/...; the owner cannot validate the second without depending on HostPlatform and the branch, so either shell registration fails or the owner takes another owner's path policy. - Fix: leave the root check with the caller as today, or name the owner that supplies both roots and raise the requirement there.
P2: the new store, timelineStore and sqliteStorage boundaries contradict the existing contracts
- Problem: SessionStore.md:195 and 209 mark the service on
SessionStoreand deleteStore, while resource-faces.md:795-798 says the RustStorebinding is the public type and "SessionStore remains the native bootstrap/implementation owner, not the publicstoretype". SessionStore.md:205 and SqliteStorage.md:130 removecreateSession,releaseSession,rollbackSessionandappendfromtimelineStore, while resource-faces.md:616 and service-faces.md:129 keep them there and resource-faces.md:619-630 definesappendas the sync face operation. SqliteStorage.md:18, 32 and 90 make the Settings, Provider, Agent and Timeline transactions crate-private, while resource-owner-operations.md:41, 47, 57 and 59 and service-faces.md:128 say those owners call the publicsqliteStorageface. SessionStore.md:99 also sayssqliteStorageis not a service face, while SqliteStorage.md:119 and 160-169 mark it as one. - Failure scenario: an implementer following resource-faces keeps
appendon the Session face or keeps the engine's proxy operations; the catalog and the callers cannot satisfy both targets. - Fix: update resource-faces, service-faces and resource-owner-operations in this series, or add explicit requirements for their owners and state which rows these docs supersede.
P2: the setTitle appendix cannot keep the dropped-reply guarantee
- Problem: SessionStore.md:121, 153 and 172 say a dropped reply still commits and announces, but the appendix declares
pub async fn set_title(SessionStore.md:351-359). Anasync fnfuture runs only on first poll, so dropping it before polling never admits the write. The currentset_titleis a plain function that admits the write and spawns it before returning the wait future (crates/dim-app-server/src/storage/metadata.rs:201-224 and 342-350). - Failure scenario: a Rust caller creates the future and drops it; the write never commits, and the flow test "a dropped reply still commits and announces" fails.
- Fix: keep the binding a plain
fnthat admits and returnsimpl Future, or state that a drop before the first poll does not admit the write and change the flow.
P2: the binding error types do not produce the documented codes and the callbacks do not compile
- Problem: the appendices declare the error enums with
#[derive(Debug, thiserror::Error)]only (SessionStore.md:299, SessionFiles.md:179, ManagedWorktrees.md:185, SqliteStorage.md:148). Under#[rutis::service], rutis 0.23 derives the wire code from serde when the error isSerialize, otherwise from theDebugvariant; these types have noSerialize, soStoreError::WorkspaceMissingbecomesWorkspaceMissing, notworkspace_missing, andStoreError::Rejected { code, message }becomesRejected, not the caller's code. The documented codes are snake_case andrejectedmust carry the callback's code (SessionStore.md:132-141). The callback aliasesTextFn,ChangeFnandRemoveFnreturnRejected(SessionStore.md:246-282), but rutis 0.23FromFunctionrequires the callback error to implementFrom<rutis::host::CallError>;Rejecteddoes not, so the#[rutis::service]methods with those parameters fail to compile. - Failure scenario: a foreign caller matches
workspace_missingor the callback'srejectedcode and seesWorkspaceMissingorRejected; the Rust binding cannot be built. - Fix: serialize the errors with the documented representation or provide a custom
__rutis_failthat emits the code, including the innerRejectedcode; addimpl From<rutis::host::CallError> for Rejected.
P2: SessionFiles remove says an unowned file succeeds but also returns not_found
- Problem: SessionFiles.md:72 says "a file the Session does not own answers success" and line 120 verifies that; line 85 defines
not_foundas "The Session has no such file". The two rules cannot both hold. - Failure scenario: an idempotent delete of a foreign or already removed file either fails or succeeds depending on the implementation; the caller cannot decide whether to retry.
- Fix: drop
not_foundfromremoveor define it only for a missing Session and state the foreign-file result explicitly.
P2: the title change callback supersedes SessionTitle's expected-revision contract without a requirement
- Problem: SessionStore.md:121, 153 and 160 replace the revision-checked write with a change callback and remove
conflict; SessionTitle.md:384, 414 and 428-449 and session-title-metadata.md:22, 92 and 104 still define{sessionId, expectedRevision, title}withconflict, and resource-faces.md:793 and resource-owner-operations.md:57 still routereadMetadataandsetTitlewith revisions. No requirement in the four docs covers the caller. - Failure scenario: SessionTitle's "manual title always wins" rule and its retry path have no target; the caller cannot migrate without a second title contract.
- Fix: add the SessionTitle and title-metadata migration to the requirements or state how the callback replaces the conflict rule, and update those docs in the series.
P3: cancellation arguments contradict the tables
- ManagedWorktrees.md:71 says
discardis "Not cancellable", but the appendix takesCancelledFn(224) and the caller example passesCancellationToken::new()(45). SessionFiles.md:275 says "only the operations that wait takeCancelledFn", but the appendix gives it toremove,registerandowned_paths(237-271), whose table entries say None (72-75), and the register example passes a token (43). Fix: remove the argument or state what it stops, and use one token type in the examples.
P3: binding appendices use undefined request and reply types
- SessionStore.md uses
Create,DeleteReply,Fork,SetTitleandTitleReplywithout defining them; SessionFiles.md usesPut,Import,WriteFile,ReadFile,RemoveFile,Register,Owns,Owned,OfSessionandPaths; ManagedWorktrees.md usesRemoved, which is defined only in SessionStore.md; SqliteStorage.md usesEmpty. Fix: define the types or point to the shared types, as the template requires.
P3: broken relative link
- SessionFiles.md:62 links
FileStorage.md, which is absent from docs/design/plugins in this tree; the file is added by PR #2080. The link resolves only if #2080 merges first. Use the PR URL, as line 153 does, or add the file before merging.
P3: SessionFiles write and remove name no caller and contradict the current file contract
- SessionFiles.md:29 and 33 add operations whose requirement rows name no caller; session-files.md:443 says "SessionStore offers no operation that changes, renames or removes one file". The delivery comment names MCP for
write,readandremove, but the design doc does not. Fix: name the caller in the rows and update session-files.md, or drop the operations.
P3: SqliteStorage restore does not take the lease it claims
- SqliteStorage.md:15, 82 and 88 say backup, restore and vacuum take the same lease;
restore_storetakes no lease and requires a non-existent destination (crates/dim-app-server/src/storage/backup.rs:135-138 and 241-250). Fix: say the destination non-existence is restore's exclusion, or add the lease.
P3: flows name closed but error tables omit it in three docs
- SqliteStorage.md:81 says pending
storageReportcalls endclosedbut line 59 lists onlystorage; ManagedWorktrees.md:100-101 say pendinglistandpruneSelectioncalls endclosedbut 72-73 omit it; SessionFiles.md:101 says pendingownscalls endclosedbut 74 omits it. Fix: addclosedor state that the generation's cancellation is the answer.
P3: a failed creation can leave an orphan branch after a reload
- ManagedWorktrees.md:99 has
discarddelete the branch, 108 hasremovekeep it, and 76 makesdiscardanswerunknown_preparationafter a reload; a process death betweencreateandstore.create(104) then leaves the branch with no operation to delete it. Fix: state the retention, or letremovedelete a branch whose worktree was never adopted.
Verification
- Head b5606d1. PR open, not draft, mergeable. Checks:
changesandci-oksuccess; the docs-only jobs are skipped. Diff size 4 files, +1060/-0, base 1bc7d67. LC_ALL=en_US.UTF-8 node scripts/adr-check.mjs --base 1bc7d67d7e3b357a64fd82c2589f57e4cb4b4becpassed: "ADR freeze passed: 4 changed files".- Relative-link check over the four files found one missing target, docs/design/plugins/FileStorage.md, from SessionFiles.md:62.
- No full build or tests, because the diff is docs-only. No workspace changes. All cited code lines were checked at head b5606d1. Every inline anchor is inside the single
@@ -0,0 +1,N @@hunk of its new file.
Residual risks: the binding compile issues are reasoned from the rutis 0.23 #[rutis::service] rules and the current code, not from a build of the target shape. The cross-PR texts (#2080, #2093, #2094, #2096, #2098) were read from their PRs, not merged main.
|
|
||
| ### Dependencies | ||
|
|
||
| The engine's crate-private operations for every row read and write and for the Timeline batches; `sqliteStorage` is not a service face. The file owner `sessionFiles` for the Session file steps a delete releases. Neither dependency crosses back into SessionStore. The assembly provides both; deployment chooses the instance. |
There was a problem hiding this comment.
sqliteStorage is a service face: this same PR marks the capacity read on the SqliteStorage type under that name (SqliteStorage.md:119 and 160-169). The sentence should say the engine's row and transaction operations are not on the face, not that the face does not exist. Otherwise the two contracts disagree about whether storageReport is callable at all. Fix: "the engine's row and transaction operations are crate-private and are not a service face; sqliteStorage carries only storageReport".
There was a problem hiding this comment.
Fixed in b4bb7f8. SessionStore.md:99 now says the engine's public face is the capacity read and its row and transaction operations are crate-private, matching SqliteStorage.md:14 and 132.
| | Operation | Intent | Request | Reply | Cancellation | Errors | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `create` | Write one admitted Session and its optional worktree association | `{id, config, agentId, protocolVersion, leader?, origin, worktree?}` | `{}` | Before the transaction starts; a dropped future does not undo a commit | `invalid`, `workspace_missing`, `storage` | | ||
| | `delete` | Remove a closed Session's output, visible rows and Timeline rows | `{id}` | `{hadRows}` | Before the first step; after the first commit the steps run to their end | `storage` | |
There was a problem hiding this comment.
delete rejects an id that is not one path component (delete_session calls check_session_id, crates/dim-app-server/src/storage/timeline.rs:1551-1554; resource-faces.md:754-755), but this row lists only storage while the errors table defines invalid for exactly that case (line 134). A caller sends a/b, gets storage, and retries instead of fixing the id. Add invalid to delete. The flow also says new calls are refused closed (147), so add that too.
There was a problem hiding this comment.
Fixed in b4bb7f8. delete lists invalid and closed (SessionStore.md:108), and every flow that names closed has it in the error list (107-126).
| | `removeGrant` | Remove one grant; an absent grant counts as removed | `{id, path}` | `{}` | None | `storage` | | ||
| | `setLanguage` | Write the reply language into the stored configuration | `{id, language?}` | `{}` | None | `not_found`, `invalid`, `storage` | | ||
| | `title` | The title, its source and its committed revision | `{id}` | `{revision, title?: {text, source}}` | None | `not_found`, `storage` | | ||
| | `setTitle` | Commit the title the caller's change returns and announce it; the owner serializes writes | `{id}` + `change` | `{revision}` | The reply may be dropped; the admitted write is not cancelled | `not_found`, `rejected`, `storage` | |
There was a problem hiding this comment.
The dropped-reply guarantee cannot hold with the async fn set_title shown at 351-359: an async fn future is not admitted until its first poll, so dropping it before polling never starts the write. The current set_title is a plain fn that spawns the write before returning the wait future (crates/dim-app-server/src/storage/metadata.rs:201-224 and 342-350), which is what makes "a dropped reply still commits" true. Make the binding a plain fn returning impl Future, or weaken the flow and the verification at line 172.
There was a problem hiding this comment.
Partially fixed. The Rust signature is now a plain fn returning a future (SessionStore.md:411), so a native caller that drops it is covered. For a marked service, rutis 0.23 treats an impl Future return as awaited and puts the call inside the reply future, so the wire path still admits on first poll. The current hand-written invoke does it eagerly (crates/dim-app-server/src/storage/metadata.rs:366-380); see the new inline on line 411.
|
|
||
| | Operation | Normal path | Caller cancels | Caller unloads | Owner closes or reloads | Settled by | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `create` | Validate the id and the workspace, take the exclusion, write the rows, the owner row, the main branch, the catalog row and the association, commit | Before the transaction: nothing written. During: the transaction completes or fails; the reply may be lost | The transaction still completes; the caller keeps the id it supplied and decides whether to publish or delete the Session | New calls are refused `closed`; admitted work ends before the writer closes | Rows by SessionStore; the workspace by the caller | |
There was a problem hiding this comment.
The order puts the workspace check before the exclusion, which reopens the race the exclusion exists to close: removeWorktree can remove the root after this check and before the transaction, and create then writes the association to the missing root and commits a Session whose cwd is gone. The current code takes ownership first and checks config.cwd under it (crates/dim-app-server/src/storage/timeline.rs:1628-1636), and line 169 promises the removal case fails on the missing workspace. State "validate the id, take the exclusion, validate the workspace, write ...".
There was a problem hiding this comment.
Fixed in b4bb7f8. The create flow is now "Validate the id, take the exclusion, validate the workspace, write ..." (SessionStore.md:149), matching crates/dim-app-server/src/storage/timeline.rs:1628-1636.
| | `create` | Validate the id and the workspace, take the exclusion, write the rows, the owner row, the main branch, the catalog row and the association, commit | Before the transaction: nothing written. During: the transaction completes or fails; the reply may be lost | The transaction still completes; the caller keeps the id it supplied and decides whether to publish or delete the Session | New calls are refused `closed`; admitted work ends before the writer closes | Rows by SessionStore; the workspace by the caller | | ||
| | `delete` | Take the exclusion, read whether rows exist, remove output, touch worktree use, remove visible and Timeline rows, schedule the file sweep | Before the first commit: every row stays. After: the steps run to their end | The work continues under the owner's task; the reply may be lost | The admitted delete ends before close | Output and rows by SessionStore; files by SessionFiles | | ||
| | `fork` | Take the exclusion, read the source text, call `text`, copy in bounded transactions with the returned text, write the target row, commit | Before the first copy; a refused text step copies nothing | The copy continues; the reply may be lost | The admitted fork ends before close | Rows by SessionStore | | ||
| | `title`, `creationRecord`, `owner`, `hasRecords`, `sessionConfig`, `grants` | One read; no lock | Before the read | Nothing to release | Pending reads end `closed` | SessionStore | |
There was a problem hiding this comment.
The flow says pending reads end closed, but none of these operations lists closed in its errors column (lines 111-120). A title or sessionConfig call during a generation close would be reported as storage, and the caller would retry the same closing generation instead of the replacement. Add closed to each read's error list. The same omission exists for create and removeWorktree, whose flows also say new calls are refused closed (147, 154).
There was a problem hiding this comment.
Fixed in b4bb7f8. closed is listed on every read and write row that names it (SessionStore.md:107-126), and catalog/query distinguish cancelled from closed at 153.
| | `import` | Copy a regular host file into the Session namespace and commit ownership | `{sessionId, name, source}` | `{fileId, size}` | Before the replacement; a cancelled import leaves no owned row | `invalid`, `too_large`, `not_found`, `node_unavailable`, `cancelled`, `closed`, `storage` | | ||
| | `write` | Replace one Session file's bytes under the same id and path | `{sessionId, fileId, bytes}` | `{fileId, path, size}` | Before the replacement; the old bytes stay | `invalid`, `too_large`, `not_found`, `node_unavailable`, `cancelled`, `closed`, `storage` | | ||
| | `read` | Read one Session file whole, within the owner's limit | `{sessionId, fileId}` | `{bytes}` | While the file is read; nothing changes | `not_found`, `node_unavailable`, `cancelled`, `closed`, `storage` | | ||
| | `remove` | Remove one Session file and its ownership row; a file the Session does not own answers success | `{sessionId, fileId}` | `{}` | None; the owner completes the removal | `not_found`, `node_unavailable`, `storage` | |
There was a problem hiding this comment.
The row says a file the Session does not own answers success and line 120 verifies it, while line 85 defines not_found as "The Session has no such file". The operation cannot be both idempotent and report a missing file; a caller cannot tell whether to retry. Define not_found only for a missing Session, or drop it for remove and state the foreign-file result.
There was a problem hiding this comment.
Fixed in b4bb7f8. remove lists only storage and says an absent or foreign file answers success (SessionFiles.md:76, 101 and 135), so it is idempotent. One residual: remove omits node_unavailable, covered by the new inline on line 76.
| | `owns` | Whether a path or file id belongs to the Session | `{sessionId, path}` | `{owned}` | While the path is resolved | `node_unavailable`, `cancelled`, `storage` | | ||
| | `ownedPaths` | Every path the Session owns | `{sessionId}` | `{paths}` | None | `node_unavailable`, `storage` | | ||
|
|
||
| `bytes` is the file content as data; the owner's limit is 16 MiB. `read` answers the whole file within that limit: the limit is the owner's, so callers do not page. A `fileId` outside the Session, or a name that is not one component, is `invalid`. |
There was a problem hiding this comment.
This removes the offset page that the existing callers use: attachment.read {sessionId,fileId,offset} returns at most 64 KiB (docs/design/plugins/Attachments.md:148-149; crates/dim-agent-attachments/src/lib.rs:169-178), the HTTP download streams by offset (crates/dim-app-server/src/web_entry/uploads.rs:234,257), and image materialization pages by offset (crates/dim-agent-capabilities/src/session_files.rs:23-41). The claim "every caller needs the whole file" is false, and the stated page-id lifetime does not exist in the stateless offset read. Keep offset and the 64 KiB chunk, or update those callers and state the 16 MiB memory and single-reply cost. The same paragraph also calls a foreign file id invalid while line 121 returns not_found; pick one.
There was a problem hiding this comment.
Fixed in b4bb7f8. read takes {sessionId, fileId, offset}, returns {data, eof} with the 64 KiB bound and pages at the offset (SessionFiles.md:30, 49-51, 73, 79 and 112), matching crates/dim-app-server/src/storage/files.rs:620 and Attachments.md:148-149.
| | Operation | Intent | Request | Reply | Cancellation | Errors | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `create` | Allocate a task id and make a Git worktree and branch for a Session creation | `{source, base?, branch?}` | `{taskId, repository, root, subtree, branch, base}` | Between Git calls and before the branch is created; a cancelled creation removes its empty task directory | `unavailable`, `invalid`, `branch_exists`, `git`, `interrupted` | | ||
| | `discard` | Settle a created worktree that the Session creation did not adopt | `{taskId}` | `{}` | Not cancellable: the cleanup runs to its end | `unknown_preparation`, `in_use`, `git` | |
There was a problem hiding this comment.
discard is "Not cancellable" here, but the appendix takes CancelledFn (224) and the caller example passes CancellationToken::new() (45), a different token type. Section 7.2 says every parameter is complexity, so a no-op cancellation argument is a defect. Remove the argument or state what it stops, and make the example use the binding's CancelledFn.
There was a problem hiding this comment.
Fixed in b4bb7f8. discard takes no CancelledFn and is stated not cancellable (ManagedWorktrees.md:71 and 238-244), and the caller example passes no token (45).
| - **Offline operations.** Backup, restore and vacuum, each holding the same lease and refusing while a daemon owns the store. | ||
| - **The capacity value.** Database bytes, WAL bytes and reclaimable bytes, read through `storageReport`. | ||
|
|
||
| The rows belong to their data owners, and their operations live on those owners' faces: the Session rows and the Timeline batches to [SessionStore](SessionStore.md), the Agent records to Agents and Collaboration ([#2098](https://github.com/arcships/dim/pull/2098)), the Settings documents to Settings ([#2094](https://github.com/arcships/dim/pull/2094)), the Provider records to Provider ([#2096](https://github.com/arcships/dim/pull/2096)). The engine executes each owner's transactions and returns the stored form; it answers no business read or write on its public face and is not in the catalog for those rows. |
There was a problem hiding this comment.
This moves the Settings, Provider, Agent and Timeline transactions off the sqliteStorage face, but resource-owner-operations.md:41, 47, 57 and 59 and service-faces.md:128 still say those owners call the public face, and SessionStore.md:99 says the face does not exist. The four new docs need one target: either update those contracts and raise the requirements, or keep the face. The same tension appears at line 32 and in the rule check at 119-120.
There was a problem hiding this comment.
Fixed in b4bb7f8 for the face tables. service-faces sections 3.3 and 3.4, resource-faces section 5 and SqliteStorage.md:14-18 now agree that storageReport is the public face and the owner rows are crate-private. Residual P3: resource-owner-operations.md:12 still says store.readMetadata/setTitle.
|
|
||
| ### Dependencies | ||
|
|
||
| `fsHost` for the owner's directory, file creation, atomic replacement, import, listing and removal; the operations used are the ones in [FileStorage's contract](FileStorage.md). The engine's file-ownership rows are private to the storage crate and are not a service. The owner does not depend on `store`: the store depends on this owner when a delete releases files. |
|
已按评审修改,head
两个检查通过。请 @yyhhyyyyyy 复核。 |
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Scope: this PR defines target contracts for the session storage owners (SessionStore, SessionFiles, ManagedWorktrees, SqliteStorage) under section 7 of the principles, refs #2018 and #2015. I reviewed the full main...head tree at b4bb7f8a and the delta since b5606d10 against the storage code, the sibling contracts and section 7 of #2029.
Verdict: REQUEST_CHANGES. Most round-1 findings are fixed, but three round-1 P2s remain partially fixed: the setTitle handover for wire callers, the title interface migration, and the Timeline face wording in resource-faces.
Round-1 status
Fixed: create order; SessionStore error lists; SessionFiles offset paging, import reply and register root; remove idempotence; binding error types and the callback From<CallError> impls; and the P3s (cancellation arguments, undefined types, FileStorage link, MCP callers, restore destination rule, closed in the error tables, leftover branch).
Partially fixed: the store/timelineStore/sqliteStorage boundary (the tables and owner docs are updated; resource-faces section 5.1 is not), the title callback migration (the new docs are updated; SessionTitle and the title metadata doc are not), and the setTitle drop guarantee (the Rust signature is fixed; the wire path is not).
Findings
P2: setTitle still cannot guarantee the handover for wire callers
- Problem:
SessionStore.md:411-418declaresset_titleas a plain fn returningimpl Futureinside#[rutis::service], and lines 121, 155 and 186 say a dropped reply still commits. In rutis 0.23 a method whose return type isimpl Futureis treated as awaited, and the macro places the call inside the reply future (Answer::Later), soset_titleruns on the first poll of the reply, not when the host receives the call. The current hand-written dispatch calls it eagerly ininvoke(crates/dim-app-server/src/storage/metadata.rs:366-380), which is what makes the claim true today; the appendix replaces that adapter with the marked service.session-title-metadata.md:153still says the named service calls it insideinvoke. - Failure scenario: a foreign caller sends
setTitleand abandons the reply before its future is polled; the write is never admitted, so the title is not committed or announced. The flow at 155 and the verification at 186 fail. - Fix: keep the hand-written method registration for
setTitle(itsinvokecalls the plain fn, then returns the wait), or state that a wire call dropped before the reply is polled does not admit the write and change the flow and verification.
P2: the title migration leaves two contracts and two request fields
- Problem: the new requirement (
SessionStore.md:219) says the revision-checked shape is superseded, but the siblings still define it.SessionTitle.md:385still declaressessionMetadata.read, 413 keeps revisionr, 430 and 450 keepconflict, and 517-519 keepset_title(session_id, expected_revision, title)withConflict.session-title-metadata.md:132, 171, 207, 224, 333, 374 and 404 still showrevision != r,conflictand the expected-revision write. They also use request{sessionId}(session-title-metadata.md:92-93,SessionTitle.md:384), while the owner table and appendix use{id}(SessionStore.md:120-121andSetTitleat 297-299 withdeny_unknown_fields). The close code also differs: the owner listsclosed, while the metadata table folds it intostorage. - Failure scenario: a caller following SessionTitle or the metadata doc sends
{sessionId, expectedRevision, title}; the owner'sSetTitlehas onlyid, so the call is a malformed request. A call during close cannot distinguishclosedfromstorage. The document set gives two title contracts. - Fix: in this series, update SessionTitle.md and session-title-metadata.md to
store.titleandstore.setTitle(id, change), remove the conflict and expected-revision rows and the Appendix G shape, useid, and align the close code.
P2: resource-faces still defines the Timeline operations the target removed
- Problem:
resource-faces.md:610and 672 saycreateSession,releaseSession,rollbackSessionandappendare not operations of thetimelineStoreface, but section 5.1 still callsappend"the one face operation a caller may issue inside its own commit lock" (633-650) and describesreleaseSessionandrollbackSessionreplies and the remote-consumer rule forappend(645-650, 684-705). - Failure scenario: an implementer following section 5.1 keeps
appendon the face, or exposes it to remote consumers, which the SessionStore contract and service-faces now forbid. The same document gives two answers. - Fix: rewrite section 5.1 as the owner's internal admission and drain steps, or state in place that the face no longer carries them.
P3: remove omits the node failure and write lists an unused code
- Problem:
SessionFiles.md:76lists onlystorageforremove, while the removal goes through FileStorage on the Session's resource node, the conditionput,readandownsreport asnode_unavailable(70, 73, 75, 88).writelistsinvalid(72), but line 79 and the error table define no invalid case for a write. - Failure scenario: a caller that should retry later gets
storageand reports failure; a caller cannot tell whatinvalidmeans forwrite. - Fix: add
node_unavailabletoremove, and define or dropinvalidforwrite.
P3: discard cannot always run to its end
- Problem:
ManagedWorktrees.md:71and 99 composestore.removeWorktree, whose errors includeclosed,storageandrejected(SessionStore.md:126), butdiscardlists onlyunknown_preparation,in_useandgitand says its cleanup is not cancellable (109). - Failure scenario: a failed creation during store close calls
discard; the store refusesclosed, the worktree and branch stay, anddiscardhas no error to report. - Fix: map the store refusals and state the retention, or weaken the non-cancellable claim.
P3: the leftover-branch recovery needs a caller to run Git
- Problem:
ManagedWorktrees.md:111leaves a branch from a never-adopted creation and says the operator deletes it with Git, while the same contract's rule check at 145 says no caller invokes Git or reads the root and the operations own the branch. - Failure scenario: a process death between
createandstore.createleaves a branch with no operation to delete it, so the documented recovery requires an action the contract forbids. - Fix: let
removedelete the branch whose worktree was never adopted, or state the operator CLI step explicitly outside the caller contract.
P3: backup does not report the format code, and the lease bullet covers restore
- Problem:
SqliteStorage.md:61listsownedandstorageforbackup, butbackup_storevalidates the current schema (crates/dim-app-server/src/storage/backup.rs:183;validate_backup_schemaatcrates/dim-app-server/src/storage/sqlite.rs:2364-2369), and line 90 says the format gate applies to every offline tool. A wrong-format store fails asstorage, while the error table definesformatfor exactly that. The ownership bullet at line 11 also says an offline tool takes the same lock, while restore does not (15, 84). - Failure scenario: a backup of an older store reports a generic failure instead of the format code, so the caller does not run the documented upgrade path; a reader expects restore to take the lease.
- Fix: add
formattobackupand map the schema refusal, and qualify the lock bullet.
P3: stale pointers and one stale table row
- Problem:
SessionStore.md:5points to resource-faces section 5.2, which this commit replaced with a supersede paragraph (709-712);SqliteStorage.md:5points to resource-owner-operations, whose Native storage section is now one paragraph (resource-owner-operations.md:32).resource-owner-operations.md:12still saysstore.readMetadata/setTitleand points file reads at the superseded session-files interface, while line 32 supersedes it. - Failure scenario: a reader follows the current-implementation pointer or the table row to a retired operation.
- Fix: update the pointers and the row, or mark the row superseded.
Verification
- Head
b4bb7f8a3f2aed61a0c37ca6a9e15a00c40c6d1c, base1bc7d67d7e3b357a64fd82c2589f57e4cb4b4bec. PR open, not draft, mergeable. Delta sinceb5606d10: 12 files, +439/-469. node scripts/adr-check.mjs --base 1bc7d67d7e3b357a64fd82c2589f57e4cb4b4becpassed with 12 changed files. A link and anchor scan over the 12 changed files found no broken target.- CI:
changesandci-okpass; the docs-only jobs are skipped. - Code checks: create order (
crates/dim-app-server/src/storage/timeline.rs:1628-1636), eager setTitle admission in the current hand-written invoke (crates/dim-app-server/src/storage/metadata.rs:366-380), restore destination rule (crates/dim-app-server/src/storage/backup.rs:243-250), file page size (crates/dim-app-server/src/storage/files.rs:620), caller-side register root (crates/dim-agent-capabilities/src/host.rs:1526-1527). - The rutis 0.23 macro behavior for an
impl Futurereturn is from the published macro source; the wire-code derivation for the new{code, message}structs and the target appendix shapes were not built, because the diff is docs-only. - Cross-PR: #2094 Settings and #2093 SessionScope align with this split. #2098, #2100 and #2103 still carry the previous service-faces and resource-owner-operations rows at their heads, so they will need the same rebase; #2103's Attachments contract gives
attachment.readerrors withoutnode_unavailableorcancelled, whichSessionFiles.readcan return. - Residual risk: no build or test of the target binding appendix.
| } | ||
|
|
||
| /// Admits the write under the owner's serialization and returns the wait future; dropping it never cancels the admitted write. | ||
| pub fn set_title( |
There was a problem hiding this comment.
The marked service does not admit the write at this line. In rutis 0.23 a method returning impl Future is awaited, and the macro puts the call inside the reply future (Answer::Later), so set_title runs on the first poll of the reply, not when the host receives the call. The current hand-written dispatch calls it eagerly in invoke (crates/dim-app-server/src/storage/metadata.rs:366-380), which is what makes line 186 true today. Keep that eager call for the wire path, for example with the hand-written method registration, or change lines 121, 155 and 186 to say that a wire call dropped before the reply is polled does not admit the write.
There was a problem hiding this comment.
Partially fixed. Moving set_title out of the marked block is the right direction, but the appendix still does not define the hand-written store table it relies on: the only one today is the storage::Store wrapper at crates/dim-app-server/src/storage/face.rs:290-303, which lines 212 and 228 delete. A marked service dispatches only its marked methods, and a second provider for store is refused. State which dispatcher serves setTitle and how its invoke admits the write before returning, or keep the whole face on the hand-written table. The new inline at 408 covers this.
There was a problem hiding this comment.
Partially fixed in 9c81829. The hand-written invoke now calls set_title eagerly before returning the wait (SessionStore.md:419-422 and 463-486), so the wire handover is defined. SessionStore.md:228 and resource-faces.md:700 still advertise the marked service, which is the remaining contradiction.
There was a problem hiding this comment.
Fixed in 9ff2b07. The hand-written table now serves the whole store face, including setTitle, and SessionStore.md:213 and :229 plus resource-faces.md:700 no longer advertise a marked service.
| | --- | --- | --- | --- | --- | | ||
| | `read` | async | `{sessionId}` | `{revision, title: {text, source} \| null}` | `not_found`, `storage` | | ||
| | `setTitle` | async | `{sessionId, expectedRevision, title: {text, source: "auto" \| "manual"} \| null}` | `{revision}`: the committed revision | `conflict`, `not_found`, `storage` | | ||
| | `title` | async | `{sessionId}` | `{revision, title: {text, source} \| null}` | `not_found`, `storage` | |
There was a problem hiding this comment.
The owner contract uses {id} for title and setTitle (SessionStore.md:120-121 and SetTitle at 297-299 with deny_unknown_fields), but this table and SessionTitle.md:384 use {sessionId}. A caller following this doc sends a field the owner does not accept, so the request is malformed. The doc also leaves the old interface in place: 132, 207, 224, 374 and 404 still show conflict and set_title(expected_revision, ...), and SessionTitle.md:385, 413, 430 and 517-519 still declare sessionMetadata and the expected-revision write. Finish the migration in this series and use one field name.
There was a problem hiding this comment.
Partially fixed. session-title-metadata.md:92-93 now uses {id} and the change callback, but SessionTitle.md:386 and :416 still send {sessionId} to the owner's {id} with deny_unknown_fields, and Appendix G at :508 and :516 still uses SessionMetadataService::read. Section 6 at :153/:156 and acceptance 12 at :352 still say a call after close fails storage while section 4.1 and section 8 now say closed. These remain in the body and the inline at SessionTitle.md:386.
There was a problem hiding this comment.
Partially fixed in 9c81829. session-title-metadata.md:92-93 and SessionTitle A.2 and A.4 now use {id} and the change callback. The old interface remains in SessionTitle 226, 291 and 332 and in session-title-metadata.md's read references at 112, 216-217, 265, 286, 333 and 338. Finish the sweep.
There was a problem hiding this comment.
Fixed in 9ff2b07 except one sentence: session-title-metadata.md:311 still says SessionStore decides through its revision check. The listed read names and the SessionTitle rows now use title and the change callback.
| workflow. `releaseSession` drains accepted backend writes and releases their resources without | ||
| closing the Agent Session or its admission. App Server creation/deletion retain the repository | ||
| and lifecycle obligations in §5.2. | ||
| `createSession`, `releaseSession`, `rollbackSession` and `append` are the store's own creation and |
There was a problem hiding this comment.
This paragraph says the four operations are not on the face, but section 5.1 still defines append as the one face operation allowed inside a commit lock and describes releaseSession and rollbackSession replies (633-650 and 684-705). The doc now gives two answers. Rewrite 5.1 as the owner's internal admission and drain steps, or state in place that the face no longer carries them.
There was a problem hiding this comment.
Partially fixed. Section 5.1 is rewritten at resource-faces.md:622-626, but the rule check at :740 still calls timelineStore.append the one face operation allowed inside the caller's commit lock and :742 still says append admits one atomic batch. Update those two rows or label them as the current implementation superseded by section 5.1. The inline at 624 covers this.
There was a problem hiding this comment.
Fixed in 9c81829. resource-faces.md:740 and 742 are rewritten to the store's internal admission; §5.1 and the rule check now agree.
| | `read` | One page of a Session file, at most 64 KiB | `{sessionId, fileId, offset}` | `{data, eof}`, `data` is base64 and `eof` is true exactly when it is empty | While the page is read; nothing changes | `not_found`, `node_unavailable`, `cancelled`, `closed`, `storage` | | ||
| | `register` | Record a caller-owned output path for the Session | `{sessionId, path}` | `{}` | None | `invalid`, `not_found`, `storage` | | ||
| | `owns` | Whether a path or file id belongs to the Session | `{sessionId, path}` | `{owned}` | While the path is resolved | `node_unavailable`, `cancelled`, `closed`, `storage` | | ||
| | `remove` | Remove one Session file and its ownership row; an absent or foreign file answers success | `{sessionId, fileId}` | `{}` | None; the owner completes the removal | `storage` | |
There was a problem hiding this comment.
remove lists only storage, but removal goes through FileStorage on the Session's resource node, the condition put, read and owns report as node_unavailable (70, 73, 75, 88). A caller that should retry later gets storage and reports failure. Add node_unavailable here. The same table lists invalid for write (72) with no rule in line 79 or the error table that produces it for a write; define the trigger or drop it.
There was a problem hiding this comment.
Fixed in 0aec7ae. write no longer lists invalid (SessionFiles.md:72) and remove lists node_unavailable (:76).
| | Operation | Intent | Request | Reply | Cancellation | Errors | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `create` | Allocate a task id and make a Git worktree and branch for a Session creation | `{source, base?, branch?}` | `{taskId, repository, root, subtree, branch, base}` | Between Git calls and before the branch is created; a cancelled creation removes its empty task directory | `unavailable`, `invalid`, `branch_exists`, `git`, `interrupted` | | ||
| | `discard` | Settle a created worktree that the Session creation did not adopt | `{taskId}` | `{}` | Not cancellable: the cleanup runs to its end | `unknown_preparation`, `in_use`, `git` | |
There was a problem hiding this comment.
discard is not cancellable, but it composes store.removeWorktree (99), whose errors include closed, storage and rejected (SessionStore.md:126). This row has no such codes, so a store refusal during unload leaves the worktree and branch with no defined answer and the promise at 109 does not hold. Map the store refusals and state the retention, or weaken the claim.
There was a problem hiding this comment.
Fixed in 0aec7ae. discard lists closed and storage (ManagedWorktrees.md:71) and the exception at :110 says a store refusal leaves the directory and branch in place. The new retry sentence in that same line contradicts the preparation table at :76 and :100; that is a separate P2 in the body and the inline at 110.
There was a problem hiding this comment.
Fixed in 9c81829. ManagedWorktrees.md:71 lists closed and storage, and line 110 now says a store refusal leaves the directory and branch in place; the preparation-drop sentence is fixed too.
There was a problem hiding this comment.
Fixed for closed and storage in 9ff2b07. A related gap remains: store.removeWorktree and store.removeUnregisteredDirectory can answer rejected or invalid, and discard and remove do not map those codes. Covered in the new body.
| - A branch is kept when `remove` deletes a worktree: committed content must not disappear with the directory. | ||
| - `discard` is not cancellable: a cancelled Session creation still has to settle what the owner made. | ||
| - Unregistered directories are never pruned: the owner has no record to age, so only an explicit `remove` by task id deletes them. | ||
| - A branch outlives a creation that was never adopted: a process death between `create` and `store.create`, or a `discard` that ended before the branch deletion, leaves the branch. `remove` on an unregistered directory deletes the directory only; the operator deletes the leftover branch with Git, and `list` names the task id the branch was made for. |
There was a problem hiding this comment.
This leaves a branch with no operation to delete it and hands the cleanup to the operator through Git, but the rule check at 145 says no caller invokes Git or reads the root. Either let remove delete a branch whose worktree was never adopted, or state the operator CLI step explicitly outside the caller contract.
There was a problem hiding this comment.
Fixed in 0aec7ae. remove on an unregistered directory deletes the default dim/<taskId> branch of a never-adopted worktree and retains an explicit branch (ManagedWorktrees.md:112), so no Git step is handed to the caller.
| | Operation | Intent | Request | Reply | Cancellation | Errors | | ||
| | --- | --- | --- | --- | --- | --- | | ||
| | `storageReport` | The store's own file bytes, WAL bytes and reclaimable bytes | `{}` | `{databaseBytes, walBytes, reclaimableBytes}` | None | `closed`, `storage` | | ||
| | `backup` | Copy a closed store and its sidecar files into an archive | the database path and the destination | `{}` | None; the tool runs alone | `owned`, `storage` | |
There was a problem hiding this comment.
backup lists owned and storage, but backup_store validates the current native schema (crates/dim-app-server/src/storage/backup.rs:183 and validate_backup_schema at crates/dim-app-server/src/storage/sqlite.rs:2364-2369), and line 90 says the format gate covers every offline tool. A wrong-format store fails as storage instead of format. Add format and map the schema refusal, or change line 90. The ownership bullet at line 11 also says an offline tool takes the same lock, while restore does not (15, 84).
There was a problem hiding this comment.
Fixed in 0aec7ae. backup lists format (SqliteStorage.md:61), and the lease sentence now limits the shared lease to backup, migration and vacuum (:90); restore keeps the destination rule.
| Discovery and credential admission run in Provider before the conditional write. SQLite executes | ||
| the existing mutation, including its index updates, in one transaction. Provider constructs the | ||
| existing business reply. `importLegacy` remains its existing separate bulk transaction. | ||
| Superseded by the owner contracts. The Agent records belong to [Agents and Collaboration](https://github.com/arcships/dim/pull/2098), the Settings document operations to [Settings](https://github.com/arcships/dim/pull/2094), the Provider record operations to [Provider](https://github.com/arcships/dim/pull/2096), and the Session repository operations to [SessionStore](../plugins/SessionStore.md). The engine's public face is the capacity read and the offline operations ([SqliteStorage](../plugins/SqliteStorage.md)); its transactions are the data owners' crate-private implementation, and no operation of those owners is published under `sqliteStorage`. |
There was a problem hiding this comment.
The table at line 12 still says store.readMetadata/setTitle and points file reads at the superseded session-files interface, although this paragraph supersedes it. A reader following the row gets a retired method. Update the row to store.title and setTitle(id, change) and the SessionFiles contract.
There was a problem hiding this comment.
Fixed in 0aec7ae. resource-owner-operations.md:12 now points at SessionStore and SessionFiles and keeps only the pointer. One residual: the Credential values section below the new supersede paragraph still advertises sqliteStorage.readRecord and the user methods; that is a separate P2 in the body.
|
|
||
| Scope: process. Issue: #2018. | ||
|
|
||
| SessionStore owns the stored Session: its rows, its grants, its reply language, its title revision, its worktree records, the exclusion that keeps those records consistent with Session creation, and the Timeline storage engine those rows are read through. This document is the owner's target contract. The current implementation is described in [Session rows §5.2](../resource-faces.md#52-session-rows) and [Native storage format](../appserver/native-storage-format.md). The Session-scoped `timelineStore` face carries this owner's Timeline operations; SessionScope binds that face at the Session instance ([#2093](https://github.com/arcships/dim/pull/2093)). |
There was a problem hiding this comment.
This pointer is stale: this commit replaced resource-faces section 5.2 with a supersede paragraph (resource-faces.md:709-712). Point at native-storage-format and the code, or say 5.2 is superseded. SqliteStorage.md:5 has the same problem with resource-owner-operations, whose Native storage section is now one paragraph at line 32.
There was a problem hiding this comment.
Fixed in 0aec7ae. SessionStore.md:5 now points at native storage format, and SqliteStorage.md:5 does the same.
Goal keeps the trigger's sequence, names the state record's one writer, takes cancellation on the line read, carries a submission id, states the ended-line client change and the evaluator refusals, and uses GoalViewStatus. SessionTitle follows #2091's ChangeFn binding and drops the broadcast row. Web declares search for a configured adapter. Code Mode gates on the mount exclusion and its examples compile. Compatibility anchors and the standing documents' owner paragraphs point at the new contracts. Refs #2033
b4bb7f8 to
4011e4f
Compare
|
已按评审修改,head 台账
指针清单与上一轮相同:resource-faces §5/§5.1/§5.2/§9(6)/§6 行/§1 行/§4.2;service-faces 五行/§4.5/§4.8/timelineStore 三向指针;resource-owner-operations credential;session-title-metadata §1/§4.1/§4.2/§5/§6/§10/Appendix A;SessionTitle 三行;session-files §9.1;worktree-management §5;worktree-access §4;typescript-plugin-authoring/plugin-contract/session-deletion-and-fork/overview;中文镜像。 最后一轮预审摘要(第二轮)
剩余 P2无。 剩余 P3
检查
请 @yyhhyyyyyy 复核。 |
4011e4f to
8114685
Compare
zerob13
left a comment
There was a problem hiding this comment.
Settle new-file creation inside SessionFiles when durability is uncertain. The new unsynced and missing_parent contract tells the caller to read and retry the same file or create its parent. That applies only to a replacement with a known file ID. A failed put or import may have placed bytes under a new ID the caller never receives, and the parent belongs to SessionFiles. Specify owner-side resync and commit or cleanup without publishing ownership; return the established attachment-facing errors where appropriate. This is creation settlement, not just an error-enum addition.
Also align SessionStore's removal with ManagedWorktrees' stale-record cleanup. Preserve the existing success path when the registered root is already gone so a retry can retire the record under the same exclusion. The earlier refusal-mapping discussion can stay where it is.
Hosted checks passed. They exercise the existing implementation, not these proposed flows.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Review: PR #2091, round 6, head 05284be
Scope: this PR defines the target contracts for the session storage owners (SessionStore, SessionFiles, ManagedWorktrees and SqliteStorage) and moves the title, Session file and worktree call sites onto them, refs #2018 and #2015. I reviewed the full main...head at 05284be against current main eacc672d and the storage code; the PR diff is 27 files, +1466/-734. Verdict: REQUEST_CHANGES.
Prior round
- P2 1, the Session face carried the process store's reads: fixed and withdrawn.
resource-faces.md§5 is now a pointer to the SessionStore contract (:604-618),service-faces.md:129states the split, andSessionStore.md:18keepssessionConfigandqueryonly on the processstore. - P2 2,
session-title-metadatastill described a revision check: fixed and withdrawn. Line 3 states the interface has noexpectedRevision, and §10 is now a pointer (session-title-metadata.md:3,:153-154). - P2 3, the fork requirement and flow disagreed on transactions: fixed and withdrawn.
SessionStore.md:34now reads the source body and decides the target text under the fork exclusion, and writes the target body and rows in the last batch transaction. - P2 4, ManagedWorktrees did not map the store's removal refusals: partly fixed. The owner error table now uses the published
worktree_*codes (ManagedWorktrees.md:82-94), but the store'srejectedreason and thediscardrow still have no complete mapping; see P2 2 below. - P2 5, the
setTitleexample passed a cancellation token the binding does not accept: fixed and withdrawn. The call is nowstore.setTitle(SetTitle { id }, change)(SessionStore.md:84).
P2 findings
P2 1. The removeWorktree example passes a cancellation token the binding does not accept
Problem: SessionStore.md:95 calls store.removeWorktree(Directory { repository, root }, remove, cancelled.clone()), but the binding at :514-519 takes only caller, request and remove; the token is already captured by the RemoveFn closure at :91-94. The operation table at :129 says the caller's step ends and the record stays; no store argument cancels the call.
Failure scenario: An implementer copies the example and gets a compile error. If the implementer instead adds a cancellation argument to the binding, the store can cancel after it has taken the Session exclusion, while the operation contract says the callback owns cancellation and the record stays. This is the same extra-token shape the round-5 setTitle finding identified, now in the removal example.
Evidence: docs/design/plugins/SessionStore.md:89-95, :129, :427-429, :514-519.
Fix: Remove the third argument and keep the token in the RemoveFn closure. If store-level cancellation is intended, add it to the binding and the operation contract together.
P2 2. ManagedWorktrees still does not map every store removal refusal
Problem: ManagedWorktrees.md:74 says a started removal reports worktree_git_failed, and the discard row at :71 lists neither worktree_not_found nor worktree_invalid. The store's removeWorktree and removeUnregisteredDirectory return invalid, not_found, in_use, rejected, closed and storage, and a callback refusal is rejected with the callback's reason (SessionStore.md:129-130, :180, :185). The new error table names the owner codes but does not say which store refusal maps to which code.
Failure scenario: A cancelled Git step returns rejected reason cancelled; the remove row says a started removal reports worktree_git_failed, and no sentence maps the refusal, so the CLI sees a Git failure instead of an interrupted removal. The discard row also omits worktree_invalid and worktree_not_found, which its removeWorktree call can answer, so the caller has no code for those outcomes. The caller cannot distinguish cancellation, a missing directory and a Git failure.
Evidence: docs/design/plugins/ManagedWorktrees.md:71, :74, :82-94, :111; docs/design/plugins/SessionStore.md:129-130, :180, :185, :199.
Fix: State the mapping explicitly, for example rejected reason git to worktree_git_failed, cancelled to worktree_interrupted, invalid to worktree_invalid, not_found to worktree_not_found, and closed/storage to worktree_store_failed; add the missing codes to the discard row.
P3 findings (optional)
P3 1. releaseSession names two different owners
Problem: SessionStore.md:136 and :276 call releaseSession a store creation and commit step, while SessionFiles.md:77 defines releaseSession as a SessionFiles operation and SessionStore.md:192 calls sessionFiles.releaseSession. The same name belongs to two owners.
Failure scenario: An implementer binds store.releaseSession instead of sessionFiles.releaseSession, or implements both. The Timeline face's internal release and the file-owner release are no longer distinguishable by name.
Evidence: docs/design/plugins/SessionStore.md:136, :192, :276; docs/design/plugins/SessionFiles.md:77.
Fix: Rename the Timeline internal step (for example releaseTimeline) or qualify every mention by owner.
P3 2. Sibling heads in the contract and PR body are stale
Problem: SessionFiles.md:172 cites #2080 at 2a312945c, but #2080 is at 4f8bd658; the PR body lists #2080 72ea12c9c, #2092 d96802349 and #2093 4209c4464. At the current sibling heads, git merge-tree reports conflicts with #2080 in docs/design/contracts/resource-owner-operations.md, docs/design/resource-faces.md and docs/design/service-faces.md, and with #2093 in docs/design/plugins/README.md, docs/design/resource-faces.md and docs/design/service-faces.md.
Failure scenario: An implementer aligns against the stale FileStorage or SessionScope head. The PR body's merge order still names old heads, so the actual rebase and conflict resolution are not visible to a reviewer.
Evidence: docs/design/plugins/SessionFiles.md:172; PR body; merge-tree of 05284be with 4f8bd65 and d4e4284.
Fix: Update the sibling heads and the FileStorage citation after rebasing, and state the conflicts resolved by each rebase.
P3 3. git diff --check reports a blank line at EOF
Problem: git diff --check reports docs/zh/design/appserver/session-title-metadata.md:248: new blank line at EOF.
Failure scenario: The local whitespace check is not clean, unlike the rest of the documentation changes.
Evidence: git diff --check origin/main...HEAD.
Fix: Remove the trailing blank line.
Cross-PR and main
- The PR is open, not draft, mergeable, and its head is 05284be. Current main is eacc672; the merge base is also eacc672, so the full diff is the 27-file, +1466/-734 change above.
- #2080 at 4f8bd65 defines the FileStorage operations SessionFiles calls; #2093 at d4e4284 defines the Session timeline face and the
sessionConfig/querysplit. #2092 at 91da0de defines the Timeline operations. The PR's merge order places #2080 before the #2091/#2092/#2093 group; the current heads conflict in the shared pointer sections above, so a rebase is needed before those branches can land. - The PR body lists #2098 and #2099 as later in the merge order; their current heads were not rechecked this round.
Verification
- PR state before drafting: head 05284be, OPEN, not draft, MERGEABLE, clean worktree.
- CI at 05284be:
changes,static-checks,verify (linux),macos-nativeandci-oksucceed; the other jobs are skipped. LC_ALL=en_US.UTF-8 node scripts/adr-check.mjs --base eacc672d: passed for 27 changed files.git diff --check origin/main...HEAD: failed with the blank line at EOF listed in P3 3.- A local relative-link scan over the 27 changed files found no missing target.
- No Rust build or test was run; this is a documentation-only PR.
Unverified
- The target bindings and examples were not compiled.
- The cross-PR conflicts were checked with
git merge-treeat the current sibling heads; no merge was performed. - The stale sibling-head citations were not checked against every commit referenced by the PR body.
| let cancelled = cancelled.clone(); | ||
| Box::pin(async move { git_remove(&root, force, &cancelled).await }) | ||
| }); | ||
| store.removeWorktree(Directory { repository, root }, remove, cancelled.clone()).await?; |
There was a problem hiding this comment.
P2: this call passes cancelled, but the binding at :514-519 takes only caller, request and remove; the token is already captured by the RemoveFn closure at :91-94, and the operation table at :129 says the caller's step ends with the record kept. The example either does not compile or teaches a store-level cancellation the binding does not have. Remove the third argument and keep the token in the closure; if store-level cancellation is intended, add it to the binding and the operation contract together.
There was a problem hiding this comment.
Partly fixed in c6d1dae. The extra token is gone, but the example still omits the caller: SessionStore.md:95 passes only Directory and remove, while the binding at :519-524 takes caller: &Ctx first and the other examples pass ctx at :59, :73 and :84. Add ctx, otherwise the example still does not compile. The remaining signature point is in the body.
|
|
||
| #### Timeline face | ||
|
|
||
| `timelineStore` is the same owner's Session-scoped Timeline face; SessionScope installs the binding at the Session instance (#2093). This contract owns the spellings. The instance identity is the Session: every request's `sessionId` must equal it, and a mismatch answers `invalid`; that rule is part of every row's `invalid` below. The face carries the line reads and the completion subscriptions; `createSession`, `releaseSession`, `rollbackSession` and `append` are the store's own creation and commit steps, and `sessionConfig`/`query` are the process `store` reads. |
There was a problem hiding this comment.
P3: releaseSession is defined as a SessionFiles operation at SessionFiles.md:77 and called as sessionFiles.releaseSession at :192, but this paragraph and :276 call releaseSession one of the store's own creation and commit steps. The same name belongs to two owners. Rename the store step (for example releaseTimeline) or qualify every mention by owner.
There was a problem hiding this comment.
Partly fixed in c6d1dae. The store's Timeline step is now releaseTimeline (SessionStore.md:137, :193, :281), and sessionFiles.releaseSession is qualified at :102 and :193. One stale mention remains: SqliteStorage.md:153 lists releaseSession among the timelineStore operations the face does not carry; use releaseTimeline there too. The thread can close once that line is fixed.
Add the target contracts for the four owners of the session storage board under design rules §7: SessionStore, SessionFiles, ManagedWorktrees and SqliteStorage. Each document has the responsibility split, the caller examples, the own contract with operations, errors and flows, the exceptions with reasons, the rule check and the requirements raised to mechanism owners. Refs #2018 Refs #2015
…callback SessionStore owns title write order: the caller supplies the title, the owner serializes the write, answers the committed revision and publishes the notice. The expected revision leaves the request, the caller example, the operation, the errors and the flows. Worktree removal becomes one removeWorktree operation with the caller's removal callback: the store holds the Session exclusion, checks the association and workspace state, runs the caller's Git step and deletes or keeps the record by its result. The claim id and the two-step claim/settle protocol leave SessionStore and ManagedWorktrees. Refs #2018 Refs #2015
setTitle takes the caller's change instead of a title plus an expected revision: the change receives the current title, its source and revision, and returns the next title or its own refusal. SessionStore serializes the decision, commits the returned title, announces it and answers the new revision. The conflict error leaves the contract; a refused change keeps the title. The title read now carries the source. Refs #2018 Refs #2015
SessionStore: query serves loaded and unloaded Sessions; the store owns the Timeline operations and the timelineStore face, bound by SessionScope at the Session instance. SessionFiles: put answers the path a read tool opens; write replaces an existing file under the same id and path; remove deletes one Session file. SqliteStorage: Settings gains a change operation under the row's exclusion beside the user path's compare-and-set; the Provider group carries the record projections, candidate and page queries, source activation and adoption, edit commits and legacy import. Refs #2018 Refs #2015
…nto the fork SqliteStorage's public face is the capacity read and the offline operations. The Settings, Provider, Agent record and Timeline transactions are crate-private implementations of their data owners; the engine no longer answers their reads or writes under sqliteStorage. SessionStore.fork reads the source configuration text itself and takes the target text from a caller callback that runs under the fork's exclusion; the source text cannot change between the read and the copy. sessionConfigText is removed. Refs #2018 Refs #2015
SessionFiles: read pages by offset with the 64 KiB bound, import and put keep
{fileId, path, bytes}, register leaves the output root with the caller, remove
is idempotent, and the binding appendix defines its request, reply and error
types. SessionStore: create validates the workspace inside the exclusion, every
flow's ending is in the error list, setTitle is a plain fn that admits the write
and returns the wait future, and the binding errors carry their codes.
ManagedWorktrees: discard takes no cancellation, list and prune answer closed,
the leftover branch rule is stated, and the appendix types are defined.
SqliteStorage: the public face is storageReport and the offline operations;
restore is excluded by its destination rule, not a lease.
The named design documents now point at the contracts: resource faces, service
faces, resource owner operations, session files, session title metadata,
SessionTitle and Attachments.
Refs #2018
Refs #2015
Rebase onto main. SessionStore keeps setTitle on the hand-written method table so a dropped wire reply still admits the write; the title interface is migrated in SessionTitle and the title metadata doc to store.title and setTitle(id, change), without expectedRevision or conflict. Resource faces section 5.1 now describes admission and drain as the store's internal steps. SessionFiles removes the unused invalid code from write and reports node_unavailable on remove; the FileStorage dependency drops root_path and states that the host's root set covers the store directory. ManagedWorktrees maps store refusals in discard and deletes the default dim/<taskId> branch of a never-adopted worktree. SqliteStorage reports format from backup and limits the lease to backup and vacuum; the stale pointers are fixed. The binding appendices use the routed error enums with the code tag, the callback error keeps the callback's code in reason, and all four appendices compile in a temporary crate against rutis 0.23. Refs #2018 Refs #2015
FileStorage's latest contract restores root_path, add_root, stat and read's size. SessionFiles reads the store directory's root with root_path instead of computing it from the database path; the requirement names the operations at that head and the host's root registration for the native store directory. Refs #2018 Refs #2015
SessionStore: the store face is one hand-written HostDispatch on the owner, so
setTitle is admitted in invoke before the reply future is returned; the
supersede entry names title and setTitle(id, change).
SessionFiles: an offset above the file size is clamped before the page read,
remove reports closed during unload, and the parent close row matches.
SessionTitle and session-title-metadata: use {id} and setTitle(id, change),
list closed with its service_reloading mapping, and replace the
SessionMetadataService binding.
Resource faces: the rule check names the store's internal admission instead of
append as a face operation. The credential rules now point at the Provider and
Settings owners' operations, not at sqliteStorage. ManagedWorktrees: a discard
refused by a closing store drops its preparation and retries through remove.
Refs #2018
Refs #2015
The store face is one hand-written HostDispatch on SessionStore; the
"service is marked" wording is gone from the contract and resource faces.
Titles keep only setTitle {id} plus the change callback: the revision-check
diagrams, expected-revision labels and conflict retries are removed from
SessionTitle and the title metadata doc, which now use title and add closed
to the error tables.
The associateWorktree request uses {id} in service faces, resource faces and
worktree access, and the supersede list records them.
Refs #2018
Refs #2015
The paragraphs this PR supersedes in resource faces, service faces,
resource-owner-operations, session-title-metadata, SessionTitle,
worktree-management and worktree-access become one-line pointers; their
headings stay. The Supersedes lists match the changed sections.
SessionStore.fork reads the source body and decides the target text under the
fork exclusion, and the target body and rows are written by the last batch
transaction. The contract names the process-face query and sessionConfig with
{id}. ManagedWorktrees maps each store refusal to its own answer and the
caller's next step. The setTitle example drops the cancellation argument the
binding does not take.
Refs #2018
Refs #2015
SessionStore restores the timelineStore operation contract (reads, completion subscriptions, notification shape, watermark and release rules) and keeps the query read scope. create/fork/delete hand over to owner tasks; duplicate create, missing fork source and second removal have results; associateWorktree dedupes; removeUnregisteredDirectory keeps the lock after the caller leaves. SessionFiles adds releaseSession and states the put cancellation and the close endings. SqliteStorage separates the offline functions from the service face. ManagedWorktrees keeps the published worktree_* codes, never deletes a branch on an unregistered removal and answers keptBranch. The remaining main-tree paragraphs that describe these owners point at the contracts, and the zh mirrors follow for the title and session-files interfaces. Refs #2018 Refs #2015
removeWorktree accepts a directory without a record, so discard can settle a created worktree; the reply says whether a record was deleted. The write operations no longer take a cancellation token, and setTitle commits once its change runs. The timelineStore flows and the worktree read flows are stated. query keeps the full read scope, session_owners has one writer, the delivery maps every code and rename, and the zh mirrors point at the contracts. Refs #2018 Refs #2015
SessionFiles maps FileStorage's unsynced and missing_parent on put, import and write, and remove's cancellation to cancelled. The Timeline face states that a sessionId differing from the instance identity is invalid. Service faces names the three owners of the timelineStore row. Refs #2018 Refs #2015
SessionFiles settles new-file creation itself: put and import create their parents, resolve unsynced by committing the ownership row or deleting the bytes, and keep only the attachment-facing codes; only a replacement leaves unsynced to the caller. removeWorktree treats a missing root as success and unregisters the record under the same exclusion. The example drops the extra argument, ManagedWorktrees maps every store refusal, and the internal Timeline step is releaseTimeline. The sibling heads and the trailing blank line are fixed. Refs #2018 Refs #2015
The store's removal checks and registers the resolved root, releases the exclusion, runs the callback in its own task and re-takes the exclusion to delete the record and clear the registration; create, fork, associate and a second removal refuse a path at, under or above a registered root. Creations register symmetrically, the record-only cleanup keeps its operation, and the worktree owner states the non-Unix unregistered removal rule. Refs #2018 Refs #2015
05284be to
c6d1dae
Compare
zerob13
left a comment
There was a problem hiding this comment.
New-file settlement and cleanup when a registered root is already missing now address the previous review. One new contradiction remains in the reconciliation with merged #2133.
Use one worktree removal lifecycle throughout. The new registration paragraph records the root under the lock and releases the lock before an owner task removes it. The operation flow next to it, and the ManagedWorktrees flow, still hold the exclusion across removal or allow caller unload to stop the process. Make the merged lifecycle authoritative in both places: retain the path registration through owner-task settlement even if the caller leaves, refuse overlapping operations with the existing in-use behavior, and let unrelated work proceed. This is distinct from the earlier error-mapping finding.
Hosted checks passed; the native jobs exercise existing code, not the proposed contract.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Review: PR #2091, round 7, head c6d1dae
Scope: this PR defines the target contracts for the session storage owners (SessionStore, SessionFiles, ManagedWorktrees, SqliteStorage) and moves the title, Session file and worktree call sites onto them, refs #2018 and #2015. I reviewed the full origin/main...HEAD at c6d1dae against main 5930539 and the storage code; the PR is 27 docs files, +1485/-754. Verdict: REQUEST_CHANGES.
Prior round
- Prior P2 1, the
removeWorktreeexample passed a cancellation token: partly fixed. The token is gone, but the example still omits the caller; see P2 1. - Prior P2 2, ManagedWorktrees did not map the store refusals: partly fixed. The table and the
discardrow exist, but several rows still disagree with the operation rows and the new registration paragraph; see P2 4. - Prior P3 1,
releaseSessiondual ownership: partly fixed. The store's Timeline step is nowreleaseTimelinein SessionStore.md:137, :193 and :281, but SqliteStorage.md:153 still namesreleaseSession; see P3 1. - Prior P3 2, stale sibling heads and the FileStorage citation: fixed. The PR body lists the current sibling heads and SessionFiles.md no longer pins a head; withdrawn.
- Prior P3 3, the EOF blank line: fixed.
git diff --checkis clean; withdrawn. - The earlier fixed findings on the Session face, the title revision check, the fork transaction and the setTitle token stay withdrawn.
- The existing review's two points at 05284be are addressed: SessionFiles.md:82 settles a new
unsyncedfile in the owner, and SessionStore.md:179 treats an already-missing root as success.
P2 findings
P2 1. The removeWorktree example still does not match its binding
Problem: SessionStore.md:95 calls store.removeWorktree(Directory { repository, root }, remove).await?, but the binding at :519-524 takes caller: &Ctx first, then the request and the callback. The create, fork and setTitle examples all pass ctx (:59, :73, :84).
Failure scenario: An implementer copies the removal example and gets a compile error on the missing caller argument. The prior fix removed the extra token but left the example one argument short, so the document still teaches a call shape the binding does not have.
Evidence: docs/design/plugins/SessionStore.md:95, :519-524, :59, :73, :84.
Fix: store.removeWorktree(ctx, Directory { repository, root }, remove).await?;.
P2 2. The removal section still says the exclusion is held across the callback
Problem: The new registration paragraph at :210 says removeWorktree checks under the exclusion, registers the root, releases the exclusion, runs the callback in the owner's task, and re-takes the exclusion to delete the record. Several earlier statements say the opposite:
- :87 and :90 say the owner holds the exclusion while the Git step removes the root.
- The flow row at :200 says "take the exclusion, ... call
remove, delete the record on success, release" and "the exclusion releases" when the callback ends. - The exception at :208 says the step "runs ... under the Session exclusion".
- The ManagedWorktrees flow at :116 says "the store checks and holds the exclusion, this owner removes the Git worktree".
- The verification at :242 and :246 says a concurrent creation "waits for" the removal, while :210 says
createis refusedinvalidwhile a root is registered.
Failure scenario: An implementer follows :200 or :208 and holds the exclusion across the callback. The callback has no time bound (a recursive forced deletion runs to its end), so every Session creation, fork and worktree association blocks for the whole deletion, which is the slow step the registration exists to take out of the lock. A test author following :242 or :246 writes a test that expects the creation to wait or succeed, while an implementation following :210 refuses it.
Evidence: docs/design/plugins/SessionStore.md:87, :90, :200, :208, :210, :242, :246; docs/design/plugins/ManagedWorktrees.md:116.
Fix: Rewrite :87, :90, :200, :208, ManagedWorktrees.md:116 and the two verification bullets to the release-register-reacquire model and the invalid refusal, or change :210 to the held-lock model and accept the unbounded lock. Keep one model.
P2 3. Worktree creation registration has no operation on the store face
Problem: The new exception at ManagedWorktrees.md:125 says a creation registers its selected root in the store's creating set before it makes the directory, and a failed creation hands the registration to the removing set. No operation on the store face performs either step: the operations table at SessionStore.md:110-131 has no creation-registration operation, store.create (:110) runs after the directory exists and receives only {repository, root, subtree}, and the ManagedWorktrees create reply at :189-196 carries no registration handle. The requirements section at :176 says "None new", so the gap is not raised anywhere.
Failure scenario: A removal starts after ManagedWorktrees creates the directory but before store.create writes the association. Without the creation registration, the store's removal checks see no association and no stored workspace, so removeUnregisteredDirectory or removeWorktree accepts the root; the removal deletes the worktree while the creation is about to hand it to the Session, and store.create then fails workspace_missing or associates a directory being deleted. The contract says this race is closed, but no caller can invoke the step that closes it. The current code has the missing piece: crates/dim-app-server/src/storage/timeline.rs:2162-2182 begin_worktree_creation returns a WorktreeCreation guard that the prepared value holds until adoption.
Evidence: docs/design/plugins/ManagedWorktrees.md:112, :125, :176, :189-196; docs/design/plugins/SessionStore.md:110, :125, :210.
Fix: Name the operation (for example store.beginWorktreeCreation {root} -> {creationId}) in the store table and pass the creation id or handle to store.create and the failed-creation cleanup, or state that the store itself makes the directory under create. Update the "Requirements raised to mechanism owners" sections accordingly.
P2 4. ManagedWorktrees maps one store answer to two codes
Problem: The mapping table at ManagedWorktrees.md:80-90 still disagrees with the operation rows and the SessionStore contract:
- :84 maps store
invalidtoworktree_invalid, while SessionStore.md:210 maps aninvalidcaused by a path being removed toworktree_in_use. - :88 maps
rejectedreasoncancelledtoworktree_interrupted, while theremoverow at :74 and the flow at :116 say a started removal "completes or reportsworktree_git_failed". The binding takesCancelledFnand the SessionStore removal example at :93 passes the token intogit_remove, so a started Git step can returncancelled. - :90 maps store
closedtoworktree_store_failed, while the error table at :104 saysworktree_interruptedis also reported when the generation closed.
Failure scenario: The CLI gets two codes for the same transition. A second worktree.remove that meets an in-flight removal receives invalid, and the table tells the operator to fix the task id instead of retrying (worktree_invalid), while the owner contract says the client reports worktree_in_use. A cancelled Git step reports a Git failure or an interrupted removal depending on which row the implementer follows, and the caller's next step differs: report Git's message or retry on the same generation. A store reload during a removal reports a store failure or an interruption for the same close.
Evidence: docs/design/plugins/ManagedWorktrees.md:74, :84, :88, :90, :104, :116; docs/design/plugins/SessionStore.md:93, :210.
Fix: Add the missing row for invalid on a path being removed and map it to worktree_in_use, make the cancellation row and the remove rows agree on worktree_git_failed or worktree_interrupted, and scope the error table's generation-close sentence to the owner's own close so the store's closed stays worktree_store_failed.
P2 5. The Chinese mirrors still define the revision-checked title interface
Problem: The English owner contract and the English SessionTitle now use store.title and setTitle(id, change) with rejected, but the Chinese mirrors still define setTitle {sessionId, expectedRevision, title}, conflict and the sessionMetadata service:
docs/zh/design/appserver/session-title-metadata.md:9,:12,:15,:27,:43,:46,:53,:110,:121,:165,:238-242.docs/zh/design/plugins/SessionTitle.md:87,:120,:147,:165,:214-216,:262.
The zh title metadata banner at :3 says the Write and Binding sections are superseded, but section 1 still contains both bullets and the revision-checked summary; sections 4 to 6 are pointers to the contract, so the same file gives two interfaces. The zh SessionTitle section 3.4 text now says a rejected change discards, while the sequence diagram in the same section still sends setTitle(expected r, manual) and expects r+1.
Failure scenario: A Chinese reader implements the owner or the caller from the mirror: a revision-checked write with a conflict retry, a sessionMetadata injection and a metadata read. The owner serves none of these; the caller fails to compile or retries a conflict the store never returns.
Evidence: docs/zh/design/appserver/session-title-metadata.md:9, :12, :15, :53, :110, :238-242; docs/zh/design/plugins/SessionTitle.md:147, :165, :214-216; the English contract at docs/design/plugins/SessionStore.md:123-124 and docs/design/appserver/session-title-metadata.md:3.
Fix: Mirror the English sweep in both zh files: replace the Write/Binding bullets and the structure table with the store face, update the revision and conflict text to the change callback and rejected, and update the diagrams. The author's ledger lists only the old sessionMetadata name as P3; the stale expectedRevision and conflict text is a different interface, so this is not just naming.
P3 findings (optional)
P3 1. SqliteStorage still names releaseSession for the Timeline face
Problem: SqliteStorage.md:153 says the timelineStore face does not carry createSession, releaseSession, rollbackSession or append, but SessionStore.md:137 and :281 renamed the store's Timeline step to releaseTimeline; releaseSession is the SessionFiles operation at SessionFiles.md:77. The same dual name the prior round flagged is still in this cross-reference.
Failure scenario: A #2025 implementer excludes the wrong operation from the Session Timeline face and keeps a releaseSession method on timelineStore, while the SessionFiles release keeps its own name.
Evidence: docs/design/plugins/SqliteStorage.md:153; docs/design/plugins/SessionStore.md:137, :281; docs/design/plugins/SessionFiles.md:77.
Fix: Rename it to releaseTimeline.
P3 2. The ManagedWorktrees code citation is off by about thirty lines
Problem: ManagedWorktrees.md:94 cites crates/dim-app-server/src/worktrees.rs:85-108 for the published worktree_* codes. In main the WorktreeError enum starts at :111, code() at :125 and the strings at :127-134; :85-108 is the prune view.
Evidence: docs/design/plugins/ManagedWorktrees.md:94; crates/dim-app-server/src/worktrees.rs:111, :125-135.
Fix: Cite :111-135 or :125-135.
P3 3. remove says it is not cancellable but lists cancelled
Problem: SessionFiles.md:76 gives remove the cancellation column "None; the owner completes the removal during close" and lists cancelled among its errors; the flow at :105 says the caller cancels before the unlink, and the binding at :267-273 takes no CancelledFn.
Failure scenario: An implementer adds a cancellation path the binding cannot receive, or maps an unreachable code; a caller reads the error table and waits for a cancelled outcome that never arrives.
Evidence: docs/design/plugins/SessionFiles.md:76, :105, :267-273.
Fix: Drop cancelled from the row and the flow, or add the token to the binding and the cancellation column.
P3 4. The resource caller matrix still gives Session files to SessionStore
Problem: resource-faces.md:637 still lists "SessionStore Session files and command output" with createDirectory, replace, list, remove and execHost.removeOutputDirectory. This PR makes SessionFiles the file owner (SessionFiles.md:5-11), whose dependency uses FileStorage's write, import, create_directory, list and remove; replace is the old fsHost spelling the FileStorage contract replaces. The SessionFiles supersedes list does not cover this row.
Failure scenario: A caller consulting the matrix wires Session file writes to SessionStore and uses replace, while the SessionFiles contract has no such dependency and FileStorage (PR #2080) does not publish replace.
Evidence: docs/design/resource-faces.md:637; docs/design/plugins/SessionFiles.md:5-11, :64, :128-132.
Fix: Name SessionFiles in the owner column and use the FileStorage operations; leave command output with its owners.
P3 5. The English SessionTitle diagrams still use the old read and write names
Problem: The prose and A.2 now use store.title and setTitle(id, change), but the flowchart at :117 is labelled "setTitle with revision" and the sequence diagrams read metadata at :173, :194, :257 and :283. The owner has no metadata operation and no revision argument.
Failure scenario: A reader of the diagrams implements a metadata method or a revision-checked setTitle that the operation table and the owner do not have.
Evidence: docs/design/plugins/SessionTitle.md:117, :173, :194, :257, :283, :385-386.
Fix: Use title and setTitle(id, change) in the labels.
Cross-PR and main
- The PR is open, not draft, mergeable, at c6d1dae; main is 5930539 and the merge base is also 5930539, so the full diff is the 27-file, +1485/-754 change above.
git merge-tree --write-tree origin/main HEADis clean. - The PR body lists the current sibling heads (#2080 ed23162, #2092 43f132d, #2093 4557d0b, #2098 c3acab3, #2099 8f440bd); the stale-head citation from the prior round is fixed.
git merge-tree --write-tree HEAD <sibling>still conflicts with every sibling in the shared pointer rows: #2080 and #2098 inresource-owner-operations.md,plugins/README.md,resource-faces.md,service-faces.md; #2092 inservice-faces.md; #2093 inplugins/README.md,resource-faces.md,service-faces.md; #2094 inoverview.md,plugins/README.md,service-faces.md; #2096 inresource-owner-operations.md,plugins/README.md,ImageUnderstanding.md; #2099 inresource-owner-operations.md,plugin-contract.md,plugins/SessionTitle.md,resource-faces.md. The merge order in the body covers them; no resolution is shown.- #2099 also rewrites
SessionTitle.mdandplugin-contract.md, so the title rows are the likely conflict when it lands after this PR.
Verification
- PR state before drafting: head c6d1dae, OPEN, not draft, MERGEABLE, clean worktree.
- CI at c6d1dae:
changes,static-checks,verify (linux),macos-nativeandci-okpass; the other jobs are skipped. LC_ALL=en_US.UTF-8 node scripts/adr-check.mjs --base origin/main: passed for 27 changed files.git diff --check origin/main...HEAD: clean.- A relative-link scan over the 27 changed files checked 1232 links and found no new missing target. One pre-existing anchor miss remains in
native-storage-format.md(a link to section 5 oftimeline-branches.mdwhose heading is English in that file); the PR does not touch that line. - No Rust build or test was run; the head changes no code.
Unverified
- The four binding appendices were not compiled.
- The sibling conflicts were checked with merge-tree at the current heads; no merge was performed.
- The inline anchors were checked against the local diff hunks at c6d1dae.
|
|
||
| | Store answer | Owner code | Caller next step | | ||
| | --- | --- | --- | | ||
| | `invalid` | `worktree_invalid` | Fix the task id or root; if the root is under a registered directory, call `removeWorktree` | |
There was a problem hiding this comment.
P2: this row maps every store invalid to worktree_invalid, but SessionStore.md:210 says an invalid caused by a path being removed is worktree_in_use at the worktree client. A second worktree.remove on an in-flight path then tells the operator to fix the task id instead of retrying. Add a separate row for the registered-path invalid and map it to worktree_in_use.
| | `not_found` (unregistered removal only) | `worktree_not_found` | The directory is already gone; nothing to retry | | ||
| | `in_use` | `worktree_in_use` | Delete the Session or stored workspace that uses the directory, then retry | | ||
| | `rejected` with reason `git` | `worktree_git_failed` | Report Git's message; the directory and record stay | | ||
| | `rejected` with reason `cancelled` | `worktree_interrupted` | Retry the removal on the same generation | |
There was a problem hiding this comment.
P2: this maps a cancelled Git step to worktree_interrupted, but the remove rows at :74 and :116 say a started removal reports worktree_git_failed; the binding and the SessionStore example at SessionStore.md:93 pass the token into the Git step, so cancelled is reachable. Also :90 maps store closed to worktree_store_failed while the error table at :104 says a generation close is worktree_interrupted. Pick one code per condition.
| - A branch is kept when `remove` deletes a worktree: committed content must not disappear with the directory, and `worktree.list` reports it. | ||
| - `discard` is not cancellable: a cancelled Session creation still has to settle what the owner made. A store refusal (`closed` or `storage`) leaves the directory and branch in place; the caller reports it. The preparation is dropped with the generation, so the directory is unregistered and `remove` by task id is the retry path on the replacement generation. | ||
| - Unregistered directories are never pruned: the owner has no record to age, so only an explicit `remove` by task id deletes them. | ||
| - A creation registers its selected root in the store's creating set before it makes the directory; a removal that meets the registration is refused, and a failed creation hands the registration to the removing set so its own cleanup is not blocked. The set is in memory; a process death leaves the directory removable by task id. |
There was a problem hiding this comment.
P2: this says a creation registers its root in the store's creating set before it makes the directory and hands the registration to the removing set, but no store operation does that: the table at SessionStore.md:110-131 has none, store.create runs after the directory exists, and CreatedWorktree at :189-196 carries no handle. The current code's begin_worktree_creation (crates/dim-app-server/src/storage/timeline.rs:2162-2182) returns the guard this text assumes. Name the operation and the handover, or the removal race stays open.
| let cancelled = cancelled.clone(); | ||
| Box::pin(async move { git_remove(&root, force, &cancelled).await }) | ||
| }); | ||
| store.removeWorktree(Directory { repository, root }, remove).await?; |
There was a problem hiding this comment.
P2: this call omits the caller. The binding at :519-524 takes caller: &Ctx first, and the create, fork and setTitle examples pass ctx at :59, :73 and :84. Use store.removeWorktree(ctx, Directory { repository, root }, remove).await?.
| - `create` takes the caller's already-validated configuration; `fork` reads the source text itself and calls the caller's text step under the fork's exclusion, so the lifecycle owner's `initialTitle` decision cannot race the copy and the copied bytes stay the source's text. | ||
| - `delete` does not close the Session, remove its Agent admission slot or remove the worktree: closing is Agents', and a managed worktree is removed by ManagedWorktrees under `removeWorktree`. | ||
| - `setTitle` runs the caller's change under the owner's serialization: the change only computes the next title from the current title and revision, and returns its own refusal; the reply may be lost, so the caller re-reads rather than assumes failure. | ||
| - `removeWorktree` serves both a recorded directory and a directory a failed creation left without a record (ManagedWorktrees' `discard`); the record is deleted only when it exists, and the reply says whether one was deleted. It runs ManagedWorktrees' removal step under the Session exclusion: the checks and the record deletion cannot interleave with a Session creation that would point into the removed root. A failed or cancelled step keeps the record and clears the registration. |
There was a problem hiding this comment.
P2: this sentence and :87, :90, :200 and :242/:246 say the callback runs under the exclusion and a concurrent creation waits, while :210 says the exclusion is released before the callback and create is refused invalid while a root is registered. The callback has no time bound, so holding the lock blocks creation and fork for the whole recursive deletion. Align these with :210.
| @@ -215,7 +214,7 @@ sequenceDiagram | |||
| R->>Meta: setTitle(expected r, manual) | |||
| Meta-->>R: r+1 | |||
| G->>Meta: setTitle(expected r, auto) | |||
There was a problem hiding this comment.
P2: this diagram still sends setTitle(expected r, auto) and expects a revision, while section 3.2 in the same file now says a rejected change discards and the English contract uses setTitle(id, change) (SessionStore.md:124). The zh mirror still defines the revision-checked interface in sections 1 to 3; mirror the English sweep.
| @@ -176,17 +121,7 @@ Rpc 从不调用 `setTitle`,也不新增方法。各错误到达客户端的 | |||
| | SessionStore 或 SqliteStorage 重载 | 按 §6 了结。`sessionMetadata` 的使用方随 SessionStore 重载([ADR 002](../../adr/002-plugin-scope.md) D3),SessionTitle §1 已接受。SessionStore 只随没有依赖的 SqliteStorage 重载 | | |||
There was a problem hiding this comment.
P2: the zh mirror still names sessionMetadata and the revision-checked write in sections 1, 2, 3, 8, 9, 12 and 17, while its own banner at :3 and the English file state that interface is superseded. A reader following this line injects a service the owner no longer provides. Replace the old interface text with the store face, not only the operation sections.
|
Closing as part of abandoning the owner-split experiment. |
Refs #2018 · Refs #2015
Summary
Target contracts for the session storage board under design rules §7: responsibility split, caller examples, operations with cancellation and error kinds, flows that settle each resource, exceptions with reasons, rule check and requirements raised to mechanism owners.
storename. TheStore,SessionMetadataandWorktreeAssociationswrappers are replaced by the owner's own operations; the worktree removal is one registration lifecycle: the store checks and registers the root under the Session exclusion, releases it, runs the caller's removal step in the owner's task, and re-takes the exclusion to delete the record; overlaps answerin_use; a creation registers withbeginWorktreeCreationand hands over withremoveCreatedWorktree.forkreads the source configuration text itself and takes the target text from a caller callback;sessionConfigTextis removed.sessionFilesname, marked on the owner type; the read is whole within the owner's limit; the wrapper type and the trait are deleted.managedWorktreesname, as a data face;removecomposes the store'sremoveWorktreewith this owner's Git step as the callback.sqliteStoragename. The Settings, Provider, Agent record and Timeline transactions are crate-private implementations of their data owners; the file-ownership rows are SessionFiles' private operations. The public face isstorageReportand the offline operations.The delivery part (deletion list, caller migration, implementation task, acceptance) is 目标契约:交付部分.
Merge order
#2029 → #2080 → #2091/#2092/#2093 → #2094 → #2096 → the rest.
Sibling heads this change is aligned with: #2080
5b56b495, #209243f132d, #20934557d0b, #2098c3acab356, #20998f440bde7.Worktree removal lifecycle
Removal is one lifecycle for every caller: under the Session exclusion the store re-checks and registers the resolved root, releases the exclusion, runs the delete step in the owner's task (a caller leaving does not stop it), and re-takes the exclusion to delete the record and clear the registration. Overlapping create/fork/associate/remove refuse a path at, under or above a registered root with
in_use; unrelated work proceeds. A creation registers its selected root withbeginWorktreeCreation(acreationIdbound to the calling row);createends it, and a failed creation hands it to the removal set withremoveCreatedWorktree.