Skip to content

AuditCheck: P_I_AgeTooHigh - age too high - #1732

Merged
kaligrafy merged 1 commit into
chairemobilite:mainfrom
kaligrafy:auditChecksOldAge
Jul 30, 2026
Merged

AuditCheck: P_I_AgeTooHigh - age too high#1732
kaligrafy merged 1 commit into
chairemobilite:mainfrom
kaligrafy:auditChecksOldAge

Conversation

@kaligrafy

@kaligrafy kaligrafy commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

AuditCheck: P_W_VeryOldAge - very old age

Add audit checks for person age:

  • P_I_AgeTooHigh: error when age > maxPersonAge, default 125
  • P_W_VeryOldAge: warning when age between veryOldPersonAge and maxPersonAge, default 100–125

Update project config:

  • Add maxPersonAge and veryOldPersonAge
  • Update minReviewPersonAge to match veryOldPersonAge

Update age real time validation according to new project config

Summary by CodeRabbit

  • New Features
    • Added configurable person age audit thresholds (maxPersonAge) and an optional “very old age” warning threshold.
    • Added new audit outcomes for implausibly high ages (error) and very old ages (warning), with English and French message support.
  • Bug Fixes
    • Person age validation now uses the configurable maxPersonAge instead of a fixed limit.
  • Tests
    • Added coverage for the new age-based audit checks.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3c8ac5da-1ea2-4203-b838-4590d551a453

📥 Commits

Reviewing files that changed from the base of the PR and between 319e83d and adfae60.

📒 Files selected for processing (8)
  • locales/en/audits.json
  • locales/fr/audits.json
  • packages/evolution-backend/src/services/audits/auditChecks/checks/PersonAuditChecks.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_I_AgeTooHigh.test.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_W_VeryOldAge.test.ts
  • packages/evolution-common/src/config/__tests__/project.config.test.ts
  • packages/evolution-common/src/config/project.config.ts
  • packages/evolution-common/src/services/widgets/validations/validations.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: pr-build-check
  • GitHub Check: test-sequential (24.x)
  • GitHub Check: check-format
  • GitHub Check: code-lint
  • GitHub Check: build-and-test (24.x)
  • GitHub Check: generate-and-build-generator (24.x)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-03-31T18:20:32.322Z
Learnt from: kaligrafy
Repo: chairemobilite/evolution PR: 1462
File: packages/evolution-common/src/services/baseObjects/Completable.ts:1-6
Timestamp: 2026-03-31T18:20:32.322Z
Learning: In this repository (chairemobilite/evolution), do not flag or require a copyright year in file headers. For new files, the header format `Copyright Polytechnique Montreal and contributors` (without a year) is acceptable. Only verify the header presence/consistency, not the presence of the year.

Applied to files:

  • packages/evolution-common/src/config/__tests__/project.config.test.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_I_AgeTooHigh.test.ts
  • packages/evolution-common/src/services/widgets/validations/validations.ts
  • packages/evolution-common/src/config/project.config.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/PersonAuditChecks.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_W_VeryOldAge.test.ts
📚 Learning: 2026-04-21T14:52:21.885Z
Learnt from: kaligrafy
Repo: chairemobilite/evolution PR: 1510
File: packages/evolution-backend/src/services/audits/auditChecks/README.md:148-149
Timestamp: 2026-04-21T14:52:21.885Z
Learning: When adding a new backend audit check error code in the Evolution project, you must also add the corresponding translations in locales/en/audits.json and locales/fr/audits.json. This is required because the UI looks up error codes via t('audits:${errorCode}') and the CI test AuditLocales.test.ts enforces that all audit error codes have locale entries; without the locale keys, the build should fail.

Applied to files:

  • locales/en/audits.json
  • locales/fr/audits.json
🔇 Additional comments (5)
packages/evolution-common/src/config/project.config.ts (1)

86-95: LGTM!

Also applies to: 258-259

packages/evolution-common/src/services/widgets/validations/validations.ts (1)

223-223: LGTM!

Also applies to: 251-251

packages/evolution-backend/src/services/audits/auditChecks/checks/PersonAuditChecks.ts (1)

2-14: LGTM!

Also applies to: 38-142

locales/en/audits.json (1)

34-35: LGTM!

locales/fr/audits.json (1)

34-35: LGTM!


Walkthrough

Added configurable maximum and review-threshold ages to project configuration and widget validation. Added backend audit checks and localized messages for ages above the maximum and very old ages. Added parameterized tests covering threshold boundaries, typical ages, and missing values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • #1741 — Relates to the P_I_AgeTooHigh audit check and its localized message handling.

Suggested reviewers: greenscientist, mathildemoliner, tahini

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clear and accurately reflects one of the main changes: the new P_I_AgeTooHigh audit check.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: one or more packages not found in the registry.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kaligrafy
kaligrafy force-pushed the auditChecksOldAge branch from e1db6c6 to efd6cdd Compare July 21, 2026 18:49
Comment thread locales/en/audits.json Outdated
"HM_I_geographyNotInSurveyTerritory": "Home geography is outside the survey territory",

"P_M_Age": "Person age is missing",
"P_I_AgeTooHigh": "Person age is too high (should be at most 125)",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems that maxPersonAge is a variable, with 125 being the default.
Therefore, shouldn't the error message be dynamic and display maxPersonAge, instead of a hardcoded '125'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Voir commentaire plus bas

errorCode: 'P_W_VeryOldAge',
version: 1,
level: 'warning',
message: 'Person age is very high (please verify, between 100 and 125)',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment here, 100 and 125 should be minReviewPersonAge and maxPersonAge instead.
Also, what's the difference between the message defined here, and in audits.json? (I see they're slightly different)

@kaligrafy kaligrafy Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bonne observation. La logique utilise projectConfig.maxPersonAge / minReviewPersonAge, mais l’UI admin affiche t('audits:' + errorCode) depuis locales/*/audits.json — pas audit.message, et pas d’interpolation aujourd’hui. C’est la même chose que HH_I_Size (pas d'interpolation, valeurs en raw). Pour cette PR, je propose de garder 125/100 dans les locales alignés sur les defaults de project.config.ts. L’interpolation i18n de projectConfig dans AuditDisplay serait un autre issue séparé si on veut généraliser ça.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kaligrafy kaligrafy Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The localized stings have been updated to remove any hardcoded values. Until #1741 is fixed, we should remove any interpolated data in the error localized strings.

@github-actions

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/evolution-common/src/config/__tests__/project.config.test.ts`:
- Around line 18-19: Add isolated non-default threshold coverage: in
packages/evolution-common/src/config/__tests__/project.config.test.ts lines
18-19, set and assert non-default maxPersonAge and minReviewPersonAge, restoring
shared configuration afterward; in
packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_I_AgeTooHigh.test.ts
lines 17-43, verify the error boundary uses the configured maximum; and in
packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_W_VeryOldAge.test.ts
lines 17-45, verify the warning range uses the configured minimum and maximum.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 75adaf7a-826b-425b-8b16-068a1ee7f5fd

📥 Commits

Reviewing files that changed from the base of the PR and between b8dc98b and 319e83d.

📒 Files selected for processing (8)
  • locales/en/audits.json
  • locales/fr/audits.json
  • packages/evolution-backend/src/services/audits/auditChecks/checks/PersonAuditChecks.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_I_AgeTooHigh.test.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_W_VeryOldAge.test.ts
  • packages/evolution-common/src/config/__tests__/project.config.test.ts
  • packages/evolution-common/src/config/project.config.ts
  • packages/evolution-common/src/services/widgets/validations/validations.ts
📜 Review details
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-03-31T18:20:32.322Z
Learnt from: kaligrafy
Repo: chairemobilite/evolution PR: 1462
File: packages/evolution-common/src/services/baseObjects/Completable.ts:1-6
Timestamp: 2026-03-31T18:20:32.322Z
Learning: In this repository (chairemobilite/evolution), do not flag or require a copyright year in file headers. For new files, the header format `Copyright Polytechnique Montreal and contributors` (without a year) is acceptable. Only verify the header presence/consistency, not the presence of the year.

Applied to files:

  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_W_VeryOldAge.test.ts
  • packages/evolution-common/src/config/__tests__/project.config.test.ts
  • packages/evolution-common/src/services/widgets/validations/validations.ts
  • packages/evolution-common/src/config/project.config.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/__tests__/person/P_I_AgeTooHigh.test.ts
  • packages/evolution-backend/src/services/audits/auditChecks/checks/PersonAuditChecks.ts
📚 Learning: 2026-04-21T14:52:21.885Z
Learnt from: kaligrafy
Repo: chairemobilite/evolution PR: 1510
File: packages/evolution-backend/src/services/audits/auditChecks/README.md:148-149
Timestamp: 2026-04-21T14:52:21.885Z
Learning: When adding a new backend audit check error code in the Evolution project, you must also add the corresponding translations in locales/en/audits.json and locales/fr/audits.json. This is required because the UI looks up error codes via t('audits:${errorCode}') and the CI test AuditLocales.test.ts enforces that all audit error codes have locale entries; without the locale keys, the build should fail.

Applied to files:

  • locales/en/audits.json
  • locales/fr/audits.json
🔇 Additional comments (5)
packages/evolution-common/src/config/project.config.ts (1)

86-95: LGTM!

Also applies to: 258-259

packages/evolution-common/src/services/widgets/validations/validations.ts (1)

223-223: LGTM!

Also applies to: 251-251

packages/evolution-backend/src/services/audits/auditChecks/checks/PersonAuditChecks.ts (1)

2-8: LGTM!

Also applies to: 35-88

locales/en/audits.json (1)

31-32: LGTM!

locales/fr/audits.json (1)

31-32: LGTM!

Comment thread packages/evolution-common/src/config/__tests__/project.config.test.ts Outdated

@tahini tahini 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.

Quelques considérations

* Age from which a person age triggers a reviewer warning audit (inclusive).
* Applies up to {@link maxPersonAge}. Defaults to 100.
*/
minReviewPersonAge: number;

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.

Il va falloir qu'on fasse du ménage dans les configurations d'âge, on commence à en avoir beaucoup de différents! Pour la prochaine version d'Evolution...

Aussi, je ne suis pas certaine de ce nom, 1- ça concerne les audits uniquement, 2- ça ajouter simplement un warning, donc addAuditWarningAge? Et le default pourrait être undefined si on ne veut pas de warning. Ou à tout le moins mettre ce champ optionnel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

default = undefined

const { person } = context;
const age = person.age;

if (age !== undefined && age !== null && age > projectConfig.maxPersonAge) {

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.

typeof age === 'number' à la place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

AuditCheck: P_W_VeryOldAge - very old age

Add audit checks for person age:
- P_I_AgeTooHigh: error when age > `maxPersonAge`, default 125
- P_W_VeryOldAge: warning when age between `addAuditWarningOldAge` and `maxPersonAge`, default disable (addAuditWarningOldAge = undefined)

Update project config:
- Add `maxPersonAge` and `addAuditWarningOldAge`

Update age real time validation according to new project config
@kaligrafy
kaligrafy force-pushed the auditChecksOldAge branch from 319e83d to adfae60 Compare July 30, 2026 13:43
@kaligrafy
kaligrafy requested a review from tahini July 30, 2026 13:43
@kaligrafy
kaligrafy merged commit fc96717 into chairemobilite:main Jul 30, 2026
7 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