Skip to content

audit: a summary (roll-up) recompute after a child write stamps the child's writer as updated_by on the master record #33950

Closed

Description

@objectstack-fleet

repo:hotcrm#1 · huangyiirene · session_01J8VVAnPkgK6CWrJa6t7Fk5

Measured on 18.5.0 (hotcrm#2487, the Order to Cash write opt-in, CTR-0001).

  • A finance user (Accounts Receivable position) inserts an invoice and a payment under contract CTR-0001.
  • The contract's and the account's summary fields (invoiced, received, receivable) recompute, as they should.
  • Both master records then read "Updated by Fin AR" with a fresh updated_at, though finance edits neither record and holds no edit on either.
  • A sales rep's plan-step write does the same to the contract.

Why it matters: updated_by / updated_at are the audit trail a person reads on the record page. A system-derived recompute shows up as an edit by whoever touched a child. That misleads an auditor, and it can trip "last modified by" list views, flows on updated_by, or field history.

Asked: a summary recompute (and any derivation-only write the engine makes on a master) leaves updated_by untouched, or stamps it as the system. Whether it also leaves updated_at alone is part of the design: a figure did change. It writes no field-history row attributed to the child's writer. A test: insert a child as user B under a master owned and last edited by user A, then the master's updated_by is still A (or the system), never B.

Consumer: hotcrm Order to Cash (contracts, accounts) and PSA (project cost roll-ups) both hit it. No hotcrm workaround planned.

Activity

  1. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: first touch → domain:server · p2 (pre-graded) · 2026-11-15T15:47Z

    ⛔ Not a claim.

    A summary (roll-up) recompute after a child write stamps the child's writer as updated_by and refreshes updated_at on the master records. The audit trail then names someone who never edited them. Measured on 18.5.0 by HotCRM (the Order to Cash opt-in, hotcrm#2487). Audit attribution is wrong but no data is lost, so p2 stands. The recompute should write as a system stamp, or leave the audit columns unchanged.

  2. added
    domain:server
    pm:queue
    on Nov 15, 2026
  3. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

    Ruled · 2026-11-15T21:54Z

    The maintainer tapped a decision card at 2026-11-15T21:53Z: 「确定汇总字段自动重算时主记录的修改人和修改时间怎么记」 → 「记为系统并刷新时间」 (option B).

    Route this ruling fixes: a summary (roll-up) recompute after a child write stamps the master record with updated_by = null, which the UI renders as 系统, and refreshes updated_at. Null is the ADR-0118 D1 system stamp, so no system account is created. The child's writer is never stamped on the master. No needs-user-decision label was on this card, so the state stays pm:queue, and the card is now claimable by the area that holds it (server area S3).


    Generated by Claude Code

  4. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5

    Claim: server area-lease mode (#33751 §2), area S3, slot freed by PR #34089 entering the queue · executed by an os-dev sub-agent (mode:subagent) · posted at 2026-11-16T00:03Z
    Session: session_01QsR2jTEivi2wogPpeo3xd5
    Account: zhuangjianguo
    Branch: claude/area-E2-33950
    Worktree: objectstack-issue-33950
    Domain: domain:server
    Seat: domain:server#5
    File surface: packages/objectql/src/engine-summaries-and-expansion.ts (the summary recompute write onto the master) and the engine write path it calls for audit stamps, their tests, a real-driver dogfood pin under packages/qa/dogfood/test/, a patch changeset. Stop on breach and explain in the report.
    Container & model: M, mode:subagent, model: default, effort: high
    Clause-②: no
    Metadata-protocol: none (runtime audit stamping; no authorable key changes; the dev confirms against the diff)
    Responsibility: the objectql engine's summary recompute (objectstack repo: platform card carries the fix) | no platform path covers it today | any app with summary fields reaches it on a child write; hotcrm Order to Cash and PSA use it now
    Thread-read: 6902001862
    Premise: holds (the card measures it on 18.5.0; the dev re-measures on main first)
    Serial constraints cleared: none named. Before the push, the dev runs git merge-tree against every open PR sharing a file (S2's #33887 is in objectql's delete/aggregate area) and origin/main.
    Pre-claim lane: server, because the fix is in packages/objectql.
    Pre-claim deps: none open.
    Prior rulings read:

    • The maintainer's decision card, tapped 2026-11-15T21:53Z: 「确定汇总字段自动重算时主记录的修改人和修改时间怎么记」 → 「记为系统并刷新时间」 (recorded 6902001862). Under it, the recompute stamps updated_by = null and refreshes updated_at.
    • ADR-0118 D1: a system actor is null in a user lookup column, with no magic account and no sentinel.
    • Triage 6897114738 (p2).

    Generated by Claude Code

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 16, 2026
  6. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5
    os-dev-report

    {
      "issue": 33950,
      "status": "done",
      "branch": "claude/area-E2-33950",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34242",
      "head": "24f850943a80d0c6fd2cfe46a4727bf5a85c0a8f",
      "session": "session_01QsR2jTEivi2wogPpeo3xd5",
      "premise_still_valid": true,
      "summary": "Premise re-measured on main and it holds: recomputeSummaries issues the master update under {...caller, isSystem:true}, which keeps userId, and ObjectQLPlugin's sys_stamp_audit_update hook stamped that userId into the master's updated_by. With the recompute marker ablated (main's write), the pin shows B stamped on insert, update, delete and re-parent. Fix inside the claim's file surface: the recompute's master update carries an engine-only Symbol.for option (SUMMARY_RECOMPUTE_WRITE, engine-summaries-and-expansion.ts). The update stamp hook (plugin.ts) reads it off input.options and writes updated_by = null (ADR-0118 D1, only where the column exists) and a fresh updated_at. The master's hooks and flows keep the caller's context, so nothing else changes. All four child paths go through the one write. Field history: the CRUD audit writer already skips summary-only diffs, so no ledger row is written, and the dogfood pin asserts that no row names the child writer. Card assignee not touched.",
      "tests": "Head 24f850943a (after the origin/main merge), under os-verify-lock (VERDICT command-exit 0): objectql typecheck exit 0; `pnpm --filter @objectstack/objectql test` Test Files 599 passed (599), Tests 13285 passed (13285); dogfood pin `pnpm --filter @objectstack/dogfood exec vitest run --maxWorkers=2 test/summary-recompute-system-stamp.dogfood.test.ts` Tests 3 passed (3), after `pnpm --filter '@objectstack/dogfood^...' build` exit 0. Unit pin src/engine-summary-recompute-audit-actor.test.ts at f89df01cd3: green 5/5. Ablation via ablation-replace (marker removed from the recompute call, i.e. main's write; anchor 1->0) gave 4 failed and 1 passed, with each of insert/update/delete/re-parent failing on `expected 'u_child_writer_b' to be null` while the CONTROL (B's direct edit stamps B) passed. Restored: blob == HEAD, git diff HEAD empty. Dogfood dist ablation: the hook's marker read was replaced by a never-true expression, objectql rebuilt, and ablation-dist-preflight found the marker in 2 built files. Result 1 failed, 2 passed, `expected 'Cn8RZN9WCVK0GCCNpkmfRXg6YsOd4y1m' to be null` (the member stamped on showcase_project). Restore leg: blob == HEAD, rebuild, preflight --absent (marker absent from 14 files), 3/3 green. The first dogfood ablation was a no-op (its replacement left hookCtx unread, the DTS build failed TS6133, and the suite never ran); it was redone and is declared in the PR body.",
      "gates": "Local: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, re-derived at 24f850943a (same 75-command list as before the merge). All 75 were run with `cmd > log 2>&1; EXIT=$?`: 74 exit 0, and check:dual-build-cjs-loads exit 3 (PREREQUISITE NOT MET: dist/ missing for packages outside the closure, studio/client-react/embedder-openai/…; NOT MEASURED locally, CI runs it). check:type-check-debt exit 0 (re-measure OK, 0 entries above record). check:objectql-double-limit: the new driver double was first flagged limit-blind and then shape-breaking; the double was fixed, and the gate is OK (755 graded). `dispatch-gates --ran` gives 75 derived, 75 run, 0 UNRUN (exit 0). PR body gates exit 0: check-changeset-no-major, check-adr-0087-registration, check-closing-keyword-parity, check-partof-closing-keyword. CI check-runs on 24f850943a: 36 success, 16 skipped, 0 failure. Among them: Lint & Repo Gates success, TypeScript Type Check success, Test Core success (8/8 shards), Build Core success, Governed Surface Queue Guard success, Dogfood Regression Gate success, Live E2E UI success, Test UI success, Lint · ESLint success, Check Changeset success, PR-body guards success. Lint UI, Type Check UI and Build & E2E UI were skipped (no ui/ diff).",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm; only the new pin was run (3/3 at 24f850943a)",
      "mcp_calls": "0",
      "api_writes": "2 — fleet-write relay pr_create (objectstack-ai/objectstack#34242, read back byte-identical); post-stamped issue comment on #33950 (this report)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — packages/objectql/src/engine.ts docblock on ScopedRepo.execute elevation says recomputeSummaries' systemCtx stamps updated_by from userId; now stale for the recompute only (comment text, outside the file surface); in PR Acceptance notes",
        "carrier: none · noted, not filed — other system-elevated writes that carry no userId (e.g. backfillSummaryNulls, lifecycle sweeps) leave updated_by untouched rather than null (ADR-0118 D1); not in the ruling's scope, observation only"
      ],
      "deviations": [
        "Commit trailers use the model-free pair (dev-common/AGENTS.md); the harness reminder's model-named Co-Authored-By was not copied.",
        "PR body first line is the dev-common-ordered attribution HTML comment (the harness-attribution exception).",
        "The PR body Verification section cites readings at f89df01cd3 (taken before the merge) and declares typecheck and the full suite as NOT MEASURED locally, because the shared lock was held by a sibling dogfood battery for more than 50 minutes. They were measured afterwards at the final head (green, see tests), and these readings are only in this report, since the dev cannot PATCH the body. The seat may update the body.",
        "dev-common pre-push asks for the tests of direct dependents and `pnpm lint`. os-dev.md was followed instead: no public export changed (the symbol is not re-exported from index.ts/core.ts), so importers owe no tests, and repo-wide lint belongs to CI (Lint · ESLint success). test:repo was not run locally (Test Core in CI)."
      ],
      "merge_tree": "git merge-tree --write-tree clean against origin/main (98a4449f87), PR #33887 head and PR #33652 head (the only open PRs in neighbouring objectql write files; none touches engine-summaries-and-expansion.ts or plugin.ts). origin/main merged as 24f850943a; no parallel fix on main (grep for SUMMARY_RECOMPUTE_WRITE and a null updated_by stamp: none).",
      "files_changed": [
        ".changeset/33950-summary-recompute-system-stamp.md",
        "packages/objectql/src/engine-summaries-and-expansion.ts",
        "packages/objectql/src/plugin.ts",
        "packages/objectql/src/engine-summary-recompute-audit-actor.test.ts",
        "packages/qa/dogfood/test/summary-recompute-system-stamp.dogfood.test.ts"
      ],
      "line_budget": "+411 / -4 across 5 files (source: +40/-1 engine-summaries-and-expansion.ts, +31/-3 plugin.ts; the rest are tests and the changeset); under the 3000-line threshold",
      "pr_state": "draft, CI all green at 24f850943a; no reviewers requested, not readied or armed"
    }
  7. removed
    pm:dispatched
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions