You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6b220ef
Browse filesBrowse the repository at this point in the historyBrowse files
fix(objectql,cli): recompute-home-amounts review round 1 — since check owned by the recompute, aborted runs audited, truncated runs exit 1
- The --since check is the recompute's own exported pure function
(assertHomeAmountRecomputeSince); the CLI calls it before its probe and
keeps no copy, so the VALIDATION_FAILED stamp has one owner.
- An unclassified error that stops an applied walk still writes the
run-level sys_audit_log entry, marked aborted, then is thrown on.
- A walk --max-records cut short exits 1.
- refuseUndeclaredObjects sets httpStatus 404, so the --json envelope
carries it beside OBJECT_NOT_FOUND.
- Pinned with the real audit writers: per-row update rows plus the run
entry. Docs: the duplicated heading removed; per-row audit rows,
updated_at kept, and record-currency-codes' every-organization code
stated.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CXZRTkUQ6UjyMWfN2U
- **`@objectstack/objectql`: `recomputeHomeAmounts(engine, logger, { object, field?, since?, apply?, maxRecords?, maxListed?, source? })`**, with `formatHomeAmountRecomputeReport`, `homeAmountRecomputeComplete` and `HOME_AMOUNT_SKIP_REASONS`. It walks every stored row of an object whose `record`-mode amounts declare `currencyConfig.homeAmount` and projects each through the write-time projection itself (the same rate row, division, single rounding, same-currency rule and organization-timezone day), in the row's own organization, so each organization converts into its own home currency at its own rates and is counted apart. A dry run (the default) reports what would change and writes nothing; `apply` writes only the rows that differ, through `engine.update` with the home field in the payload, so the value stored is the one the write itself computes, and only the home and rate fields move (`updated_at` is kept). Rows that cannot be converted are listed by reason and never written: `rate_missing` (with the currency and date), `code_blank` (an amount with no currency code; the remedy is `os migrate record-currency-codes`), `document_date_blank`, `home_currency_unset` and `unconvertible`. `since` filters on the document date (`homeAmount.rateDate`). One `sys_audit_log` entry records each applied run (counts per organization and reason, and the skipped rows). Refused before any row is read: an unknown object (`OBJECT_NOT_FOUND`), an object or `field` declaring no home amount (`INVALID_FIELD`), a `since` that is not `YYYY-MM-DD` (`VALIDATION_FAILED`).
11
+
- **`@objectstack/objectql`: `recomputeHomeAmounts(engine, logger, { object, field?, since?, apply?, maxRecords?, maxListed?, source? })`**, with `assertHomeAmountRecomputeSince` (the pure `since` check a door can run before it opens a database), `formatHomeAmountRecomputeReport`, `homeAmountRecomputeComplete` and `HOME_AMOUNT_SKIP_REASONS`. It walks every stored row of an object whose `record`-mode amounts declare `currencyConfig.homeAmount` and projects each through the write-time projection itself (the same rate row, division, single rounding, same-currency rule and organization-timezone day), in the row's own organization, so each organization converts into its own home currency at its own rates and is counted apart. A dry run (the default) reports what would change and writes nothing; `apply` writes only the rows that differ, through `engine.update` with the home field in the payload, so the value stored is the one the write itself computes, and only the home and rate fields move (`updated_at` is kept, so a consumer syncing by `updated_at` does not see the recompute). Being a write, it moves what reads the home field as a fresh write would: stored formulas, parent summaries, and the per-row audit rows where audit capture is installed. Rows that cannot be converted are listed by reason and never written: `rate_missing` (with the currency and date), `code_blank` (an amount with no currency code; the remedy is `os migrate record-currency-codes`), `document_date_blank`, `home_currency_unset` and `unconvertible`. `since` filters on the document date (`homeAmount.rateDate`). One run-level `sys_audit_log` entry records each applied run (counts per organization and reason, and the skipped rows), also when an unclassified error stops the run partway (marked `aborted`, then the error is thrown on). A walk cut short by `maxRecords` is `truncated` and not complete. Refused before any row is read: an unknown object (`OBJECT_NOT_FOUND`), an object or `field` declaring no home amount (`INVALID_FIELD`), a `since` that is not `YYYY-MM-DD` (`VALIDATION_FAILED`).
12
12
-**`@objectstack/objectql`: `ObjectQL.homeAmountReadsFor(context?)`**, the reads the write-time projection makes (its serving, and the organization a write converts a row under), for a caller that projects a stored row as a write would.
13
-
-**`@objectstack/cli`: `os migrate recompute-home-amounts --object <o> [--field <amount>] [--since YYYY-MM-DD] [--apply] [--yes] [--json] [--force] [--max-records] [--database-url]`**, the shell of `os migrate record-currency-codes`, booting the settings service (each organization's `localization.currency` and `.timezone`) and the audit ledger. It exits 1 while any row is listed and skipped, on a dry run as on an apply, because a total over the home field silently leaves such a row out.
13
+
-**`@objectstack/cli`: `os migrate recompute-home-amounts --object <o> [--field <amount>] [--since YYYY-MM-DD] [--apply] [--yes] [--json] [--force] [--max-records] [--database-url]`**, the shell of `os migrate record-currency-codes`, booting the settings service (each organization's `localization.currency` and `.timezone`) and the audit ledger. It exits 1 while any row is listed and skipped, on a dry run as on an apply, because a total over the home field silently leaves such a row out, and when `--max-records` cut the walk short.
14
+
-**`@objectstack/cli`: an unknown `--object` on any `os migrate` command now carries `httpStatus: 404` in its `--json` envelope** beside `code: OBJECT_NOT_FOUND` (`refuseUndeclaredObjects` sets ADR-0112 D5's spelling of the status it already carried as `status`).
Copy file name to clipboardExpand all lines: content/docs/deployment/cli.mdx
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1647,7 +1647,13 @@ row would store. Each organization converts into its own home currency at its ow
1647
1647
and the report counts each organization apart.
1648
1648
1649
1649
**What is written.** Only rows whose stored home amount or rate differs, and in them only
1650
-
the home and rate fields: `updated_at` keeps its stored value. `--field` limits the run to
1650
+
the home and rate fields: `updated_at` keeps its stored value. Because each one is an
1651
+
ordinary write of the home field, whatever reads that field moves with it, as it would for
1652
+
a fresh write: stored formulas, parent summaries, and, where audit capture is installed
1653
+
(it is in the command's own boot), one per-row `sys_audit_log` `update` row for each row
1654
+
rewritten. ⚠️ Since `updated_at` does not move, a consumer that syncs incrementally by
1655
+
`updated_at` does not see a recomputed row; resync the object, or the rows the report
1656
+
lists. (`os migrate record-currency-codes` does move `updated_at`.) `--field` limits the run to
1651
1657
one amount; without it, every amount of the object that declares a home amount is
1652
1658
recomputed. `--since YYYY-MM-DD` keeps the rows whose **document date** (the field
1653
1659
`homeAmount.rateDate` names, the date that picks the rate) is on or after that day, a
@@ -1662,20 +1668,22 @@ is refused after the boot and before any row is read.
1662
1668
| Reason | The row | Fix, then re-run |
1663
1669
|:---|:---|:---|
1664
1670
| `rate_missing` | No rate for its currency is in force on its document date (the report names both). | Add the rate. |
1665
-
| `code_blank` | An amount with no currency code: stored before the field switched to record mode. | [`os migrate record-currency-codes`](#os-migrate-record-currency-codes). |
1671
+
| `code_blank` | An amount with no currency code: stored before the field switched to record mode. | [`os migrate record-currency-codes`](#os-migrate-record-currency-codes). It writes its one code into the codeless rows of **every** organization, so check the report's `code_blank` count per organization first. |
1666
1672
| `document_date_blank` | A foreign-currency amount with no document date. | Fill the document date. |
1667
1673
| `home_currency_unset` | Its organization has no `localization.currency`. | Set **Localization → Default currency**. |
1668
1674
| `unconvertible` | A code, amount or document date the write itself refuses. | Correct the value. |
1669
1675
1670
1676
A skipped row keeps whatever it stored, so a total over the home field leaves it out (a
1671
1677
`sum` skips an empty home amount silently). That gap stays visible: the command exits 1,
1672
1678
on a dry run and on an apply, for as long as any row is listed, and an applied run's
1673
-
`sys_audit_log` entry (one per run, `action: update`, `metadata.event:
1674
-
home_amount.recompute`) records the counts per organization and reason and every skipped
1675
-
row. Idempotent: re-running until it lists nothing and changes nothing *is* the
1679
+
run-level `sys_audit_log` entry (one per run beside the per-row rows, no record,
1680
+
`action: update`, `metadata.event: home_amount.recompute`) records the counts per
1681
+
organization and reason and every skipped row. A run that an unexpected error stops
1682
+
partway still writes that entry, marked `aborted` with the counts it reached, before the
1683
+
command fails. A walk cut short by `--max-records` also exits 1: rows past the bound were
1684
+
not looked at. Idempotent: re-running until it lists nothing and changes nothing *is* the
1676
1685
verification, which is why it records no flag.
1677
1686
1678
-
#### `os migrate comment-reactions`
1679
1687
#### `os migrate comment-reactions`
1680
1688
1681
1689
v18 retired `sys_comment.reactions`, the JSON column that held every emoji
0 commit comments