fix(tables): the tables the assistant writes are written by nobody else; a person's save sets no field the server decides #122

Merged
james.maes merged 1 commits from fix/system-written-tables-refuse-user-writes into develop 2026-11-21 06:11:33 +00:00
Owner

The rule

Every table of the assistant has a decision about who writes it, by operation, in one place (AssistantTableWrites). A table without a decision cannot be built.

Tables A person, through a table route Written by
assistant_policy, assistant_provider, assistant_model, assistant_model_price, assistant_profile, assistant_skill, assistant_profile_skill, assistant_data_access, assistant_rag_source, assistant_scheduled_task, assistant_budget, assistant_budget_override insert, update, delete an administrator, on the record screens
assistant_conversation update, delete started by the assistant's own API; renamed, pinned, archived and deleted by its owner
assistant_message, assistant_turn, assistant_turn_event, assistant_tool_call, assistant_pending_action, assistant_pending_action_claim, assistant_feedback, assistant_client_error, assistant_data_audit, assistant_scheduled_run nothing the assistant (AssistantStore): the turn engine, the tool-call service, the assistant's own API for a rating and a client error, the scheduler
assistant_usage, assistant_usage_daily, assistant_budget_usage, assistant_budget_event nothing the assistant: the accounting the spending limits are counted from

How it is enforced

By the assistant itself, on any QQQ version:

  • a table has no capability (insert, update, delete) for what a person may not do to it, so the metadata a screen reads offers no button for it and QQQ defines no bulk action for it;
  • the permission checker of every table of the assistant refuses the insert, update or delete a table route is about to make, for every person, with 403 and a message that says why ("Rows of Assistant Tool Call are written by the assistant; they cannot be changed."). assistant_scheduled_run, which needs no permission to read, gets a checker of its own for this.

The assistant's own writes are made by AssistantStore, in code, never through a table route, and are unchanged. Deleting a conversation still deletes what belongs to it; retention still removes history.

A person's save sets no field the server decides

A field that is not editable (the id, the date a row was created, who granted an override, a provider's health and test results, a model's test result, what a knowledge source indexed, a scheduled task's approval, next run and last run) is taken out of a person's save of a settings table before a rule sees it or it is stored (StoredRecords.ofSave, called first by every settings customizer; assistant_policy, which had no customizer, gets one for it).

It is taken out, not refused: a client that sends a whole record back keeps working, and what it sent for such a field changes nothing. The primary key of an update stays (the route takes it from the path), and so do the dates QQQ itself sets on the save. A save is a person's when its input source is USER, which every table route sets; the assistant's own saves set these fields as before.

Changed for administrators

Rows of assistant_message, assistant_turn, assistant_turn_event, assistant_tool_call, assistant_feedback, assistant_client_error, assistant_usage, assistant_usage_daily, assistant_pending_action and assistant_pending_action_claim had a Delete button on their record screens. They no longer have one. History is removed by the retention process, and a conversation with everything that belongs to it by deleting the conversation.

Tests

Through the real table routes against the fixture application:

  • TablesWrittenByTheAssistantTest: for each of the fourteen tables, the administrator of the assistant and an ordinary user are each refused an insert, an update, an update that changes nothing, an update of the modify date and a delete, with 403, and every row is exactly what it was; the metadata offers no write and no bulk action; a conversation is renamed and deleted by its owner and not added; the assistant's own work (an answer with a tool call, a change proposed and confirmed, a rating, a client error) still writes its tables.
  • AssistantTableWritesTest: every table has a decision and is built to it, and a table without one is not built; the checkers refuse every kind of write and nothing else; every table a person edits takes the server's fields out of a person's save and leaves them in the assistant's own.
  • Server-decided fields over the routes in BudgetEditOverHttpTest, RecordEditsOverHttpTest, AssistantSettingsTest, RagTest and ScheduledTasksTest.

./mvnw verify: BUILD SUCCESS, 699 tests in qbit-assistant, coverage checks met.

For a host

See UPGRADE.md. No schema or configuration change. A host is affected only if its own code wrote rows of the tables the assistant writes through a table route as a person, or if it replaced the permission rules of the assistant's tables.

🤖 Generated with Claude Code

## The rule Every table of the assistant has a decision about who writes it, by operation, in one place (`AssistantTableWrites`). A table without a decision cannot be built. | Tables | A person, through a table route | Written by | |---|---|---| | `assistant_policy`, `assistant_provider`, `assistant_model`, `assistant_model_price`, `assistant_profile`, `assistant_skill`, `assistant_profile_skill`, `assistant_data_access`, `assistant_rag_source`, `assistant_scheduled_task`, `assistant_budget`, `assistant_budget_override` | insert, update, delete | an administrator, on the record screens | | `assistant_conversation` | update, delete | started by the assistant's own API; renamed, pinned, archived and deleted by its owner | | `assistant_message`, `assistant_turn`, `assistant_turn_event`, `assistant_tool_call`, `assistant_pending_action`, `assistant_pending_action_claim`, `assistant_feedback`, `assistant_client_error`, `assistant_data_audit`, `assistant_scheduled_run` | nothing | the assistant (`AssistantStore`): the turn engine, the tool-call service, the assistant's own API for a rating and a client error, the scheduler | | `assistant_usage`, `assistant_usage_daily`, `assistant_budget_usage`, `assistant_budget_event` | nothing | the assistant: the accounting the spending limits are counted from | ## How it is enforced By the assistant itself, on any QQQ version: - a table has no capability (insert, update, delete) for what a person may not do to it, so the metadata a screen reads offers no button for it and QQQ defines no bulk action for it; - the permission checker of every table of the assistant refuses the insert, update or delete a table route is about to make, for every person, with 403 and a message that says why ("Rows of Assistant Tool Call are written by the assistant; they cannot be changed."). `assistant_scheduled_run`, which needs no permission to read, gets a checker of its own for this. The assistant's own writes are made by `AssistantStore`, in code, never through a table route, and are unchanged. Deleting a conversation still deletes what belongs to it; retention still removes history. ## A person's save sets no field the server decides A field that is not editable (the id, the date a row was created, who granted an override, a provider's health and test results, a model's test result, what a knowledge source indexed, a scheduled task's approval, next run and last run) is taken out of a person's save of a settings table before a rule sees it or it is stored (`StoredRecords.ofSave`, called first by every settings customizer; `assistant_policy`, which had no customizer, gets one for it). It is taken out, not refused: a client that sends a whole record back keeps working, and what it sent for such a field changes nothing. The primary key of an update stays (the route takes it from the path), and so do the dates QQQ itself sets on the save. A save is a person's when its input source is `USER`, which every table route sets; the assistant's own saves set these fields as before. ## Changed for administrators Rows of `assistant_message`, `assistant_turn`, `assistant_turn_event`, `assistant_tool_call`, `assistant_feedback`, `assistant_client_error`, `assistant_usage`, `assistant_usage_daily`, `assistant_pending_action` and `assistant_pending_action_claim` had a Delete button on their record screens. They no longer have one. History is removed by the retention process, and a conversation with everything that belongs to it by deleting the conversation. ## Tests Through the real table routes against the fixture application: - `TablesWrittenByTheAssistantTest`: for each of the fourteen tables, the administrator of the assistant and an ordinary user are each refused an insert, an update, an update that changes nothing, an update of the modify date and a delete, with 403, and every row is exactly what it was; the metadata offers no write and no bulk action; a conversation is renamed and deleted by its owner and not added; the assistant's own work (an answer with a tool call, a change proposed and confirmed, a rating, a client error) still writes its tables. - `AssistantTableWritesTest`: every table has a decision and is built to it, and a table without one is not built; the checkers refuse every kind of write and nothing else; every table a person edits takes the server's fields out of a person's save and leaves them in the assistant's own. - Server-decided fields over the routes in `BudgetEditOverHttpTest`, `RecordEditsOverHttpTest`, `AssistantSettingsTest`, `RagTest` and `ScheduledTasksTest`. `./mvnw verify`: BUILD SUCCESS, 699 tests in `qbit-assistant`, coverage checks met. ## For a host See `UPGRADE.md`. No schema or configuration change. A host is affected only if its own code wrote rows of the tables the assistant writes through a table route as a person, or if it replaced the permission rules of the assistant's tables. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
james.maes added 1 commit 2026-11-21 04:29:21 +00:00
Every table of the assistant has a decision about who writes it, by
operation (AssistantTableWrites); a table without one is not built. The
settings are edited by an administrator on a record screen. A conversation
is renamed, archived and deleted by its owner, and started only by the
assistant. Everything else (what was said and done, and what was spent) is
written by the assistant only.

The assistant enforces the decision itself, on any QQQ version: a table has
no capability for what a person may not do to it, so a screen is offered no
button and QQQ defines no bulk action; and the permission checker of every
table refuses the insert, update or delete a table route is about to make,
for every person, with 403 and a message that says why. The assistant's own
writes go through AssistantStore, in code, and are unchanged.

A person's save of a settings table sets no field that is not editable (the
id, the create date, who granted an override, health and test results, index
counters, a scheduled task's approval and run fields): StoredRecords.ofSave,
used by every settings customizer, takes them out of a USER save before a
rule sees them. A client that sends a whole record back keeps working.

Tests go through the real table routes against the fixture application.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
james.maes merged commit fe39c2de0b into develop 2026-11-21 06:11:33 +00:00
Sign in to join this conversation.