Files
TotoroandTotoro-qaq d5cc9158b3 feat(projects): let owners review proposed rule changes (#8862)
* feat(projects): let owners review proposed rule changes

* fix(projects): retain rule review decisions across working-set limits

* fix(projects): preserve independent sources for identical facts

* fix(projects): keep independent facts between repeated rule excerpts

* fix(projects): retain independent evidence across extraction passes

* fix(projects): identify matched rules in the extraction prompt

---------

Co-authored-by: Totoro-qaq <279883115+Totoro-qaq@users.noreply.github.com>
2026-12-02 21:22:13 +08:00

16 KiB
Raw Permalink Blame History

Projects

Projects group related conversations under a shared name, instructions, and document shelf.

A conversation joins a project at creation time (when a project is selected) or later through the move menu. Runs never modify membership: submitting a message cannot assign or reassign a conversation. Moving a conversation out of a project keeps it unassigned until it is explicitly moved again.

Moving a conversation refreshes its header affiliation as well as the project lists, including when an older metadata request is still in flight.

Projects require the current database tables and columns. A database stamped 0019_thread_incarnations from the older 0018-based rollout is rejected at startup if the project schema is missing. Follow the offline database recovery procedure before starting this build against that database.

Project instructions

Each project stores free-form instructions — background, conventions, and constraints that apply to every conversation in the project — editable on the project page's Instructions tab with a live byte counter. When a run starts on a member thread, the Gateway pins the project's current state once and renders the instructions as a bounded, request-scoped <project> block for that run only: the block never enters the system prompt or persisted history, and every new run sees the latest saved instructions. Instructions are capped at projects.instructions_max_bytes UTF-8 bytes (default 8192, range 256–262144); multi-byte characters count as their UTF-8 byte length. Oversized instructions are rejected with a 422 at write time and are never silently truncated.

If another tab changes the instructions or promotes a memory while you are editing, the editor keeps your draft and shows the saved text below it. Merge the changes you want to keep into your draft, confirm that you have reviewed the saved version, then save. If the editor cannot load the saved version after a rejected save, use Reload saved instructions. Your draft stays in the editor while you retry, and Save stays disabled until you can review the saved version.

Project memory

With DeerMem automatic memory enabled, project conversations also accumulate short project facts in a separate pool (up to 30 facts and 2 KiB of rendered context). The same extraction call classifies user and project facts; personal facts keep their existing user scope. Unassigned conversations have no project pool. Project facts are pinned with the instructions at run start and are used only inside that project. They are background context, subordinate to explicit instructions and the current request.

An active project pool keeps the shared extraction call enabled for every eligible batch, even when the user-memory pre-screen would skip it: that pre-screen does not assess project facts. Existing project facts also add input tokens. Turn off automatic extraction in the project's Instructions tab to stop this project-specific work while retaining its stored facts.

Project writes are best-effort after the user pool commits. If the project write fails, the batch is consumed so later turns do not replay the paid model call or the committed user writes. The failure is logged and reported separately as project_memory_apply_success: false; success still describes the user-pool commit. A failed project update is not automatically retried.

The Instructions tab shows these facts below the editor. Delete incorrect or outdated facts, turn automatic extraction off, or move a fact into instructions. Turning extraction off preserves existing facts and their injection; deleting one removes it from subsequent runs. Promotion saves the instruction and removes the fact atomically; save any pending instruction edits first. User edits fence already-queued extraction so old results cannot undo them. Archived projects retain their facts for reading and do not collect new ones.

Confirmed rule changes

Open Projects → Instructions → Project memory and choose Track as rule beside a fact you want to manage. Tracked rules stay visible in this section after they leave the ordinary memory list.

When extraction links a change to a tracked rule and the Gateway can verify the original user message, Changes to review shows the current rule and your words side by side. The old rule applies while you review the suggestion. Choose an effective date that has already arrived. Use Replace rule with an exact excerpt of the quoted decision, Withdraw only when the decision has no successor, or Ignore suggestion to keep the current rule. An uncertain date or replacement is left for you to fill in. A hidden or deleted source cannot be used to confirm a suggestion.

A project owner can track a project memory fact and approve its retirement through PUT /api/projects/{project_id}/memory/{fact_id}/lifecycle. A change applies to the selected rule's full scope. Use a separate tracked fact for an adjacent procedure or an exception with narrower conditions.

  1. Use operation: track to keep an admitted project's rule addressable after the working set trims it. Supply effective_on if the original start date is known. When extraction explicitly pairs a replacement with a tracked fact ID, the owner must confirm the change. A paraphrase of the same decision can also be held for review. An unrelated fact can stay in ordinary project memory even between two copies of a decision in the same message. Repeating the proposed replacement in that message leaves it pending. A separate extraction can independently support the fact, including a spelling that differs in case. The extractor receives the ID and text of each active rule verified for the originating turn, even after the ordinary memory list trims it.
  2. Use operation: retire with effective_on, source_thread_id, source_message_seq and an exact source_quote from that user message. The source must be visible inside the same project. For a full replacement, supply successor_fact_id for an accepted fact, or successor_text for an exact excerpt of the decision quote. The response returns the confirmed successor_fact_id. A new excerpt enters the same bounded working set as other facts. Omit both successor fields for a withdrawal.

After a reload, owners with runs:read can use GET /api/projects/{project_id}/memory to find a retained rule by its text and ID, even after it leaves the working set. retained_rules reports active, withdrawn and superseded versions, their dates and recorded successor IDs. Text is null when its sources cannot be verified. Active rules come first. The default page holds 30 rules. Set rules_limit from 1 to 100 and pass next_rules_offset as rules_offset to fetch another page.

Each page also returns source-verified pending_rule_changes. The same rules_limit and rules_offset apply to this list. When next_proposals_offset is set, pass it as rules_offset to read the next page of suggestions, even if the tracked-rule history is already exhausted. An unresolved suggestion stays available while its rule is active. To confirm one, include its proposal_id and the quoted message and sequence displayed on the card. To ignore it, use DELETE /api/projects/{project_id}/memory/rule-proposals/{proposal_id}. Later suggestions do not undo that choice when the same source is reprocessed.

The ordinary facts list and its promotion action exclude retained versions and case-insensitive copies of their text. Deleting a retained ID also removes its ordinary copies in the same transaction.

The Gateway stores approved versions and their sources alongside the project's working set. A later decision can attach a successor to a withdrawal while preserving the interval during which the old rule was unavailable. A lookup crossing that transition verifies both decisions. When a user asks for the rule in effect as of YYYY-MM-DD, 截至 YYYY-MM-DD, or YYYY-MM-DD 当时, the Gateway looks up that date. Current queries use the current UTC day. With an unknown initial effective date, the initial version covers the period before its first recorded retirement.

Resumed runs recover the active turn's requested date from the selected checkpoint. Clarification replies use the originating task and the user's answers, including the latest explicit date. If compaction removed an earlier question, the Gateway follows the card or reply in that checkpoint back through the owner's visible transcript. Scheduled runs use the owner's current permission to read runs.

New runs select at most two distinct rules. Historical wording participates in ranking, and versions in the same chain share a place. The highest-ranked withdrawn or unavailable rule produces a status and any accessible withdrawal evidence. The lookup stops before it can supply values from a different rule. Moving or deleting a source thread makes the corresponding evidence unavailable to later runs. Deleting the project memory fact by its ID also removes its retained version. Project memory continues to follow the global and per-agent injection settings.

Document shelf

Each project has a document shelf for files the whole project shares, managed from the project page's Documents section:

  • Upload a file (button or drag-drop, one file per request). Shelf size limits reuse uploads.max_file_size (default 50 MiB); re-uploading identical content returns the existing entry instead of creating a duplicate. Oversized uploads return 413; deduplicated uploads return 200. Staging cleanup failures are logged without replacing these outcomes or a missing, foreign, or archived project's 404 response. Cancelling a shelf upload discards its partial file after any active disk operation finishes; waiting for further upload data remains cancellable.
  • List entries with name, size, modified time, and provenance (uploaded vs. saved from a conversation), and preview or download any entry.
  • Save to project from a thread file: the read-only conversation-files browser below the shelf lists member threads' uploads and outputs, each with a Save to project action.
  • Attach to thread: copy a shelf file into a thread's uploads through the normal ingestion pipeline, so the conversation can work with it directly. The successful server response closes the picker and navigates to the target conversation even when the browser blocks or fills sessionStorage. The staged attachment handoff is best-effort in that case, so a blocked storage area can prevent the attachment chip from surviving the route change or a reload. If the browser temporarily blocks reading the pending list, adding a document or clearing sent attachments leaves the saved list intact.

New shelf names, including explicit upload name and promotion shelf_name, follow ordinary upload filename validation. Names containing NUL, Windows reserved device names (such as CON.txt), or trailing dots are rejected with 400 before bytes are staged.

On native Windows, the document shelf uses extended-length filesystem paths so deep workspace directories and long filenames can be uploaded, downloaded, restored, and purged without enabling the system-wide long-path setting. Filesystem limits on individual path components still apply.

Runs on member threads also receive a bounded <documents> index rendered per run from the pinned snapshot (capped by projects.shelf_index_max_entries and projects.shelf_index_max_bytes), and the agent can page the shelf and read documents with the list_project_documents and read_project_document tools.

Document character counts use a bounded, thread-safe cache; concurrent reads do not serialize full file scans behind its cache lock.

Shelf conversion cleanup failures are logged without replacing the read result or its original error. Cancelled reads wait for their staging cleanup to finish; files that cannot be removed remain eligible for the existing retention sweep.

Document summaries are enabled by default for newly uploaded or promoted shelf files (projects.summaries_enabled: false disables generation). Each eligible file uses a separate best-effort summary call; existing files are not backfilled. The document shelf remains user-curated.

Archive read semantics

Archiving a project freezes writes but keeps reads. Threads in an archived project still run and still receive the project's instructions and shelf index, and the shelf remains fully readable: listing, preview/download, the conversation-files browser, and attach-to-thread all keep working. Uploads, save-to-project, and moving individual shelf files to trash require an active project, and a trashed document cannot be restored into an archived one. Deleting an archived project remains allowed and moves its whole shelf to trash.

Trash

Deleting a shelf document moves it to trash instead of erasing it: the entry keeps its bytes and a snapshot of its origin project for projects.trash_retention_days (default 30) before the retention sweep may purge it permanently. The /workspace/trash page — reachable from the project page's Documents section and the sidebar Projects header — lists trashed documents with their origin project and remaining retention, with per-entry Restore and Delete permanently actions plus an Empty trash action that permanently deletes every document in the trash — immediately, not after the retention window; the window only bounds how long an entry may sit there before the retention sweep reclaims it. Restore returns the document to its origin project, or to a project you pick when the origin is gone or archived; if the target already holds an identical active file, the entries merge. Deleting a project moves its entire shelf to trash in the same step.

If the retention configuration cannot be read, automatic cleanup is deferred and the trash listing remains available. Cleanup resumes with the current configured retention window once the configuration is readable again.

The Gateway removes temporary uploads from .staging after 24 hours, including for deleted projects. A fresh or older SQLite database can share the same data directory and lack records for documents that still exist. The storage scan therefore preserves original and converted files in published document directories. If an upload crashes after placing its original but before the database commit, that directory can remain on disk.

A restore that merges identical documents can also leave a directory behind. The merge commits before the Gateway removes the discarded copy. If removal fails, the target document stays available and the source has no Trash entry to retry. Look for Merge cleanup failed for discarded document in the Gateway log. Its user_id and stored_relpath identify the directory under DEER_FLOW_HOME/users/<user_id>/projects/<stored_relpath>. The log also includes the filesystem error.

Before removing that directory, check the project_documents table in every database that uses this storage for the logged user_id and stored_relpath, including trashed rows. If any database still references it or cannot be checked, keep the directory. Once all references are ruled out, remove only the logged document directory. Other copies can share its parent hash directory.

Trash expiration still uses the state in the connected database. To use the same projects and trash history from multiple working directories, set database.sqlite_dir to the absolute directory containing the original deerflow.db.

Permanently deleting read-only documents also works on Windows. A file that is already missing does not block deletion; other filesystem errors keep the entry in Trash for retry. Permissions on symlink targets are preserved.