askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
rules.json · 6.2 KB · 74 lines
| 1 | { |
| 2 | "retracted": [ |
| 3 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update", "delete"], "collection": "stock_moves", "row_filter": {"owner_id": "$user_id"}, "reason": "signed-in users manage the stock moves they recorded. stock_moves is append-mode and immutable in spirit (see schemas/stock_moves.json) but this platform has no separate create-only permission action -- update/delete stay owner-scoped rather than granted to everyone, the same posture app-thread's append-mode thread_comments takes"}, |
| 4 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_products", "reason": "no package ships this object, so the grant made whatever was later created under the id runnable without a rule written for it (bug-reports/2026-11-28-06-14-43)"}, |
| 5 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_locations", "reason": "no package ships this object, so the grant made whatever was later created under the id runnable without a rule written for it (bug-reports/2026-11-28-06-14-43)"}, |
| 6 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_product_view", "reason": "an earlier version's grant for an object this package no longer ships"} |
| 7 | ], |
| 8 | "rules": [ |
| 9 | {"effect": "deny", "principal": "owner_fallback", "actions": ["delete"], "collection": "backorders", "reason": "a backorder is never deleted; cancelled says so out loud. No rule grants this; the engine's owner fallback did, to whoever the row's owner key names. This switches the fallback off for these actions only: an explicit grant still grants, and admins and in-process writers are unaffected"}, |
| 10 | {"effect": "deny", "principal": "owner_fallback", "actions": ["delete"], "collection": "reorder_suggestions", "reason": "a suggestion is answered, never deleted. No rule grants this; the engine's owner fallback did, to whoever the row's owner key names. This switches the fallback off for these actions only: an explicit grant still grants, and admins and in-process writers are unaffected"}, |
| 11 | { |
| 12 | "effect": "allow", |
| 13 | "principal": "registered", |
| 14 | "actions": ["create", "read", "update", "delete"], |
| 15 | "collection": "products", |
| 16 | "row_filter": {"owner_id": "$user_id"}, |
| 17 | "reason": "signed-in users manage the products they created. v1 keeps the catalog owner-scoped like app-invoices; a public read rule for a storefront view is deferred (see dbbasic-package.json)" |
| 18 | }, |
| 19 | { |
| 20 | "effect": "allow", |
| 21 | "principal": "registered", |
| 22 | "actions": ["create", "read", "update", "delete"], |
| 23 | "collection": "locations", |
| 24 | "row_filter": {"owner_id": "$user_id"}, |
| 25 | "reason": "signed-in users manage the warehouse/zone/aisle/shelf/bin (and virtual customer/supplier) locations they created, same owner-scoped posture as products" |
| 26 | }, |
| 27 | { |
| 28 | "effect": "allow", |
| 29 | "principal": "registered", |
| 30 | "actions": ["create", "read"], |
| 31 | "collection": "stock_moves", |
| 32 | "row_filter": {"owner_id": "$user_id"}, |
| 33 | "reason": "signed-in users record stock moves and read the ones they recorded. Never update or delete: stock levels ARE the moves, so editing or deleting one rewrites what is on the shelf with nothing to show for it, and the correction is a new compensating move. hook_stock_moves used to refuse a non-admin's edit or delete; this rule and the owner-fallback deny below are that refusal" |
| 34 | }, |
| 35 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "stock_moves", "reason": "the stock ledger is append-only: stock levels are the moves. No rule grants update or delete; the engine's owner fallback did, to whoever the row's owner key names. This switches the fallback off for these actions only: an explicit grant still grants, and admins and in-process writers are unaffected"}, |
| 36 | { |
| 37 | "effect": "allow", |
| 38 | "principal": "registered", |
| 39 | "actions": ["create", "read", "update"], |
| 40 | "collection": "backorders", |
| 41 | "row_filter": {"owner_id": "$user_id"}, |
| 42 | "reason": "signed-in users manage the backorders raised against their own catalogue, same owner-scoped posture as products. No DELETE: a customer who waited and was let down is a fact the shop should still be able to find, and `cancelled` says that out loud where a missing row would say nothing at all" |
| 43 | }, |
| 44 | { |
| 45 | "effect": "allow", |
| 46 | "principal": "registered", |
| 47 | "actions": ["read", "update"], |
| 48 | "collection": "reorder_suggestions", |
| 49 | "row_filter": {"owner_id": "$user_id"}, |
| 50 | "reason": "a suggestion is written by system_reorder_check and ANSWERED by a human -- marked ordered when somebody bought some, dismissed when somebody looked and said no -- so read and update are the whole of what a person needs. No CREATE: a suggestion typed by hand is an observation of a shelf nobody looked at, and the nightly fold is the only thing here that has looked. No DELETE either: the pass keeps one open row per product and refreshes it, so there is nothing to tidy up, and a dismissed row is the record that somebody decided" |
| 51 | }, |
| 52 | { |
| 53 | "effect": "allow", |
| 54 | "principal": "registered", |
| 55 | "actions": ["execute"], |
| 56 | "object_id": "system_reorder_check", |
| 57 | "reason": "an operator who has just set a reorder point should be able to poke the nightly pass without an admin token. It is safe to run by hand for the same reason it is safe to retry: it writes SUGGESTIONS and never a purchase order, it keeps one open row per product and refreshes rather than appends, so the worst a signed-in person can do with it is learn today's answer a few hours early" |
| 58 | }, |
| 59 | { |
| 60 | "effect": "allow", |
| 61 | "principal": "public", |
| 62 | "actions": ["execute"], |
| 63 | "object_id": "site_stock", |
| 64 | "reason": "the stock levels page is public; it shows a sign-in prompt to visitors, and computes the owner-scoped summary itself once signed in (see objects/site/stock.py)" |
| 65 | }, |
| 66 | { |
| 67 | "effect": "allow", |
| 68 | "principal": "registered", |
| 69 | "actions": ["execute"], |
| 70 | "object_id": "action_apply_count", |
| 71 | "reason": "applying a physical count is an ordinary operator verb; the object requires a signed-in identity, stamps the caller as the move's owner, and writes only compensating adjustment moves (never edits)" |
| 72 | } |
| 73 | ] |
| 74 | } |