Repository navigation
fix(service-settings): a settings change's audit row records the value before and after, with secrets as digests - #30937
Conversation
Claude-Session: https://claude.ai/code/session_016WV4cy588UNGpATRLjBi9h Co-authored-by: Claude <noreply@anthropic.com>
…er, secrets as digests The settings config_change row on sys_audit_log now records old_value and new_value readable for a key that is not secret-valued, as ADR-0007 Audit & history decides; a secret-valued key (manifest encrypted: true, forced by type password) keeps the masked digest on both sides. plugin-audit's ledger field redaction narrows a settings config_change row's value and digest for a reader whose field-level security masks the settings store's value. Claude-Session: https://claude.ai/code/session_016WV4cy588UNGpATRLjBi9h Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 14 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin f2ddf8d699b432b2ad5b9dbb0c8130d575477965 && git checkout f2ddf8d699b432b2ad5b9dbb0c8130d575477965
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 26c965cb8f61ca59804d55e27e737bf7ff91b383 47b9abc5b704afcd6d9439c4c6cb9af6b96a68c9 && git checkout -B drift-repro 26c965cb8f61ca59804d55e27e737bf7ff91b383 && git merge --no-ff 47b9abc5b704afcd6d9439c4c6cb9af6b96a68c9
node scripts/docs-audit/affected-docs.mjs --json 26c965cb8f61ca59804d55e27e737bf7ff91b383
|
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW Contract reviewServed-tier: Face note: ① Derived judgmentsMust-fix: none. Should-fix (follow-up cards, not blockers; both outside the claim's file surface):
Confirmed, by file and line:
② Semver level
Clause-② arm:
③ Boundary flags
④ Design judgmentDeclaration face only: no schema or governed path in the diff, no narrowing arm declared, so ④ is not owed. For the record, the one design call made here is read against ADR-0007: the before-side describes the stored row at the write's own rung (the row Tests, read for what they pin and whether the reported ablations go red:
Implemented-by: VERDICT: PASS |
|
domain:server#1 · os-elon-musk · session_016WV4cytLmJxfAmgPVjUbbW 席位核对 · ACCEPT · 2026-11-06T13:14Z · #30923Head-sha: 47b9abc
|
…0937 The config_change row now carries a non-secret key's readable before and after itself; the header no longer says it holds only a digest. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1abDZNVe9GRYCpLEn
Requested by Elon · project thread
domain:server#1 · os-elon-musk · session_016WV4cy588UNGpATRLjBi9h
Fixes #30923
Claim: 6684421676 (full re-post of 6684227943 with this branch; file surface amended for the dogfood pin, the QA checklist entry and the plugin-audit redaction file)
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
config_change记录,现在会记下改前值(old_value)和改后值(new_value),非密钥类设置是可读的原值;密钥类设置(清单标encrypted: true,password类型自动算)两边都只记掩码摘要,从不记明文。审计读取端同时补上一道限制:字段级权限看不到设置值的读者,在这条记录里也看不到值和摘要。packages/services/service-settings/src/settings-service.ts的auditReadable/auditPrevious(密钥规则与改前值);config-change-audit.ts的old_value/new_value写法;packages/plugins/plugin-audit/src/audit-log-field-redaction.ts新增的config_change收窄。pnpm --filter @objectstack/service-settings exec vitest run src/config-change-audit.test.ts,预期 24 个用例全过,其中#30923开头的 6 个覆盖 IP 范围前后值、重置、首次写入和密钥。What changes
ADR-0007 § Audit & history decides that every settings write records its before and after on
sys_audit_log, and that a value declaredencrypted: trueis recorded only as a placeholder plus a checksum. Theconfig_changerow recorded a digest of the after and nothing of the before. This PR implements the ADR. No ADR records "a digest, never the value" (searcheddocs/adr/**); the module header that said so was the deviation, and it is rewritten.config_changerow (config-change-audit.ts).new_valueis{ namespace, key, scope, value, digest }, andnullon a reset as before.old_value(an existing column, previously never written) has the same shape for the value the same stored settings row held before the write (the rowrecord_idnames). It isnullwhen that row held no value: a first write at that rung, or a row an earlier reset cleared. A reset records its before there.SettingsService.auditReadable). A value is written readable only when the key is not secret-valued and the row it comes from is not storedencrypted: true. Secret-valued is the manifest'sencrypted: true, whichtype: 'password'forces (registerManifestreads it intoencryptedKeys,settings-service.tsabout line 1259). That is the only sensitivity flag a specifier declares. Nosensitiveflag exists inpackages/spec, and none is needed, because every credential key in the shipped manifests istype: 'password'. A secret's sides carry onlydigest: the encrypted marker, which is the wordencrypted, a colon and the provider's keyed digest, wrapped in angle brackets (the bare word in angle brackets when no keyed digest is available). That is byte-for-byte thenew_valuethese rows carried before, so a reader that parses it keeps working. The before of a secret is the same keyed digest the settings trail'sold_hashrecords.oldHashis now taken when either ledger is wired, before the reaper destroys the previous ciphertext. A plaintext row of a key declared secret since then, and an encrypted row of a key no longer declared secret, are both recorded masked.metadatais unchanged and carries no value.settings-service.types.ts).SettingsAuditSink.record's entry gains two optional fields:value, the after, readable, absent for a secret and on a reset; andprevious,{ value?, digest } | null. A host sink that ignores them works as before.sys_settingdeclaresapiMethods: ['get', 'list']andmanagedBy: 'engine-owned', so the data API cannot write it. Every settings door (Setup,PUT /api/settings/:namespace, the built-inresetaction,resetNamespace, in-processset/setMany) writes throughSettingsService.setMany, the only caller of the sink.plugin-audit,audit-log-field-redaction.ts). The ledger's read-side field redaction narrowed only the CRUD mirror's create/update/delete snapshots, and servedconfig_changerows as written on the ground that they held only a digest. Aconfig_changerow about a settings store (sys_setting, orsys_platform_settingfor a global value) is now judged by that store'svaluefield. A reader not servedvalue(masked or withheld by field-level security) gets neither the value nor its digest on either side, because an unkeyed digest of a short value answers "is it X?".namespace,keyandscopestay. The mirror's row about the same write is narrowed the same way. A snapshot that is not a JSON object is dropped (fail closed). Aconfig_changerow naming no settings store (the deployment notice's hide) is served as written, as before.Tests
config-change-audit.test.ts, new top-level describe, using the realSettingsServicePluginboot, its own sink, and the realauthmanifest:auth.allowed_ip_ranges: a first write recordsold_value: null, and a change records both values readable. The before's digest equals the previous after's digest and the settings trail'sold_hash, andmetadatacarries no value.PUT /api/settings/auth.new_value: null, and a write after a reset records a null before.old_value,new_valueormetadata. Every side is the encrypted marker around anhmac-sha256:digest of 64 hex digits, each before equals the previous after, and thenew_valuekeys staynamespace, key, scope, digest.audit-log-field-redaction.test.ts, new top-level describe, onredactAuditLogRowsover rows in the writer's shape (plugin-audit does not depend on service-settings):valuemasked onsys_settingor onsys_platform_settinggets{ namespace, key, scope }on both sides.config_changerow naming no settings store is served as written.settings-config-change-audit.dogfood.test.ts: the two assertions that pinned the old shape now assert the value. The first case now expectsnew_value.value, and the Setup: show what people can really do and what really changed, using names rather than ids #30209 case now expects the row to carry the workspace name instead of asserting that it does not.docs/qa/platform-checklist/areas/platform-core.json(platform-core.settings-audit-secret-fingerprint):source[1]now describes the readable before and after, and the item gets revision 6 with a history row. No clause changed, because every clause there scores the secretmail.api_key, whose rows still carry only the masked keyed digest.Measured on main 0e88208 before the fix (in-process settings service, real sink, real auth and mail manifests)
auth.allowed_ip_ranges, set, then changed, then reset:old_valueabsent on all three rows.new_valuewas{"namespace":"auth","key":"allowed_ip_ranges","scope":"global","digest":"sha256:…"}on the two sets andnullon the reset.mail.api_key, set, then rotated, then reset:old_valueabsent.new_valuecarried namespace, key, scope and the encrypted marker around anhmac-sha256:digest, thennullon the reset. No plaintext.Ablations (scripts/ablation-replace.mjs; anchor 1 → 0, mutation marker 0 → 1, restored blob == HEAD blob; both suites import src, so no build between)
auditReadablereturnstrue(the secret rule dropped): 3 of the 6#30923service cases fail. They are the secret write/rotate/reset case (new_valuecontains the secret), the key declared secret later (old_valuecontains the old plaintext), and the key no longer declared secret (old_valuehas avalueproperty). The 3 readable cases stay green.config_changebranch removed from the redaction guard: 3 of the 5 new redaction cases fail (masked onsys_setting, masked onsys_platform_setting, non-JSON snapshot). The control case and the no-store case stay green.Acceptance notes
old_value/new_valuedescribe the stored row at the write's own rung, the rowrecord_idnames, and that row's previous value is whatold_hashalready fingerprints. A first tenant-scope write records a null before even when a global value or the default was in force.Clause-②: yes (widening): the served row carries more. The plugin-audit half removes the value and digest only for a reader whose field-level security already withholds the settings store'svalue. That reader was served the unkeyed digest of a non-secret value before, so for them this is a security narrowing. The seat may judge whether that half wants its own arm.plugin-audit/src/audit-plugin.ts("aconfig_changerow's digest sits next to the mirror's row that carries the value") still reads true for secrets but undersells non-secret rows. That file is outside this PR's surface, so it is noted here and not edited.Verification
Local runs on the final head are quoted with that head in the report comment on #30923:
@objectstack/service-settingsand@objectstack/plugin-audittestandtypecheck; the changed dogfood file; every familynode scripts/pm/dispatch-gates.mjs --commandsderives from this diff, reconciled with--ran;pnpm lint. CI's required checks are the authority for everything else.Generated by Claude Code