Skip to content

feat(rules): add Dhall review rules - #963

Merged
lizhengfeng101 merged 5 commits into
alibaba:mainfrom
chethanuk:wf/dhall-language-support
Nov 19, 2026
Merged

lizhengfeng101 merged 5 commits into
alibaba:mainfrom
chethanuk:wf/dhall-language-support

Conversation

@chethanuk

Copy link
Copy Markdown
Contributor

Description

.dhall files were never reviewed. The extension is missing from supported_file_types.json, so IsAllowedExt drops them at the filter gate before any rule can run, which is why a rule doc on its own would never have been reachable.

This adds .dhall to the allowlist and registers one rule doc in path_rule_map: **/*.dhall → dhall.md. Data only, no Go source changes.

The headline check is a remote import by URL with no trailing sha256:<hex> integrity hash. Dhall resolves those over the network when the file is evaluated, so an unpinned import hands whoever controls that URL control of the configuration, and the content it returns can change between two evaluations of the same file. dhall freeze writes the hash.

Two carve-outs keep that check usable. The Prelude's missing sha256:<hex> ? ./local.dhall idiom is a content-addressed cache lookup with a working local fallback rather than an unpinned import, and it sits at the top of nearly every file that imports the Prelude. Bare relative imports (./types.dhall) are the overwhelming majority of imports in a project and pinning them is not the convention. The totality section carves out Natural/fold and List/fold for the same reason: folds are how iteration is written in a language with no recursion, so flagging them would fire on almost every file.

No exclude patterns are added. IsExcludedPath applies every pattern to every path with no language dispatch, so a pattern is only worth its repo-wide reach when it matches paths that are reliably test-only or generated. Dhall has neither in tree. Its import cache lives under $XDG_CACHE_HOME/dhall, outside the repository, so it never appears in a diff, and there is no vendored dependency directory or build output to skip.

Limitation

.dhall diffs that used to be skipped are now reviewed. Anyone who does not want that opts out with user exclude globs, which are checked before the allowlist.

Type of Change

  • New feature (non-breaking change that adds functionality)

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Rows appended to the existing table tests:

  • TestIsAllowedExt — .dhall and .DHALL.
  • TestResolve_DefaultRules — config/prod.dhall and schemas/package.dhall resolve by a heading anchor unique to dhall.md.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

The rule table in pages/src/content/docs/{en,ja,ru,zh}/review-rules.md lists the new pattern.

Related Issues

Part of #470.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s).

@chethanuk
chethanuk force-pushed the wf/dhall-language-support branch from 4bead34 to e685498 Compare August 17, 2026 06:19
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Please review and merge this. Future main updates might cause more conflicts. Thanks :)

@chethanuk
chethanuk force-pushed the wf/dhall-language-support branch from e685498 to 611b2cd Compare August 17, 2026 07:35
@chethanuk
chethanuk force-pushed the wf/dhall-language-support branch 2 times, most recently from 848246c to 4579f84 Compare August 18, 2026 08:55
`.dhall` was missing from the extension allowlist, so Dhall files were
filtered out before rule resolution ever ran and no review rule could
apply to them. This adds `.dhall` to the allowlist, adds a
`**/*.dhall` -> `dhall.md` entry to `path_rule_map`, and lists the
mapping in the review-rules docs table for all four locales.

The rule doc leans on what Dhall's type checker cannot already catch:
unpinned remote imports missing a `sha256:` hash, stale hashes after an
import target moves, `env:` secrets leaking into rendered artifacts, and
self-referential `let` bindings (the language is total, so recursion is
a design error rather than a style nit). It explicitly does not flag
bare relative imports or the Prelude's `missing sha256:... ? ./local`
cache idiom, both of which look like unpinned imports but are not.
@chethanuk
chethanuk force-pushed the wf/dhall-language-support branch from 4579f84 to 32e4c89 Compare August 21, 2026 06:03
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Rebased onto main and conflicts resolved. Please review and merge this. Thanks :)

Main's Objective-C/MATLAB `.m` rule appended to the same rule-resolution
table and the same pattern table in all four locales of review-rules.md that
this branch appends the Dhall rows to. Kept both, main's first.

Claude-Session: https://claude.ai/code/session_01FoMHZQ3qqdt98LHTwSJuTG
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Rebased onto main and conflicts resolved again. Please review this. Thanks :)

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Thanks for the contribution! Clean data-only change following the established patterns.

Dhall has a fairly small user base, so I'd like to wait for someone with hands-on Dhall experience to review the rule doc before merging. I want to make sure the checks reflect real-world Dhall pitfalls rather than theoretical ones.

Leaving this open — happy to merge once a domain expert signs off.

…port

Signed-off-by: ChethanUK <[email protected]>

# Conflicts:
#	internal/config/allowlist/allowed_ext_test.go
#	internal/config/allowlist/supported_file_types.json
#	internal/config/rules/system_rules_test.go
#	pages/src/content/docs/en/review-rules.md
#	pages/src/content/docs/ja/review-rules.md
#	pages/src/content/docs/ru/review-rules.md
#	pages/src/content/docs/zh/review-rules.md
Rule docs resolve per file, so the generated YAML/JSON section in dhall.md
could never apply. The self-referencing let, non-exhaustive merge and
completion typo cases are already type errors, and the fold-bound and
Optional-default rules needed intent a reviewer cannot see.

Reading a credential from env: is the right pattern, so only a
real-looking secret fallback is flagged now. The stale-hash rule now
says what happens: a warm cache keeps serving the old content by hash
and a cold cache fails. Adds two real pitfalls: env: without `as Text`
for a Text value, and `//` used for a nested update where `with` was
meant.

Also adds the Dhall row to the Korean rule table that came in from main.

Signed-off-by: ChethanUK <[email protected]>
@lizhengfeng101

Copy link
Copy Markdown
Contributor

@chethanuk merge conflicts

Resolve conflicts with the GLSL/HLSL/WGSL/Metal, EJS/Liquid/Nunjucks,
Clojure/EDN, CUDA/HIP, PowerShell and Move additions: keep both sides
in the allowlist and test tables, and slot the `**/*.dhall` row after
`**/*.bicep` in the review-rules tables to match system_rules.json.

Signed-off-by: ChethanUK <[email protected]>
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Merged main in 3507c22 and resolved the conflicts. The **/*.dhall row now sits after **/*.bicep in the review-rules.md tables, same order as system_rules.json. go test ./internal/config/... passes and the PR is mergeable again. Thanks :)

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit b87ca79 into alibaba:main Nov 19, 2026
15 checks passed
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.

3 participants