Repository navigation
Commit 740edc5
fix(plugin-audit,platform-objects): the audit log's default list shows what people did; the audit objects read in Chinese (#30620)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgJEWbotugYjYfjGSJZi35n7)_
domain:server#6 · os-bill · session_01Utp6CXCS98uhsFQYk64epE
## 维护者速读
-
改了什么:Setup「审计日志」打开时的默认列表(最近)只列人做的操作:登录时顺带写的「更新用户(最近登录时间)」行、设置变更顺带写的设置存储行和设置审计行、密钥存储、签名密钥、数据迁移台账都不再出现在默认列表;「平台设置」「平台设置审计记录」「评论表情回应」在中文界面显示中文名。
- 为什么改:真实用户走查发现一次登录在审计日志里写好几行,设置改一次出现三四行,管理员找不到真正的操作;「Platform Setting
Audit Entry」等对象名在中文界面是英文。
- 风险与回滚:不少写任何一行,也不删数据,「全部」视图照旧列出每一行;登录戳那一行多带一个 metadata 标记
`{"event":"auth.last_login_stamp"}`。回滚即 revert 本 PR,已写入的标记无害。
-
先看:`packages/plugins/plugin-audit/src/objects/sys-audit-log.object.ts`(默认视图
recent 的过滤与排除清单),`packages/plugins/plugin-audit/src/sign-in-stamp.ts` 与
`audit-writers.ts`
里打标记的两处,`packages/platform-objects/scripts/i18n-extract.config.ts`。
- 两分钟验证:`pnpm --filter @objectstack/plugin-audit exec vitest run
src/sys-audit-log-default-view.integration.test.ts`,预期 5
条全过:登录戳被标记且不进默认列表,管理员改用户仍在,设置变更行仍在,「全部」仍列出所有行。
- 需要你做的:无,席位落地。
Refs #30209 (row 3)
Clause-②: no — no `packages/spec` change; the new constants are
module-internal (not exported from the package entry)
Metadata-protocol: none
Skills-docs: none — `git grep -n -i -E "audit
log|last_login|sys_platform_setting|comment reaction" -- skills` on
`ef370d07e` answers two lines
(`skills/objectstack-ui/rules/list-views.md:222`, an example grid
labelled `Audit Log`;
`skills/objectstack-platform/references/plugin-development.md:211`, a
plugin's log line), neither about the shipped audit log's views or
names, so this PR makes neither false.
## What changes
**Row 3, the audit log's default list.** Measured on a fresh `pnpm dev
-- --fresh` showcase boot (`c23eafa8`), one act wrote several ledger
rows:
| Act | Rows on `sys_audit_log` |
| --- | --- |
| A sign-in | `login` on `sys_session`, and `update` on the person's
`sys_user` stamping `last_login_at` / `last_login_ip` (plugin-auth
`stampLastLogin`, under the person's own id) |
| The first sign-in through the console | the two above, and `create` on
`sys_jwks` (the token-signing key) |
| A tenant setting change | `create`/`update` on `sys_setting`,
`config_change` naming `sys_setting`, `create` on `sys_setting_audit` |
| A global secret change | `create` on `sys_secret`, `create` on
`sys_platform_setting`, `config_change` naming `sys_platform_setting`,
`create` on `sys_platform_setting_audit` |
| A boot | rows on `sys_migration` |
- `plugin-audit`: the CRUD ledger writer marks the sign-in stamp.
`isSignInStamp` (`sign-in-stamp.ts`) answers true for an update of
`sys_user` whose changed fields (the writer's own diff) are
`last_login_at` / `last_login_ip` and nothing else; the row then carries
`metadata: {"event":"auth.last_login_stamp"}`, the place `config_change`
rows already name their event (`settings.set`). An administrator's edit
of a user, or any write that changes another field beside the stamp,
carries no mark. The row is still written. A delegated write's
`performed_by` / `on_behalf_of` keys are kept beside the mark when both
apply.
- `sys_audit_log.listViews.recent` (the first declared view, which Setup
opens) gains a filter: rows on `sys_secret`, `sys_setting_audit`,
`sys_platform_setting_audit`, `sys_jwks`, `sys_migration` and
`sys_migration_journal` are left out; rows on `sys_setting` /
`sys_platform_setting` are left out unless the action is `config_change`
(that row names the store as its object); and a row whose `metadata`
contains the stamp's event is left out (an any-of group with `metadata`
is null, so rows without metadata stay). `metadata` is not one of the
value-bearing columns `parent-field-query-guard.ts` refuses to filter
on, so every reader can run the view. `all_events` is unchanged and
lists every row. Object names are read from the definitions
(`@objectstack/platform-objects/system`, `SystemObjectName.JWKS`), not a
name prefix: `sys_user`, `sys_member`, sharing rules and the like stay
in, because their writes are acts.
**Row 3, the audit objects' names in Chinese.** `sys_platform_setting`
and `sys_platform_setting_audit` (registered by `service-settings`,
defined in `platform-objects`) were in no extract config, so no bundle
carried them in any locale. They join `platform-objects`' extract config
(and its `bundle-ownership` list); the extract added them to every
bundle, and zh-CN is written by hand (object, field, help, option and
view names, following `sys_setting` / `sys_setting_audit`).
`sys_comment_reaction`'s zh-CN leaves in `plugin-audit` held the English
fill and are translated; the regenerate dropped their fill records.
## Tests
- `plugin-audit/src/sys-audit-log-default-view.integration.test.ts`
(new; real kernel, `AuditPlugin`, SQLite driver, the view's filter
lowered the way the Console lowers it, `or` group included, and parsed
by `parseFilterAST`): the stamp is marked and the two controls are not;
`recent` keeps `login`, both `config_change` rows and the
administrator's edits, and leaves out the stamp and every machinery row;
`recent` reads newest first; `all_events` still lists all of them.
- `platform-objects/src/system/platform-setting-zh-cn.test.ts` (new):
served zh-CN (`SetupAppTranslations`) names both objects and every
declared field and option in Chinese.
- `plugin-audit/src/translations/comment-reaction-zh-cn.test.ts` (new):
served zh-CN (`AuditTranslations`) names `sys_comment_reaction`, its
fields and helps in Chinese.
Red first on `main` `2ffdb649` (pin commit `ccb7a5f8`): default view 2
failed / 3 passed (stamp unmarked; stamp in `recent`), platform settings
zh-CN 4/4 failed, comment reaction zh-CN 2/2 failed.
Ablation (once, `scripts/ablation-replace.mjs`, anchor hit x1, restored
blob equals HEAD, `git diff HEAD` empty): with `signInStamp =
isSignInStamp(…)` replaced by `false`, the default-view file goes 2
failed / 3 passed (the mark pin and the `recent` pin).
## Acceptance notes
- **Rows 4, 5 and 6 are not in this PR** (`Refs`, not a closing
keyword). Row 4 (config change old/new values) and row 5 (the
sharing-rule object picker) are in the card report as decisions; row 6
(queue members) is a reading only.
- **ja-JP and es-ES** carry the extract's English fill for the two
settings objects, recorded in their `source-hashes` files;
`sys_comment_reaction` in those locales is unchanged.
- **The sign-in stamp is recognised by its fields.** A future write that
changes only `last_login_at` / `last_login_ip` on `sys_user` for another
reason would be marked too; today plugin-auth's stamp is the only writer
of those two fields.
- Other `sys_*` objects that still read English under zh-CN (approvals
tokens and approvers, connector and flow credentials, metadata commit
and activation, webhook, trusted key, identity email, automation run,
assignment cursor, audience binding suggestion, migration journal)
belong to other packages and are not touched.
## Verification
<details><summary>Package suites and typechecks (head ef370d0, after
merging origin/main with #30551)</summary>
- `pnpm --filter @objectstack/platform-objects --filter
@objectstack/plugin-audit test` under the verify lock: platform-objects
114 files / 1567 tests, plugin-audit 73 files / 1144 tests, VERDICT
command-exit 0.
- `pnpm --filter @objectstack/plugin-audit --filter
@objectstack/platform-objects typecheck`: VERDICT command-exit 0.
- `node scripts/check-i18n-bundles.mjs --write` after the merge:
byte-identical (no file changed); `pnpm check:i18n`: all ten bundle sets
in sync.
- eslint `--no-inline-config` on the changed TypeScript files: exit 0.
</details>
<details><summary>Derived gate families</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on `ef370d07e` (after the `origin/main`
merge) derived 64 commands. Each ran with its exit code captured before
any pipe: all 64 exited 0. `--ran`: 64 derived, 64 run, 0 NOT-MEASURED,
0 UNRUN.
- On the pre-merge tree (`77f2050b`) the same 64 ran green except `node
scripts/check-plugin-teardown-shape.mjs --self-test`, exit 3 on the
shallow clone; it exited 0 after `git fetch` of its fixture commit, and
exited 0 on the merged head too.
- `pnpm lint` (repository-wide, `eslint . --no-inline-config`) on
`ef370d07e`: exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CbEH94Gqn2583kuuzH)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6e8ec73 commit 740edc5
18 files changed
Lines changed: 1111 additions & 27 deletions
File tree
- .changeset
- packages
- platform-objects
- scripts
- src
- apps/translations
- system
- plugins/plugin-audit/src
- objects
- translations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
192 | 203 | | |
193 | 204 | | |
194 | 205 | | |
| |||
316 | 327 | | |
317 | 328 | | |
318 | 329 | | |
| 330 | + | |
319 | 331 | | |
320 | 332 | | |
| 333 | + | |
321 | 334 | | |
322 | 335 | | |
323 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3446 | 3446 | | |
3447 | 3447 | | |
3448 | 3448 | | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
3449 | 3497 | | |
3450 | 3498 | | |
3451 | 3499 | | |
| |||
3573 | 3621 | | |
3574 | 3622 | | |
3575 | 3623 | | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
3576 | 3702 | | |
3577 | 3703 | | |
3578 | 3704 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3446 | 3446 | | |
3447 | 3447 | | |
3448 | 3448 | | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
3449 | 3497 | | |
3450 | 3498 | | |
3451 | 3499 | | |
| |||
3573 | 3621 | | |
3574 | 3622 | | |
3575 | 3623 | | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
3576 | 3702 | | |
3577 | 3703 | | |
3578 | 3704 | | |
| |||
0 commit comments