Skip to content

feat: add public OTSL and synthetic-data tooling - #1

Open
yushuosun wants to merge 3 commits into
mainfrom
feat/public-synthetic-data-tooling
Open

feat: add public OTSL and synthetic-data tooling#1
yushuosun wants to merge 3 commits into
mainfrom
feat/public-synthetic-data-tooling

Conversation

@yushuosun

@yushuosun yushuosun commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add public OTSL decoding normalization, fixed-denominator paired metrics, and synthetic manifest validation.
  • Add a KEEP-majority Raw-preserving pair contract with Gold-only offline labels and a Gold-free runtime selector view.
  • Add terminal-blind family planning and rendering, streaming family/overlap/shortcut audits, exact all-KEEP rollback checks, and token-geometry counterfactual fixtures.
  • Bind formal records to relative image paths, SHA256, generator policy, family-plan provenance, license, and non-redistributed font metadata.

Safety and claim boundaries

  • Raw remains the default output; missing, invalid, tied, or unsupported candidates return exact Raw.
  • Perceptual overlap is fail-closed: dHash is only a high-recall screen and pHash confirms blockers. Family IDs alone are not treated as proof of visual isolation.
  • Selector-only reports identify controlled offline-Gold positive candidates and explicitly set candidate_generation_evaluated=false; they do not claim a deployable candidate generator.
  • No datasets, benchmark pages, customer content, model weights, predictions, experiment outputs, credentials, or internal paths are included.

Validation

  • git diff --check passed.
  • All 30 Python files passed py_compile.
  • 29/29 committed test functions passed through a zero-dependency direct fixture runner.
  • Formal terminal-blind records (30/30) and legacy-mode records (10/10) passed the Draft 2020-12 JSON Schema.
  • Full pytest was not run because pytest is absent locally and temporary dependency download was denied by the execution safety policy.

Notes

  • Pillow-backed rendering and perceptual overlap checks are isolated in the optional synthesis dependency group.
  • Generated corpora and audit outputs remain external to this repository.

Expose reproducible OTSL normalization, fixed-denominator paired metrics, and synthetic manifest validation while documenting the provenance and scope of the privately shared synthetic corpora.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 12, 2026 03:58

Copilot AI 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.

Pull request overview

This PR adds public-facing research utilities to the mpr_tsr_splitmerge_v2 package, including OTSL post-decode normalization helpers, paired fixed-denominator metric summaries, and lightweight synthetic-manifest validation plus provenance documentation.

Changes:

  • Introduces OTSL normalization/validation utilities and a small paired-metrics summarizer module.
  • Adds a CLI script to validate synthetic-data manifests against an asset root.
  • Adds documentation updates (README scope bullets + synthetic provenance doc) and tests for the new public utilities.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_public_research_tools.py Adds tests covering OTSL normalization and paired-metrics summary behavior.
src/mpr_tsr_splitmerge_v2/paired_metrics.py Implements paired fixed-denominator summary metrics including LOO summaries.
src/mpr_tsr_splitmerge_v2/otsl.py Adds OTSL normalization, chat-control stripping, and structure-token validation helpers.
scripts/validate_synthetic_manifest.py Adds a standalone manifest validator for synthetic assets and path safety.
README.md Updates the “Current repository scope” list to mention new public utilities and provenance tooling.
docs/SYNTHETIC_DATA_PROVENANCE.md Adds provenance documentation for synthetic corpora (SynthFin v3.4 and invoice-synthetic-v1).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +42 to +59
largest_index = max(range(len(deltas)), key=lambda index: abs(deltas[index]))
largest = deltas[largest_index]
loo_denominator = denominator - baseline[largest_index][1]
if loo_denominator <= 0:
raise ValueError("leave-one-out denominator must be positive")
loo_delta = candidate_correct - baseline_correct - largest
return PairedSummary(
baseline_correct=baseline_correct,
candidate_correct=candidate_correct,
fixed_denominator=denominator,
delta_correct=candidate_correct - baseline_correct,
delta_pp=100.0 * (candidate_correct - baseline_correct) / denominator,
help_count=sum(delta > 0 for delta in deltas),
hurt_count=sum(delta < 0 for delta in deltas),
same_count=sum(delta == 0 for delta in deltas),
largest_absolute_delta=largest,
leave_one_out_delta_pp=100.0 * loo_delta / loo_denominator,
)
Comment on lines +25 to +28
if not any(token in text for token in STRUCTURE_TOKENS):
raise ValueError("decoded output contains no OTSL structure token")
if "<nl>\n" not in text and "<nl>" in text:
raise ValueError("OTSL newline token is not followed by a literal newline")
Comment on lines +30 to +36
def test_paired_metrics_uses_the_removed_item_denominator_for_loo() -> None:
baseline = [(8, 10), (90, 100)]
candidate = [(10, 10), (89, 100)]
summary = summarize_paired(baseline, candidate)
assert summary.delta_correct == 1
assert summary.largest_absolute_delta == 2
assert summary.leave_one_out_delta_pp == -1.0
Comment on lines +11 to +18
def test_native_otsl_preserves_one_literal_newline_per_row_boundary() -> None:
assert to_native_otsl("<fcel>A<nl>\n<fcel>B<nl>") == "<fcel>A<nl>\n<fcel>B<nl>"


def test_decoded_otsl_removes_only_chat_controls() -> None:
text = normalize_decoded_otsl("<|im_end|><fcel>A<nl><fcel>B<nl>")
assert text == "<fcel>A<nl>\n<fcel>B<nl>"
assert count_structure_tokens(text)["<fcel>"] == 2
yushuosun and others added 2 commits August 13, 2026 15:42
Introduce terminal-blind pair generation, fail-closed isolation audits, exact Raw rollback checks, and token-geometry fixtures so candidate routing can be evaluated without benchmark leakage.

Co-Authored-By: Claude Opus 4.7 <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.

2 participants