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.
dbbasic-package.json · 7.9 KB · 95 lines
| 1 | { |
| 2 | "id": "app-intake", |
| 3 | "name": "Document Intake", |
| 4 | "version": "0.6.4", |
| 5 | "description": "Snap it, confirm it, post it. Paperwork sprawl is the reason small-business books rot: entries are tedious, so they do not get made, and by the time anybody looks the receipts are in a coat pocket. This package is the ENTRY path -- ingest is fast and dumb (store the bytes, return, read it later) because capture has to happen at the moment the paper exists; a reading pass produces a structured GUESS; and a human confirms it into a draft expense stamped generated_from scans/{id}. Nothing an engine reads is ever posted. That boundary (docs/logic-decisions.md #6, #8) is what lets this ship with no AI at all: the default extractor is regex over OCR text -- free, no key, no per-page cost -- and it degrades to 'found nothing, here is your image, type the total' rather than to wrong numbers in the ledger. An AI vision engine plugs into the same shape and simply guesses better, on the owner's own key, which is the only path with a real marginal cost. The image itself is the audit evidence auditors actually want, and it stays attached to the expense, the journal and the invoice line that follow from it. Pairs with bank reconciliation: the bank line says money left, the scan says why. Declares an attention count (collection + where, counted per viewer): a scan at `extracted` is the pipeline's honest stopping point, where a machine declined to turn somebody's money into an expense on its own, and system_scan_processor has been returning a key literally named `needing_a_human` that no surface ever read. Now it is a number on the home page. No nav entry: app-intake still ships no door of its own, so the count files under Money and clicks through to the scans list. 0.3.0 gives the count a page to land on. The manifest has been claiming since 0.2.0 that the receipts queue \"clicks through to the scans list\", and there was no scans list: the attention path pointed at /scans?status=extracted, which no route answered, so the most valuable number on the home page was a dead link -- a notification rather than a workflow. The fix is a seeded `views` record over the generic `list` block plus a site_routes row to site_view_render, the same zero-page-code shape /products, /invoices and /accounts already use, and the nav entry that was previously declared absent. The list has no Add button on purpose: a scan is bytes plus a hash, raised by action_scan_ingest from whatever took the photograph, and a form that let somebody type a filename would create a row with no document behind it for the processor to choke on. Rows do not link either -- there is no /scans/{id} permalink in this slice, and a row that navigates to a 404 is worse than a row that does not navigate. The path is now the UNFILTERED index, deliberately: the generic list renderer builds its filter bar from the schema's views.filter_fields and takes no preselection from the query string, so ?status=extracted would have been a link that silently landed on the whole collection while claiming to be a queue. An honest broader list with `status` one click away in the filter bar beats a filter that does nothing. 0.3.1: action_confirm_scan refuses a scan whose status cannot move to confirmed before it writes anything, and claims the expense through expenses.generated_from (unique), so a retry or a second click links the one expense instead of booking another. 0.5.2: a row a registered user writes could point at anybody's record, because the rules asked only that the new row be the writer's own. Every pointer a non-admin can write now declares relation.requires (scans.entity_id update), so over the API a row points only at a record its writer may see, or, where it moves money, stock or state of what it points at, may update; a record they may not see is answered like a missing one (docs/permissions-model.md, 'Pointing at a record you may not act on'). 0.6.0: confirming a scan links it as the expense's receipt (expenses.receipt_scan_id, app-finance 0.19.0) and takes the category, business purpose, attendees and place an auditor asks for, stamping the category's requirements itself because it writes below the expenses hook. role:manager and role:finance may read scans, so the approver sees the receipt an expense cites. 0.6.1: system_scan_processor reads only the bytes intake stored for the scan (scan-{id} under the scan's owner) and marks any other scan failed without opening a file; scans.file_id is read_only; action_scan_ingest files the scan under the signed-in caller and refuses an owner_id naming somebody else unless the caller is an admin (it used to prefer the body's owner_id, so anybody could file a scan, and store its bytes, under anybody's account). 0.6.2: action_scan_ingest checks the scan's entity_id as the record API does (relation.requires update, through object_access), before it stores anything: it used to copy entity_id from the request, so any signed-in user could point a scan, and the expense confirmed from it, at somebody else's books, and a nonexistent id was a 500 after the bytes were stored. A missing entity and one the caller may not see get the record API's one 400. 0.6.3: action_confirm_scan asks the record API's relation.requires question for every pointer on the expense (project_id from the request, entity_id from the scan, through object_access) before it writes anything, preview included: it used to copy project_id from the request, so any signed-in user could put an expense on somebody else's project, and a scan stored before 0.6.2 carried its unchecked entity_id onto the expense. A missing record and one the caller may not act on get the record API's one 400; a project member may still put an expense on the project. 0.6.4: system_scan_processor asks for itself, over HTTP, that the caller is staff (an admin, or a role the installed execute rules name for it; this package names none), whatever the enforcement setting: with enforcement off any signed-in user could start a pass, which spends the owner's AI budget and touches every pending scan. The scheduler runs it as the system, unchanged.", |
| 6 | "compatibility": { |
| 7 | "dbbasic_object_server": ">=0.1.0" |
| 8 | }, |
| 9 | "dependencies": [ |
| 10 | "app-views" |
| 11 | ], |
| 12 | "objects": [ |
| 13 | { |
| 14 | "id": "action_scan_ingest", |
| 15 | "path": "objects/action/scan_ingest.py" |
| 16 | }, |
| 17 | { |
| 18 | "id": "system_scan_processor", |
| 19 | "path": "objects/system/scan_processor.py" |
| 20 | }, |
| 21 | { |
| 22 | "id": "action_confirm_scan", |
| 23 | "path": "objects/action/confirm_scan.py" |
| 24 | } |
| 25 | ], |
| 26 | "schemas": [ |
| 27 | { |
| 28 | "collection": "scans", |
| 29 | "path": "schemas/scans.json" |
| 30 | } |
| 31 | ], |
| 32 | "permissions": [ |
| 33 | { |
| 34 | "path": "permissions/rules.json" |
| 35 | } |
| 36 | ], |
| 37 | "seed": [ |
| 38 | { |
| 39 | "collection": "scans", |
| 40 | "path": "seed/scans.tsv" |
| 41 | }, |
| 42 | { |
| 43 | "collection": "views", |
| 44 | "path": "seed/views.tsv" |
| 45 | }, |
| 46 | { |
| 47 | "collection": "site_routes", |
| 48 | "path": "seed/site_routes.tsv" |
| 49 | } |
| 50 | ], |
| 51 | "migrations": [], |
| 52 | "schedules": [ |
| 53 | { |
| 54 | "id": "scan_processor_hourly", |
| 55 | "object_id": "system_scan_processor", |
| 56 | "schedule": "5 * * * *", |
| 57 | "description": "Read pending scans and produce confirmable suggestions. Hourly rather than daily because somebody who just photographed a receipt expects to see it read, and nothing here posts anything." |
| 58 | } |
| 59 | ], |
| 60 | "nav": [ |
| 61 | { |
| 62 | "id": "scans", |
| 63 | "label": "Scans", |
| 64 | "path": "/scans", |
| 65 | "blurb": "Paperwork photographed in, waiting to be read and confirmed", |
| 66 | "surface": "member", |
| 67 | "group": "Money", |
| 68 | "order": 380 |
| 69 | } |
| 70 | ], |
| 71 | "attention": [ |
| 72 | { |
| 73 | "id": "scans_to_confirm", |
| 74 | "collection": "scans", |
| 75 | "where": { |
| 76 | "status": "extracted" |
| 77 | }, |
| 78 | "detail": { |
| 79 | "op": "count", |
| 80 | "where": { |
| 81 | "created_at": { |
| 82 | "op": "older_than_days", |
| 83 | "value": 7 |
| 84 | } |
| 85 | }, |
| 86 | "text": "{value} over a week old" |
| 87 | }, |
| 88 | "label": "Receipts to confirm", |
| 89 | "path": "/scans", |
| 90 | "group": "Money", |
| 91 | "severity": "normal", |
| 92 | "nav_id": "scans" |
| 93 | } |
| 94 | ] |
| 95 | } |