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 · 19.9 KB · 158 lines
| 1 | { |
| 2 | "retracted": [ |
| 3 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update", "delete"], "collection": "fin_accounts", "row_filter": {"owner_id": "$user_id"}, "reason": "retracted 2026-11-30 (decision 5): the books moved off `registered` to role:finance and role:owner. Was: signed-in users manage the chart of accounts they created"}, |
| 4 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update", "delete"], "collection": "fin_journals", "row_filter": {"owner_id": "$user_id"}, "reason": "retracted 2026-11-30 (decision 5): the books moved off `registered` to role:finance and role:owner. Was: signed-in users manage journals they created, including the draft->posted transition guarded on the schema"}, |
| 5 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update", "delete"], "collection": "fin_journal_lines", "row_filter": {"owner_id": "$user_id"}, "reason": "retracted 2026-11-30 (decision 5): the books moved off `registered` to role:finance and role:owner. Was: signed-in users manage line items on journals they created"}, |
| 6 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update", "delete"], "collection": "fin_recurring", "row_filter": {"owner_id": "$user_id"}, "reason": "retracted 2026-11-30 (decision 5): the books moved off `registered` to role:finance and role:owner. Was: signed-in users manage recurring journal templates they created"}, |
| 7 | {"effect": "allow", "principal": "registered", "actions": ["execute"], "object_id": "action_reverse_journal", "reason": "retracted 2026-11-30 (decision 5): the books moved off `registered` to role:finance and role:owner. Was: reversing a posted journal is the doctrine-correct correction; the object itself enforces owner-or-admin on the target journal"}, |
| 8 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update", "delete"], "collection": "fin_closed_periods", "row_filter": {"owner_id": "$user_id"}, "reason": "retracted 2026-11-30 (decision 5): the books moved off `registered` to role:finance and role:owner. Was: closing a period is creating a row; reopening -- rare and legitimate -- is deleting it, and both are attributed in the change log so 'who reopened March?' has an answer"}, |
| 9 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_accounts", "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)"}, |
| 10 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_journals", "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)"}, |
| 11 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_journal_view", "reason": "an earlier version's grant for an object this package no longer ships"} |
| 12 | ], |
| 13 | "rules": [ |
| 14 | {"effect": "allow", "principal": "role:finance", "actions": ["execute"], "object_id": "action_record_barter", "reason": "booking a barter as a sale and a purchase at fair value through the clearing account is the bookkeeper's and owner's (decision 6, 2026-11-30); the action checks the role too"}, |
| 15 | {"effect": "allow", "principal": "role:finance", "actions": ["execute"], "object_id": "action_record_contra_cogs", "reason": "booking scrap proceeds and vendor rebates against cost of goods is the bookkeeper's and owner's (decision 6, 2026-11-30); the action checks the role too"}, |
| 16 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_record_barter", "reason": "booking a barter as a sale and a purchase at fair value through the clearing account is the bookkeeper's and owner's (decision 6, 2026-11-30); the action checks the role too"}, |
| 17 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_record_contra_cogs", "reason": "booking scrap proceeds and vendor rebates against cost of goods is the bookkeeper's and owner's (decision 6, 2026-11-30); the action checks the role too"}, |
| 18 | {"effect": "deny", "principal": "owner_fallback", "actions": ["read", "update", "delete"], "collection": "fin_accounts", "reason": "the books are the business's, not their row owner's (decision 5, 2026-11-30): the composers stamp a journal with the owner of the payment or invoice it books -- often the customer -- and the engine's owner fallback would let that customer read, edit or delete it. Only role:finance, role:owner and admins keep the books"}, |
| 19 | {"effect": "deny", "principal": "owner_fallback", "actions": ["read", "update", "delete"], "collection": "fin_journals", "reason": "the books are the business's, not their row owner's (decision 5, 2026-11-30): the composers stamp a journal with the owner of the payment or invoice it books -- often the customer -- and the engine's owner fallback would let that customer read, edit or delete it. Only role:finance, role:owner and admins keep the books"}, |
| 20 | {"effect": "deny", "principal": "owner_fallback", "actions": ["read", "update", "delete"], "collection": "fin_journal_lines", "reason": "the books are the business's, not their row owner's (decision 5, 2026-11-30): the composers stamp a journal with the owner of the payment or invoice it books -- often the customer -- and the engine's owner fallback would let that customer read, edit or delete it. Only role:finance, role:owner and admins keep the books"}, |
| 21 | {"effect": "deny", "principal": "owner_fallback", "actions": ["read", "update", "delete"], "collection": "fin_recurring", "reason": "the books are the business's, not their row owner's (decision 5, 2026-11-30): the composers stamp a journal with the owner of the payment or invoice it books -- often the customer -- and the engine's owner fallback would let that customer read, edit or delete it. Only role:finance, role:owner and admins keep the books"}, |
| 22 | {"effect": "deny", "principal": "owner_fallback", "actions": ["read", "update", "delete"], "collection": "fin_closed_periods", "reason": "the books are the business's, not their row owner's (decision 5, 2026-11-30): the composers stamp a journal with the owner of the payment or invoice it books -- often the customer -- and the engine's owner fallback would let that customer read, edit or delete it. Only role:finance, role:owner and admins keep the books"}, |
| 23 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "rates", "reason": "a rate is a historical observation; a restated rate is a new row. 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"}, |
| 24 | { |
| 25 | "effect": "allow", |
| 26 | "principal": "registered", |
| 27 | "actions": [ |
| 28 | "read" |
| 29 | ], |
| 30 | "collection": "denominations", |
| 31 | "reason": "denominations are reference data, not private records: any signed-in user needs to know that BTC divides into eight places in order to render an amount correctly at all" |
| 32 | }, |
| 33 | { |
| 34 | "effect": "allow", |
| 35 | "principal": "registered", |
| 36 | "actions": [ |
| 37 | "create", |
| 38 | "update", |
| 39 | "delete" |
| 40 | ], |
| 41 | "collection": "denominations", |
| 42 | "row_filter": { |
| 43 | "owner_id": "$user_id" |
| 44 | }, |
| 45 | "reason": "operators may add their own units (a gift-card program, a loyalty point, a barter unit) but cannot edit the seeded ones everybody shares" |
| 46 | }, |
| 47 | { |
| 48 | "effect": "allow", |
| 49 | "principal": "public", |
| 50 | "actions": [ |
| 51 | "read" |
| 52 | ], |
| 53 | "collection": "denominations", |
| 54 | "row_filter": { |
| 55 | "is_system": "true" |
| 56 | }, |
| 57 | "reason": "public pages that display money (an invoice pay link, a storefront) must be able to resolve the scale of a standard unit; operator-defined denominations stay behind the sign-in because a custom code can name a business relationship" |
| 58 | }, |
| 59 | { |
| 60 | "effect": "allow", |
| 61 | "principal": "registered", |
| 62 | "actions": [ |
| 63 | "create", |
| 64 | "read" |
| 65 | ], |
| 66 | "collection": "rates", |
| 67 | "reason": "rates are shared observations: any signed-in user may read them (an amount cannot be valued without one) and may record one they fetched. No update or delete -- a restated rate is a new row with a later fetched_at, never an edit to what was recorded at the time" |
| 68 | }, |
| 69 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update", "delete"], "collection": "fin_accounts", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 70 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update", "delete"], "collection": "fin_journals", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 71 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update", "delete"], "collection": "fin_journal_lines", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 72 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update", "delete"], "collection": "fin_recurring", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 73 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update", "delete"], "collection": "fin_closed_periods", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 74 | {"effect": "allow", "principal": "role:finance", "actions": ["execute"], "object_id": "action_reverse_journal", "reason": "reversing a posted journal is the doctrine-correct correction, and the bookkeeper's and owner's to make (decision 5)"}, |
| 75 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read", "update", "delete"], "collection": "fin_accounts", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 76 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read", "update", "delete"], "collection": "fin_journals", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 77 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read", "update", "delete"], "collection": "fin_journal_lines", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 78 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read", "update", "delete"], "collection": "fin_recurring", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 79 | {"effect": "allow", "principal": "role:owner", "actions": ["create", "read", "update", "delete"], "collection": "fin_closed_periods", "reason": "the chart of accounts and the journals are the business's books, kept by its bookkeeper (role:finance) and its owner (role:owner); decision 5, 2026-11-30. They were every signed-in user's own rows, so a customer could keep a chart and post journals, and read the journals the books composed for their own payments"}, |
| 80 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_reverse_journal", "reason": "reversing a posted journal is the doctrine-correct correction, and the bookkeeper's and owner's to make (decision 5)"}, |
| 81 | { |
| 82 | "effect": "allow", |
| 83 | "principal": "public", |
| 84 | "actions": [ |
| 85 | "execute" |
| 86 | ], |
| 87 | "object_id": "site_trial_balance", |
| 88 | "reason": "the trial balance page is public; it shows a sign-in prompt to visitors and the page itself scopes the report to the signed-in owner (see objects/site/trial_balance.py)" |
| 89 | }, |
| 90 | { |
| 91 | "effect": "allow", |
| 92 | "principal": "public", |
| 93 | "actions": [ |
| 94 | "execute" |
| 95 | ], |
| 96 | "object_id": "site_setup_accounts", |
| 97 | "reason": "setup-accounts is public execute like every other finance page object; the object itself requires a signed-in identity and verifies the entity belongs to the caller before creating any account" |
| 98 | }, |
| 99 | { |
| 100 | "effect": "allow", |
| 101 | "principal": "public", |
| 102 | "actions": [ |
| 103 | "execute" |
| 104 | ], |
| 105 | "object_id": "site_statements", |
| 106 | "reason": "the statements page is public execute like every other finance page object; it shows a sign-in prompt to visitors and scopes both statements to the signed-in owner (see objects/site/statements.py)" |
| 107 | }, |
| 108 | { |
| 109 | "effect": "allow", |
| 110 | "principal": "registered", |
| 111 | "actions": [ |
| 112 | "create", |
| 113 | "read", |
| 114 | "update" |
| 115 | ], |
| 116 | "collection": "expenses", |
| 117 | "row_filter": { |
| 118 | "owner_id": "$user_id" |
| 119 | }, |
| 120 | "reason": "people record and submit their own spending" |
| 121 | }, |
| 122 | { |
| 123 | "effect": "allow", |
| 124 | "principal": "role:manager", |
| 125 | "actions": [ |
| 126 | "read", |
| 127 | "update" |
| 128 | ], |
| 129 | "collection": "expenses", |
| 130 | "reason": "approving spending means acting on somebody else's record, which the owner-filtered rule above deliberately cannot do; the hook still refuses self-approval" |
| 131 | }, |
| 132 | {"effect": "allow", "principal": "role:finance", "actions": ["read"], "collection": "expenses", |
| 133 | "reason": "finance reports on and reimburses everybody's spending; it does not approve it (role:manager does) and cannot change it"}, |
| 134 | {"effect": "allow", "principal": "registered", "actions": ["read"], "collection": "expense_categories", |
| 135 | "reason": "a claimant has to see the categories, and what each one requires, to file an expense that will be accepted"}, |
| 136 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update"], "collection": "expense_categories", |
| 137 | "reason": "what each kind of spending requires and how much of it is deductible is finance's policy, kept as data with its source"}, |
| 138 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "expense_categories", |
| 139 | "reason": "a category is house policy, not its creator's row: somebody who has left role:finance must not keep editing it through the owner fallback, and nobody deletes a category approved expenses point at (deactivate it; admins may still delete)"}, |
| 140 | {"effect": "allow", "principal": "registered", "actions": ["execute"], "object_id": "action_expense_report", |
| 141 | "reason": "the report folds only the expenses the caller may read (object_access.Access.visible): a claimant sees their own, manager and finance the company's"}, |
| 142 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update"], "collection": "vehicles", "row_filter": {"owner_id": "$user_id"}, "reason": "people record the vehicles they drive on business"}, |
| 143 | {"effect": "deny", "principal": "owner_fallback", "actions": ["delete"], "collection": "vehicles", "reason": "trips point at the vehicle; deactivate it instead (admins may still delete)"}, |
| 144 | {"effect": "allow", "principal": "role:manager", "actions": ["read"], "collection": "vehicles", "reason": "the approver of a trip has to see whose vehicle it was in, which decides whether it is reimbursed"}, |
| 145 | {"effect": "allow", "principal": "role:finance", "actions": ["read"], "collection": "vehicles", "reason": "finance reconciles reimbursements and the personal use of business vehicles"}, |
| 146 | {"effect": "allow", "principal": "registered", "actions": ["create", "read", "update"], "collection": "mileage_logs", "row_filter": {"owner_id": "$user_id"}, "reason": "drivers log and submit their own trips; the hook refuses approving your own"}, |
| 147 | {"effect": "allow", "principal": "registered", "actions": ["delete"], "collection": "mileage_logs", "row_filter": {"owner_id": "$user_id", "status": "draft"}, "reason": "a draft trip is a note to self and may be thrown away; a submitted one is a claim"}, |
| 148 | {"effect": "deny", "principal": "owner_fallback", "actions": ["delete"], "collection": "mileage_logs", "reason": "only drafts are deleted by their driver (the rule above); without this the owner fallback let a driver delete a submitted or rejected claim"}, |
| 149 | {"effect": "allow", "principal": "role:manager", "actions": ["read", "update"], "collection": "mileage_logs", "reason": "approving a trip means acting on somebody else's log; the hook still refuses self-approval"}, |
| 150 | {"effect": "allow", "principal": "role:finance", "actions": ["read"], "collection": "mileage_logs", "reason": "finance reconciles mileage reimbursements against the log"}, |
| 151 | {"effect": "allow", "principal": "registered", "actions": ["read"], "collection": "mileage_rates", "reason": "a driver should be able to see the rate their trip will be paid at"}, |
| 152 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update"], "collection": "mileage_rates", "reason": "the reimbursement rate is finance's policy, kept as data with its source"}, |
| 153 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "mileage_rates", "reason": "a rate is house policy, not its creator's row: somebody who has left role:finance must not keep changing it, and nobody deletes a year approved trips were priced from (admins may)"}, |
| 154 | {"effect": "allow", "principal": "role:finance", "actions": ["create", "read", "update"], "collection": "fringe_benefits", "reason": "the register is pay information about named people, kept by finance for the payroll provider"}, |
| 155 | {"effect": "deny", "principal": "owner_fallback", "actions": ["read", "update", "delete"], "collection": "fringe_benefits", "reason": "a row is not its recorder's: somebody who has left role:finance must not keep reading or changing pay information through the owner fallback; corrections are edits by finance, removal is an admin's"}, |
| 156 | {"effect": "allow", "principal": "role:finance", "actions": ["execute"], "object_id": "action_fringe_export", "reason": "the export is the whole register; the object asks again (admin, or reads every row) before reading"} |
| 157 | ] |
| 158 | } |