Skip to content

A review saved with decision Approved leaves 结论时间 (decided_at) empty — the deviation stamps it, the review does not - #163

Merged
zhuangjianguo merged 1 commit into
mainfrom
claude/issue-159-review-decided-at
Oct 27, 2026
Merged

zhuangjianguo merged 1 commit into
mainfrom
claude/issue-159-review-decided-at

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #159

Clause-②: no
Metadata-protocol: none

A review saved with a decision kept 结论时间 (decided_at) empty. A decided deviation is stamped by deviation_state_machine and a completed signing round by signature_state_machine; the review had no stamp at all. This adds one, in the same file and the same pattern.

What changed

  • src/objects/contract.hook.ts: new hook review_decision_stamp on clm_review, beforeInsert + beforeUpdate, priority 200. When a write gives the review a decision (approved, changes requested or rejected) that differs from the one it had, and no decided_at is present (in this write or already on the row), it stamps decided_at with the current time. It never overwrites and never clears a value. File header lists the hook.
  • src/objects/review.object.ts: decided_at gets a description: "Stamped when the review is given a decision, unless set explicitly." (the deviation's wording).
  • src/translations/en|zh-CN/objects.lifecycle.ts: the matching help (zh-CN: 给出结论时自动写入,除非显式指定。). The i18n gate asked for the zh-CN key (objects.clm_review.fields.decided_at.help, measured red before it was added); the en line keeps the en bundle in step with the deviation's.

No decided_by: clm_review has no such field and DESIGN.md §03 lists only started_at · decided_at on the review. The reviewer is who decides. No field was added.

Back to pending

The decision may go back to pending (§03 gives the review's decision no transition table, unlike the deviation's open → final machine), and the hook leaves decided_at as it is. This matches the deviation's stamp, which only fills an empty value and never erases one. Clearing would also erase a time the lawyer typed, because the hook cannot tell a stamped value from a typed one. The field stays editable on the same form, so a lawyer can clear or correct it. The trade-off: a review decided again after going back to pending keeps its first time (measured, step I below). Refusing the back-edge or clearing on it would be a product decision. It is raised in the report and not made here.

One step beyond the card's wording ("leaves pending"): a change between two decisions (for example approved → rejected) on a row that has no decided_at is stamped too. Those are exactly the rows this defect produced before the fix. Re-deciding one gives it a time instead of leaving it empty (step K).

Measurement: @objectstack 18.2.0, pnpm demo:zh --port 3144, fresh DB before and after

Persona created the README way, as the dev admin: POST /api/v1/auth/admin/create-user Legal Counsel 1 → 200 (mustChangePassword: true), POST /api/v1/data/sys_user_position { position: clm_legal_counsel } → 201, then as the persona POST /api/v1/auth/change-password → 200. security/explain (clm_review, create) → allowed, permission sets clm_legal, clm_requester, member_default. Every reading below was taken signed in as Legal Counsel 1, in Chromium (/opt/pw-browsers/chromium, locale zh-CN).

Browser, before (origin/main 21f2319). Contract DPA-2026-0005 (数据处理协议 — 渡鸦安保) › 审查与偏离 › 审查 › 新建. Steps: 审查人 = Legal Counsel 1, 结论 = 通过, 创建. POST /api/v1/data/clm_review → 201, and the row then reads {"decision":"approved","decided_at":null}. The record page shows 结论 通过 and no 结论时间. The contract's review grid has no 结论时间 column at all, because every row's value is empty.

Browser, after (4041dd1). Same contract, same steps, on a fresh DB.

  • 结论 = 通过, 创建 → {"decision":"approved","decided_at":"2026-10-27T09:04:05.678Z"} (created_at 09:04:05.667Z). The record page reads 结论时间 2026/10/27 上午9:04, and the contract's grid now shows the 结论时间 column with 2026/10/27 上午9:04 on that row.
  • Typed value kept: 结论 = 通过 with 结论时间 typed 2026/10/01 09:30 → decided_at: "2026-10-01T09:30:00.000Z".
  • Pending stays empty: 结论 left at 待定 → {"decision":"pending","decided_at":null}.
  • Edit path: that pending review › 编辑 › 结论 = 通过 › 保存. PATCH → 200, then decided_at: "2026-10-27T09:05:42.961Z" and the page reads 结论时间 2026/10/27 上午9:05.
  • Back to pending: › 编辑 › 结论 = 待定 › 保存. {"decision":"pending","decided_at":"2026-10-27T09:05:42.961Z"}: the stamp is left in place.
  • Browser console in every run: the same two resource errors (one 404, one 401) as before the fix. Nothing new.

API path (REST, as Legal Counsel 1), before → after

step write before after
A POST decision=approved decided_at null stamped 09:06:12.159Z
B POST approved + decided_at 2026-10-01T09:30Z kept kept
C POST decision=pending / POST with no decision null / null null / null
E PATCH pending → changes_requested null stamped 09:06:14.240Z
F PATCH changes_requested → pending null 09:06:14.240Z left in place
G PATCH pending → rejected + decided_at 2026-09-15T08:00Z kept kept
H PATCH comments only unchanged unchanged
I PATCH (F's row) pending → approved n/a 09:06:14.240Z kept (first time)
K PATCH approved → rejected on a row with decided_at cleared n/a stamped 09:06:26.030Z

Seed untouched: as the dev admin, 67 reviews in the table (60 seeded + 7 written above). Exactly 4 carry a decided_at on or after 2026-10-27, all four written above, so no seeded review was restamped. 0 decided reviews have an empty decided_at. Both boots end with the same seed summary (inserted 830 · errored 404, the README's documented unnamed-persona references), before and after.

Gates (final head 4041dd1)

pnpm install                  EXIT=0
pnpm validate                 EXIT=0   ✓ Validation passed (735ms)
pnpm lint                     EXIT=0   1 warning(s), 6 suggestion(s): the warning is main's security-controlled-by-parent-owner-policy-without-opt-in
pnpm typecheck                EXIT=0   tsc --noEmit
pnpm lint:i18n-gate           EXIT=0   ✓ i18n gate · COVERAGE : 0 missing keys across 2 locale(s)
CLM_DEMO_SEED=1 pnpm validate EXIT=0   ✓ Validation passed (843ms)

Before the translation was added: lint:i18n-gate EXIT=1 ([zh-CN] objects.clm_review.fields.decided_at.help), and lint showed a second warning for the same key. Both cleared.

Acceptance notes

  • The contract page's review grid leaves out the 结论时间 column when no row on it has a value. Measured before the fix: the column was absent. After the fix it appears once one row is stamped. This is renderer behaviour. Noted, not filed.

🤖 Generated with Claude Code

https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn

A review saved as approved, changes requested or rejected kept an empty
decided_at, while a decided deviation and a completed signing round are
stamped by their hooks. review_decision_stamp fills decided_at on insert
and update when the decision changes to a non-pending value, unless one
is set; it never overwrites or clears a value, so a typed time is kept
and a return to pending leaves the field alone. decided_at gets a
description and its en / zh-CN help.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017nzWFRUo2U7evMkPdVniAn
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对 — ACCEPT · head 4041dd1 · 2026-10-27T09:11Z

check reading
shape draft → main, Fixes #159; mergeable clean
CI on the head both Validate check-runs success on 4041dd1 = PR head.sha
scope 4 files (+41): the review_decision_stamp hook in contract.hook.ts, the decided_at description in review.object.ts, and its en / zh-CN help (the i18n gate asked). This is within the claim's surface. Nothing governed; lint has only main's one existing warning
the defect measured on 18.2.0 as Legal Counsel 1 in the browser and over the API, before and after. Before: 结论 = 通过 saved with decided_at null. After: it is stamped. A typed time is kept, a pending review stays empty, and a comments-only PATCH leaves it unchanged
code follows the deviation stamp (deviation_state_machine): it fills an empty value and never overwrites or clears one. It stamps only on a real change of decision away from pending
seat call — back to pending A, as shipped: the stamp stays. This matches the deviation, needs no §03 change, and the field stays editable on the form. No card
observation the hook spells out the empty check inline; the file's isSet helper (used by the deviation stamp) says the same. Not a defect, no change asked

Landing: under the maintainer's merge authorization (project thread: 「你可以自己审核的就自己合并」).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A review saved with decision Approved leaves 结论时间 (decided_at) empty — the deviation stamps it, the review does not

2 participants