Skip to content

fix: respect zero policy sample thresholds#3

Merged
Gsbreddy merged 1 commit into
chore/1.0.1-v1-rollout-readinessfrom
cursor/recent-pr-bugfixes-23f4
May 1, 2026
Merged

fix: respect zero policy sample thresholds#3
Gsbreddy merged 1 commit into
chore/1.0.1-v1-rollout-readinessfrom
cursor/recent-pr-bugfixes-23f4

Conversation

@Gsbreddy
Copy link
Copy Markdown
Collaborator

@Gsbreddy Gsbreddy commented May 1, 2026

Summary

Fix policy sample-threshold overrides so explicit zero values are honored instead of falling back to workspace defaults.

Why

Policy permits min_baseline_runs, min_candidate_runs, and min_low_runs to be 0, but the diff logic used truthiness fallback. That made 0 behave like unset and could incorrectly block promotion on sample-confidence policy.

Changes

  • Replace truthiness fallbacks with is not None checks in diff_releases.
  • Add a regression test for zero policy sample thresholds.

Validation

  • uv run python -c "from flightdeck.ledger import diff_releases; from flightdeck.models import Policy, PricingTable, WorkspaceConfig; policy=Policy(require_high_diff_confidence=True,min_candidate_runs=0,min_baseline_runs=0,min_low_runs=0); table=PricingTable(provider='openai', pricing_version='p', entries=[]); result=diff_releases(cfg=WorkspaceConfig(), policy=policy, baseline_events=[], candidate_events=[], baseline_pricing_table=table, candidate_pricing_table=table, window='7d'); print(result.confidence); print(result.policy.passed); print(result.policy.reasons)"
  • uv run python -m pytest tests/test_ledger.py
  • uv run python -m ruff check src tests
  • uv run python -m pytest
  • uv run python scripts/quickstart_smoke.py

Schema / Storage Impact

  • None
  • Schema change
  • Storage change

Risk

Low. The change only distinguishes explicit zero thresholds from omitted thresholds.

Notes

Bug was reproduced before the fix: explicit zero thresholds returned LOW, False, and a default-threshold policy failure. After the fix, the same repro returns HIGH, True, and no policy reasons.

Open in Web Open in Cursor 

Co-authored-by: Gottam Sai Bharath <Gsbreddy@users.noreply.github.com>
@Gsbreddy Gsbreddy marked this pull request as ready for review May 1, 2026 23:29
@Gsbreddy Gsbreddy merged commit 295db21 into chore/1.0.1-v1-rollout-readiness May 1, 2026
3 checks passed
@Gsbreddy Gsbreddy deleted the cursor/recent-pr-bugfixes-23f4 branch May 1, 2026 23:33
Gsbreddy added a commit that referenced this pull request May 1, 2026
…cstrings (#4)

- CHANGELOG.md: add Fixed entry under Unreleased for PR #3 (zero policy
  sample thresholds were silently ignored due to falsy 'or' fallback;
  now uses 'is not None' checks)
- ledger.py: add docstrings to confidence_label, evaluate_policy, and
  diff_releases explaining threshold semantics (None vs 0 vs config default),
  confidence label tiers, constraint fields, and agent-id invariant
- models.py: add Policy class docstring explaining the None/0 distinction
  for min_* threshold fields versus constraint (max_*) fields
- schemas/v1/policy.schema.json: regenerated to pick up Policy docstring

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Gottam Sai Bharath <Gsbreddy@users.noreply.github.com>
Gsbreddy added a commit that referenced this pull request May 1, 2026
* feat: FlightDeck 1.0.1 package and v1 rollout readiness

Ship the local-first CLI, schemas, tests, and CI. Slim-repo docs link to
canonical flightdeckdev/flightdeck main. OpenTelemetry is optional-only.

Also: pytest basetemp under .tmp/pytest for Windows, Python 3.13–3.14 in CI,
ruff 0.15.12 aligned with ruff-pre-commit, pre-commit-hooks v5, .gitattributes
LF for golden bundle, CHANGELOG 1.0.1 section and empty Unreleased,
RELEASE_NOTES v1.0.1 patch notes, README quickstart_smoke first.

Co-authored-by: Cursor <cursoragent@cursor.com>

* adds pypi fixes

* adds ci fixes

* fix: respect zero policy sample thresholds (#3)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Gottam Sai Bharath <Gsbreddy@users.noreply.github.com>

* Fix promotion audit sequencing (#5)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Gottam Sai Bharath <Gsbreddy@users.noreply.github.com>

* docs: document zero-threshold policy fix and improve ledger/policy docstrings (#4)

- CHANGELOG.md: add Fixed entry under Unreleased for PR #3 (zero policy
  sample thresholds were silently ignored due to falsy 'or' fallback;
  now uses 'is not None' checks)
- ledger.py: add docstrings to confidence_label, evaluate_policy, and
  diff_releases explaining threshold semantics (None vs 0 vs config default),
  confidence label tiers, constraint fields, and agent-id invariant
- models.py: add Policy class docstring explaining the None/0 distinction
  for min_* threshold fields versus constraint (max_*) fields
- schemas/v1/policy.schema.json: regenerated to pick up Policy docstring

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Gottam Sai Bharath <Gsbreddy@users.noreply.github.com>

---------

Co-authored-by: zendaya <zendaya@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Gottam Sai Bharath <Gsbreddy@users.noreply.github.com>
Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.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