Skip to content

fix(AC0032): count CalcSums as a read operation - #580

Merged
Arthurvdv merged 5 commits into
mainfrom
fix/ac0031-ac0032-calcsums-read
Oct 10, 2026
Merged

Arthurvdv merged 5 commits into
mainfrom
fix/ac0031-ac0032-calcsums-read

Conversation

@Arthurvdv

@Arthurvdv Arthurvdv commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Summary

CalcSums is a SQL aggregate over the receiver table, run in the calling object, so it needs read permission there. It was missing from MethodOperationMap, so a codeunit whose only access is SetRange + CalcSums had its tabledata X = r reported as unused by AC0032, and AC0031 did not flag a missing r.

  • Add CalcSums as a Read in MethodOperationMap (AC0031 and AC0032 both pick it up; temporary records stay exempt).
  • RecordMethodClassification.ReadMethods intentionally still excludes it (same reasoning as Next: it does not fill a record buffer).
  • CalcFields is deliberately not included: the read lands on the FlowField's CalcFormula source table, not the receiver, so mapping it would charge the wrong table. This needs FlowField source resolution and is left for a separate change. The table-procedure claim in the issue is also still open.
  • .claude rule docs updated.

Behaviour change: AC0031 now reports CalcSums on a non-temporary record not covered by any permission source, so existing projects may see new AC0031 diagnostics.

Refs #578 (findings for CalcFields and the table-procedure case: #578 (comment))

Tests

TDD: new fixtures failed before the map change (AC0031 HasDiagnostic/CalcSumsWithoutPermissions, AC0032 NoDiagnostic/CalcSumsOnly) and pass after.

  • AC0031: HasDiagnostic/CalcSumsWithoutPermissions, HasDiagnostic/CalcSumsWithoutReadPermission (= m without r), HasDiagnostic/CalcSumsBareSelf, NoDiagnostic/CalcSumsWithPermissions, NoDiagnostic/CalcSumsTemporaryRecord
  • AC0032: NoDiagnostic/CalcSumsOnly, NoDiagnostic/CalcSumsBareSelf, HasDiagnostic/CalcSumsPartialUnused, HasDiagnostic/CalcSumsTemporaryRecordOnly
  • Full dotnet test ALCops.sln green, dotnet format --verify-no-changes clean, Release CI-TFM builds of ApplicationCop and Common clean, Validate-Rules.ps1 passes.

Review

/code-review (Sonnet, high) — round 1 reviewed the wrong checkout and was discarded; round 2 ran in the PR worktree: no correctness findings. Test-coverage findings addressed: AC0032 temporary-only CalcSums, AC0031 = m without r, bare-self CalcSums for both rules. Not changed, with reason: full receiver-form fixture set (receiver resolution is method-agnostic and already covered by the existing receiver-form fixtures); name-only matching in MethodOperationMap (same as every other entry; AL forbids user methods shadowing built-ins); a test pinning ReadMethods exclusion (record-method-classification.md already states membership is not symmetric).

Round 3 (final): one real finding fixed, an empty [||] marker in AC0032 NoDiagnostic/CalcSumsBareSelf that could not catch a regression. Not changed: the reported "unrelated AC0002 commit" is already on main (stale local base); TableType = Temporary, RecordRef/same-named-procedure and receiver-form fixtures are generic to every MethodOperationMap entry and covered by existing fixtures; the fixtures-before-fix commit order is the intended TDD sequence (squash merge keeps main bisectable).

Docs PR: ALCops/alcops.dev#201

🤖 Generated with Claude Code

Arthurvdv and others added 3 commits October 10, 2026 16:41
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
CalcSums is a SQL aggregate over the receiver table, executed in the calling
object, so it needs read permission there. Without it a codeunit whose only
access is SetRange + CalcSums looked like it never read the table, and AC0032
reported its tabledata entry as unused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Arthurvdv and others added 2 commits October 10, 2026 17:15
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ture

An empty marker spans nothing, so the NoDiagnostic assertion passed even
if AC0032 reported the entry.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Arthurvdv
Arthurvdv merged commit 535330b into main Oct 10, 2026
46 checks passed
@Arthurvdv
Arthurvdv deleted the fix/ac0031-ac0032-calcsums-read branch October 10, 2026 15:28
Arthurvdv added a commit that referenced this pull request Oct 17, 2026
This reverts commit 535330b.

Runtime probes on BC 29 (Docker) and BC 28.5 (SaaS) showed CalcSums and
CalcFields succeed with only the user's indirect permission, whether or
not the calling object declares tabledata X = r, so the change would make
AC0031 ask for permissions that have no effect.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant