Skip to content

Finalize U4 reliability and local quality gates - #3

Merged
QJHWC merged 30 commits into
mainfrom
feature/u4c-reliability
Oct 11, 2026
Merged

QJHWC merged 30 commits into
mainfrom
feature/u4c-reliability

Conversation

@QJHWC

@QJHWC QJHWC commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Preserve U4B eligibility, authorization, and released-state boundaries.
  • Harden controlled-termination recovery and provenance-bound imported metric ledgers.
  • Close isolated Python 3.11 quality gates; repair output paths, figure serialization, and generated LaTeX validation.
  • Record local readiness and explicit limitations in docs/u4d-final-execution.md.

Verification

  • Full pytest: 778 passed, 5 opt-in real-compute skips, 0 failures or collection errors.
  • Ruff whole repository and configured mypy (81 files): pass.
  • Integration and controlled-termination/reopen smoke: pass.
  • Isolated build, official wheel smoke, and pip check: pass.
  • Independent scoped local review: no open reproduced HIGH/CRITICAL.

Required before tool freeze

Read actual automatic code-review and security-review findings for this exact head commit; resolve blocking findings and repeat checks after each push. No merge is authorized.

Limitations

Single-writer/quiesced repair only; no physical power-loss or concurrent-writer proof. Generated-text validation is not an arbitrary-TeX OS sandbox. No real paper or private shadow artifacts are included; no human review or publication release is fabricated.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 09:34

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T10:08:28.621300Z 0af125a Manual request
🔒 Security Review ✅ Completed 2026-10-09T10:08:58.942964Z 0af125a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@QJHWC

QJHWC commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@QJHWC

QJHWC commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7d8dd70c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +506 to +510
"subject": str((row.get("run_identity") or {}).get("model_id") or ""),
"metric": row.get("metric_name"), "value": row.get("value_str"), "unit": row.get("unit"),
"qualifiers": dict(spec.qualifiers), "ledger_id": spec.ledger_id,
"ledger_digest": ledger.get("ledger_digest"),
"evidence_ids": list(row.get("source_evidence_ids") or []),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve evidence semantics in generated facts

Include the source row's measurement_kind and run_identity in generated facts. The normal generate_facts output currently omits both, while validate_narrative and the scientific-review checks look for those fields at the fact's top level; consequently, a fact generated from simulated or remapped evidence can be described as a physical measurement without triggering the layer guard, and comparison checks cannot detect incompatible datasets or devices.

Useful? React with 👍 / 👎.

Comment thread paperforge/publication_artifacts.py Outdated
Comment on lines +426 to +430
match = next((
x for x in x_rows
if all(str((dict(x.get("run_identity") or {})).get(k) or "") == str(identity.get(k) or "")
for k in ("model_id", "seed", "device_id", "precision", "input_size"))
), None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Match figure coordinates using the complete run identity

Require the x and y observations to agree on every scientifically relevant run dimension. As written, two rows with the same model, seed, device, precision, and input size but different dataset, split, checkpoint, runtime, batch size, or timing scope are paired into one point; next(...) then silently chooses an arbitrary x row and produces a scientifically invalid correlation.

Useful? React with 👍 / 👎.

Comment thread paperforge/publication_artifacts.py Outdated
Comment on lines +259 to +263
def _load_ledger(root: Path, ledger_id: str) -> dict[str, Any]:
path = root / ".paperforge" / "ledgers" / ledger_id / "ledger.json"
if not path.is_file():
raise PublicationArtifactError(f"ledger missing: {ledger_id}")
return json.loads(path.read_bytes().decode("utf-8"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Validate ledger integrity before generating artifacts

Verify the ledger digest, registry entry, and currentness before consuming its rows rather than returning parsed JSON directly. If ledger.json is modified after freezing, table, figure, and fact generation currently accepts the altered values and registers new verified outputs while copying the stale embedded ledger_digest; those outputs can then be used by narrative and result-update APIs without necessarily supplying a separate ledger binding.

Useful? React with 👍 / 👎.

Comment on lines +421 to +423
for cand in _classify_candidates(proposed_block):
if cand["kind"] == "structural" or cand["text"] in old_texts:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require bindings for newly duplicated numeric claims

Compare occurrences rather than skipping every candidate whose textual value appeared anywhere in the old block. For example, if the old block contains one 20 ms, a proposal can retain it and add an unrelated Model B recorded 20 ms statement; both candidates are skipped by this set-membership test, so the new scientific claim is validated with no allowlisted fact binding.

Useful? React with 👍 / 👎.

Comment on lines +253 to +255
with memory.connect() as db:
for key, files in current.items():
for rel, actual in files.items():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject missing files from approved artifact bindings

Compare the complete expected file set against the current file set before approving or applying a proposal. This loop only visits files that still exist, so deleting a bound artifact member such as facts.json while leaving manifest.json causes the missing expected entry to be ignored and the integrity check to pass, allowing an update whose evidence artifact is incomplete.

Useful? React with 👍 / 👎.

Comment thread paperforge/pdf_qa.py
Comment on lines +492 to +497
pages = {r["page"] for r in renders}
reviewed_any = {r.get("page") for r in human_records if not r.get("stale")}
if critical or any(r.get("status") == "failed" for r in human_records):
state = "failed"
elif needs_human or pages - reviewed_any:
state = "needs_human"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Count only completed human reviews as page coverage

Restrict reviewed_any to current reviews whose status is passed or passed_with_warnings. A caller can currently submit a correctly bound HumanPageReview with the default pending status and no reviewer identity; it counts as coverage, and when there are no critical or needs-human detector findings the bundle is incorrectly emitted with layout_qa_state="passed".

Useful? React with 👍 / 👎.

Comment thread paperforge/pdf_qa.py Outdated
Comment on lines +569 to +580
# Target PDF still matches?
target_match = True
historical = "valid" if digest_valid else "invalid"
# Human/render currentness sampled from stored hashes (no recomputation of renders here).
unresolved_critical = list(payload.get("unresolved_critical") or [])
state = str(payload.get("layout_qa_state") or "")
from .immutable_artifacts import verify_registered_bundle

registry = verify_registered_bundle(root, memory, {
f".paperforge/pdf_qa/{bundle_id}/qa.json": "review",
f".paperforge/pdf_qa/{bundle_id}/manifest.json": "manifest"})
currently_valid = bool(historical == "valid" and registry["registered_complete"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recheck the target PDF when verifying QA

Resolve the stored QA spec's target path and hash its current bytes instead of hard-coding target_match and currentness to true. After the PDF changes, verify_pdf_qa still reports currently_valid=True, target_pdf_hash_match=True, and current render/human reviews; in particular, reviewer_matrix._binding_current trusts that result, so a QA binding can remain current for a PDF that was never reviewed.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: f7d8dd70c1

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@QJHWC

QJHWC commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review current head 0af125a. All seven prior findings have local fixes: e5f92a6 binds facts to source semantics, pairs full figure identities, and verifies ledger inputs; 2c59895 enforces artifact member sets and numeric occurrence counts; 761bfa7 keeps pending human gates incomplete and checks actual current PDF bytes. 4506b8b provisions Poppler in all CI platforms; 0c9c9f7 repairs Windows source-byte/newline integrity and portable imported paths.

Local evidence: 819 passed, 5 opt-in skips, 0 failures/collection errors; Ruff whole scope and configured mypy pass; sdist/wheel and isolated wheel smoke pass; scoped independent reviews pass. Fresh cross-platform CI and exact-head remote code/security clearance remain pending. No merge or tool freeze is claimed.

@QJHWC

QJHWC commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@codex security review

Please review current head 0af125a, including publication ledger integrity, exact source-byte writes, canonical imported paths, artifact member binding and PDF currentness repairs. The prior no-findings security report applies only to f7d8dd7 and is not being reused as clearance for this head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@QJHWC

QJHWC commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Retrying the failed code review (the connector reported Unknown error in comment 6078668241). Please review unchanged head 0af125a. No error or running summary is being treated as approval.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0af125a603

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

)
# Group rows. Default forbids silent cross-condition pooling; every
# allowed dimension must be explicit with intent recorded per row.
protected = set(CROSSABLE_DIMENSIONS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep models separated during aggregation

When an aggregation does not explicitly include model_id in group_by, observations from different models receive the same group key, and this guard does not reject the mixture because CROSSABLE_DIMENSIONS omits model_id. For example, otherwise-identical values 1 and 3 from models A and B produce a single mean of 2, silently corrupting a scientific result instead of requiring an explicit cross-model intent.

Useful? React with 👍 / 👎.

Comment thread paperforge/publication_artifacts.py Outdated
Comment on lines +310 to +311
by_id = {str(r.get("row_id")): r for r in rows}
selected = [by_id[rid] for rid in spec.row_ids if rid in by_id] if spec.row_ids else list(rows)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Filter and pivot table rows by requested metrics

When row_ids is omitted, this selects every ledger row regardless of spec.columns; the later one-to-one mapping creates a table row for each observation and fills only that observation's metric. Thus a latency-only table from a ledger that also contains FPS emits blank FPS-derived rows, while a latency/FPS table emits two sparse rows rather than one row for their shared run identity, producing unusable or misleading publication tables.

Useful? React with 👍 / 👎.

Comment thread paperforge/grounded_narrative.py Outdated
Comment on lines +279 to +283
if key == "model_id" and expected.lower() not in lowered:
# Model must be named correctly when the fact is model-specific.
pass
for _candidate in (f"{key} {expected}", str(expected)):
pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject subject mismatches in grounded narratives

For model-specific facts, the branch that detects the expected model is absent from the sentence is a no-op, as is the following candidate loop. Consequently, a fact for ModelA with value 20 validates the sentence ModelB measured 20 ms. as passed because only the number is checked, allowing a grounded narrative to attribute valid measurements to the wrong subject.

Useful? React with 👍 / 👎.

Comment on lines +266 to +268
if statistical_artifacts:
return _result("statistical_wording", claim.claim_id, "passed", "typed statistical support present",
facts_used=tuple(claim.fact_ids))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind statistical support before passing claims

For claims containing significance or equivalence wording, any non-empty statistical_artifacts sequence passes this checker without verifying the artifact's metric, subjects, dataset, evidence set, or margin. review_claim invokes this presence-only checker, and the coverage gate does not require the stricter check_statistical_binding, so even an unrelated string can make a statistical-superiority claim receive a fully reviewed verdict.

Useful? React with 👍 / 👎.

Comment thread paperforge/references.py
Comment on lines +225 to +226
# Text-like formats: record line spans for auditability.
text, truncated, bytes_read = _read_text_with_budget(data, budget_bytes=per_file)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Extract DOCX text before adding it to prompts

For an accepted .docx reference, this non-PDF path decodes the ZIP container bytes directly as UTF-8 instead of extracting document text. The resulting prompt contains archive/XML noise and often truncates before useful prose, so users cannot actually provide DOCX reference context despite that suffix being explicitly accepted by the API and documented workflow.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 0af125a603

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@QJHWC
QJHWC merged commit 6e51ab3 into main Oct 11, 2026
10 checks passed
@QJHWC
QJHWC deleted the feature/u4c-reliability branch October 11, 2026 04:07
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