Skip to content

fix(engine): reject malformed historical replay calibration scores - #3466

Merged
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-autonomy-gate-vulnerability
Jul 5, 2026
Merged

fix(engine): reject malformed historical replay calibration scores#3466
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-autonomy-gate-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • A malformed or non-finite historical replay compositeScore could propagate NaN into the combined calibration accuracy and allow the autonomy-increase gate to fail open, violating the intended fail-closed behavior.
  • The code previously accepted history replay inputs based only on metadata/freshness and harness status without validating that the extracted score is a finite number.

Description

  • Change extractHistoricalReplayScore to return null for missing/non-finite values and to return a number | null so malformed scores are explicitly rejected instead of producing NaN via roundScore.
  • When a historical replay accuracy is null, mark the replay as held (replayHarnessHold = true), record the hold reason invalid_replay_score, and add a rejected source entry so malformed replay signals cannot contribute to contributingSources.
  • Add a regression test that exercises object-shaped/malformed, NaN, and Infinity compositeScore inputs and asserts the replay source is rejected, autonomyIncreasePermitted remains false, and the invalid_replay_score hold is recorded.

Testing

  • Ran the package build with npm --workspace @jsonbored/gittensory-engine run build, which completed successfully.
  • Executed the Phase 7 unit file with node --test packages/gittensory-engine/test/phase7-calibration-loop.test.ts, and all tests in that file passed (new regression included).
  • Attempted the full coverage run with npm run test:coverage, but the unsharded full test suite did not complete due to unrelated timeouts/failures in other tests during this environment run; therefore full-coverage validation in this environment did not finish.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 5, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 5286f3b Commit Preview URL

Branch Preview URL
Jul 05 2026, 08:18 AM

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 08:25:22 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This change correctly moves the malformed-score check ahead of rounding, so `NaN` and non-finite replay scores no longer enter the weighted calibration calculation. The fail-closed path records `invalid_replay_score`, excludes the replay source from contributors, and the regression test drives the production `computePhase7CalibrationLoop` path rather than only testing the helper. I do not see a reachable code defect in the provided diff, but the PR description still needs to link the maintainer-authorized issue if this is an external contribution.

Nits — 4 non-blocking
  • nit: PR fix(engine): reject malformed historical replay calibration scores #3466 description does not clearly close or link an eligible open issue; add the issue reference explicitly instead of relying on the Codex task link or incidental historical comments.
  • nit: packages/gittensory-engine/test/phase7-calibration-loop.test.ts:348 covers `{}`, `NaN`, and `Infinity`, but it does not cover the object-shaped `compositeScore: { compositeScore: NaN }` case that matches the declared `GateVerdictCompositeCalibrationScore` branch.
  • packages/gittensory-engine/test/phase7-calibration-loop.test.ts:348 add a case like `{ compositeScore: Number.NaN }` so the object-score branch is covered with a malformed value shaped like the real calibration object.
  • PR fix(engine): reject malformed historical replay calibration scores #3466 description: add `Closes #<issue>` or `Fixes #<issue>` for the eligible open issue authorizing this change.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 56 registered-repo PR(s), 46 merged, 586 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 56 PR(s), 586 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 56 PR(s), 586 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 5, 2026
@JSONbored
JSONbored merged commit 364024c into main Jul 5, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-autonomy-gate-vulnerability branch July 5, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant