Add JS/Python profiler parity tests - #126
Merged
Merged
Conversation
Contributor
|
@ahmdkaml is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds automated Python↔JavaScript profiler parity checks (per faircode/SPEC.md / issue #110) by introducing a Node.js harness, fixture-backed pytest parity tests, and CI provisioning for Node so parity runs on every PR.
Changes:
- Add
scripts/profile-js.jsNode harness to execute the JS profiler engine and emit JSON. - Add pytest parity coverage across multiple fixture CSVs (including new
small.csvandcredit_customers.csv). - Update JS engine behavior to better align with the Python profiler (
"none"handling andsmall_groupreliability flags), and update CI (audits.yml) to install Node 20 for profiler tests.
Reviewed changes
Copilot reviewed 5 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_js_parity.py | Adds Python↔JS parity test that runs Node harness and compares profiler JSON results. |
| tests/fixtures/small.csv | New minimal fixture dataset for parity testing. |
| tests/fixtures/credit_customers.csv | New larger categorical-heavy fixture dataset for parity testing. |
| scripts/profile-js.js | New Node.js harness to run the JS profiler engine from CI/tests and print JSON. |
| assets/profiler-engine.js | Adjusts missing-token handling and adds small_group flag messages in JS to match Python behavior. |
| .github/workflows/audits.yml | Provisions Node.js in the profiler job so parity tests can run in CI. |
Suppressed comments (2)
tests/test_js_parity.py:36
subprocess.run(["node", "scripts/profile-js.js", ...])will fail if the test is executed from a non-repo-root working directory. Using the resolved harness path (and the discoveredNODEexecutable) makes this robust and matches how the CSV path is handled.
completed = subprocess.run(
["node", "scripts/profile-js.js", str(csv)],
capture_output=True,
text=True,
encoding="utf-8",
tests/test_js_parity.py:46
- The parity assertion currently drops
flagsentirely.flagsare part of the profiler contract (and are tested on the Python side in tests/test_profiler.py), so excluding them means JS flagging drift could slip through even if the structured metrics still match. If exact string formatting is too brittle across languages, consider comparing a normalized form of the flags (e.g., stripping numeric literals) in addition to the full structured JSON.
# Flags are human-readable messages. They duplicate information already
# present in the structured output and may differ because Python and
# JavaScript format floating-point values differently (e.g. 6.25 -> 6.2
# vs 6.3). Compare the structured data instead.
python_result = dict(python_result)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+13
| from pathlib import Path | ||
| import json | ||
| import subprocess | ||
|
|
||
| import pandas as pd | ||
| import pytest | ||
|
|
||
| from faircode import profile | ||
|
|
||
| FIXTURES = Path(__file__).resolve().parent / "fixtures" | ||
|
|
yakew7
added a commit
that referenced
this pull request
Aug 4, 2026
The parity test suite added in #126 copied 25MB of dataset CSVs into tests/fixtures/ that are byte-identical to files already tracked in their audit folders. Point the tests at the existing datasets instead.
yakew7
added a commit
that referenced
this pull request
Aug 4, 2026
The parity test suite added in #126 copied 25MB of dataset CSVs into tests/fixtures/ that are byte-identical to files already tracked in their audit folders. Point the tests at the existing datasets instead.
yakew7
added a commit
that referenced
this pull request
Aug 4, 2026
…rity work Documents the FAQPage JSON-LD + sitemap lastmod, llms-full.txt, the homepage FAQ/Contact/Legal section, PR #126's JS/Python profiler parity tests, and the fixture-dedup fix. README's Connect section gained the same contact email and FAQ link for consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
scripts/profile-js.js) to execute the JavaScript profiler from CI."none"as a categorical value instead of treating it as missing.small_groupreliability flags.This automates the Python↔JavaScript parity check described in
SPEC.mdand helps prevent future implementation drift.Closes #110