Skip to content

fix: web profiler export records resolved params, not sparse currentOpts - #535

Merged
yakew7 merged 1 commit into
yakew7:mainfrom
propcgamer20-png:fix/web-export-resolved-params
Sep 9, 2026
Merged

fix: web profiler export records resolved params, not sparse currentOpts#535
yakew7 merged 1 commit into
yakew7:mainfrom
propcgamer20-png:fix/web-export-resolved-params

Conversation

@propcgamer20-png

Copy link
Copy Markdown
Collaborator

Problem

assets/profiler-ui.js and assets/profiler-compare.js both build the export's provenance as:

params: Object.assign({}, currentOpts),

currentOpts starts as {} on every upload and only gains a key when the user manually edits a threshold input. So for any plain run where no threshold is touched (the common case), provenance.params is exported as {} - not the 7 resolved defaults that SPEC.md section 10 requires ("the knobs of section 7 as resolved, defaults included") and that the Python CLI/MCP path already records via provenance.public_params.

python: {'cross': None, 'imbalance_flag': 3.0, 'intersection_floor': 0.01,
         'min_group_size': 100, 'min_share': 0.05, 'missing_flag': 0.05,
         'reference_flag': 0.05}
js:     {}

An export that omits every default threshold can't answer "was this produced from these thresholds" after the fact.

Fix

New E.publicParams(opts) in profiler-engine.js, mirroring faircode.provenance.public_params(faircode.profiler._resolve_opts(opts)):

function publicParams(opts) {
  var resolved = resolveOpts(opts);          // merge over DEFAULT_OPTS
  var out = {};
  Object.keys(resolved).sort().forEach(function (k) {
    if (!OPAQUE_PARAMS[k]) out[k] = resolved[k];   // drop the parsed `reference` object
  });
  return out;
}

Exported from the engine, and used at both params: sites. A user-set threshold still shows through (publicParams({min_share: 0.2}) -> min_share: 0.2, rest defaulted).

Test

test_python_js_public_params_parity_for_a_defaulted_run - asserts E.publicParams({}) (run under Node) equals public_params(_resolve_opts(None)) and carries exactly the 7 expected keys, reference not among them.

pytest tests/test_js_parity.py -> 22 passed, 1 failed (test_python_js_profiler_parity_sniffs_quoted_newlines, pre-existing on main on this platform, unrelated).

Closes #490

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@propcgamer20-png 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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

@yakew7 @ahmdkaml - new PR touching a path you own, please review.

@propcgamer20-png
propcgamer20-png force-pushed the fix/web-export-resolved-params branch from 6773760 to e7b5a66 Compare September 9, 2026 15:28
@yakew7

yakew7 commented Sep 9, 2026

Copy link
Copy Markdown
Owner

@propcgamer20-png fix the conflicts

@propcgamer20-png
propcgamer20-png force-pushed the fix/web-export-resolved-params branch 2 times, most recently from c1132a7 to 64fa6c3 Compare September 9, 2026 16:13
profiler-ui.js and profiler-compare.js built provenance.params as
Object.assign({}, currentOpts). currentOpts starts {} on every upload and
only gains a key when the user edits a threshold input, so for the common
case (no threshold touched) the exported params was {} - not the 7
resolved defaults SPEC.md section 10 requires, and which the Python
CLI/MCP path already records.

Added E.publicParams(opts) to the engine, mirroring
faircode.provenance.public_params(faircode.profiler._resolve_opts(opts)):
resolveOpts merge, drop the opaque `reference` structure, key-sorted.
Both export sites now use it.

Closes yakew7#490
@propcgamer20-png
propcgamer20-png force-pushed the fix/web-export-resolved-params branch from 64fa6c3 to b447287 Compare September 9, 2026 16:16
@yakew7
yakew7 merged commit a6583d1 into yakew7:main Sep 9, 2026
15 of 16 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.

Web profiler's "Copy as JSON" exports provenance.params as whatever the user typed, not the resolved defaults SPEC.md requires

2 participants