Skip to content

fix(config): apply the config that was parsed and ignored - #181

Merged
chiruu12 merged 5 commits into
devfrom
fix/dead-config-surfaces-169
Aug 31, 2026
Merged

chiruu12 merged 5 commits into
devfrom
fix/dead-config-surfaces-169

Conversation

@chiruu12

Copy link
Copy Markdown
Collaborator

Fixes #169.

Three config surfaces parsed without error and then did nothing. All three now apply.

Top-level [policy]. build_config read policy only out of [guard], with no top-level fallback, unlike pipeline, limits, messages, tools and boundaries. unplug.example.toml ships [guard] at line 3 and [policy] at line 101, so the whole block was dead for anyone who copied the example. [guard.policy] still wins where both name a key.

[pipeline.thresholds]. These were folded into pipeline.policy, which nothing scans with: Guard builds every request policy from the guard-level one, and BasePipeline._resolve_policy prefers the context policy. A pipeline run with no context was the only path that saw them, and the public API never takes it, so one file gave Guard.scan and Pipeline.run two different actions for the same input. They now fold into the guard policy as well. An explicit [policy] key still wins.

Partial scanners_config entries. A table naming one field built a fresh ScannerConfig, so every unnamed field fell to the pydantic class default instead of the bundled one. secrets dropped 0.99 to 0.85 and injection lost normalize, both silently and both weakening, for anyone setting a single key. Overrides now merge onto data/defaults/scanners.toml, which is what that file says it is for. A scanner with no bundled entry is unchanged.

Seven tests, all four of the behaviour changes fail on dev:

test_top_level_policy_applies_alongside_a_guard_table   assert 0.8 == 0.1
test_pipeline_thresholds_reach_the_guard_policy         assert 0.8 == 0.2
test_explicit_policy_beats_pipeline_thresholds          assert 0.3 == 0.1
test_partial_scanner_override_keeps_the_bundled_rest    assert 0.85 == 0.99

717 passed on the branch, 710 on dev, same 2 unrelated ML model-store failures on both (local model cache; #163 and PR #175 cover those). ruff clean.

Copilot AI lite review requested due to automatic review settings August 30, 2026 17:21

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.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR applies previously ignored policy, pipeline-threshold, and scanner-override configuration while preserving source precedence and validating reconstructed values.

  • Merges policy sources per key with guard-specific settings taking precedence.
  • Aligns guard and pipeline policy thresholds.
  • Merges partial scanner overrides onto bundled defaults.
  • Adds threshold constraints and regression coverage for precedence, validation, and synchronization.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
sdk/src/unplug/config/loader.py Resolves policy sources consistently, validates threshold propagation, and merges scanner overrides onto bundled defaults.
sdk/src/unplug/config/guard.py Adds bounded validation to pipeline threshold fields.
sdk/tests/unit/config/test_config_loader.py Adds broad regression coverage for policy precedence, threshold synchronization, malformed values, and partial scanner overrides.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A["pipeline.policy"] --> M["Resolve policy by precedence"]
    B["top-level policy"] --> M
    C["guard.policy"] --> M
    D["pipeline.thresholds"] --> M
    M --> G["Guard policy"]
    M --> P["Pipeline policy"]
    M --> T["Pipeline thresholds"]
    E["Scanner overrides"] --> V["Validate over bundled defaults"]
    F["Bundled scanner defaults"] --> V
    V --> S["Effective scanner configs"]
Loading

Reviews (5): Last reviewed commit: "Merge remote-tracking branch 'origin/dev..." | Re-trigger Greptile

Comment thread sdk/src/unplug/config/loader.py Resolved
Comment thread sdk/src/unplug/config/loader.py Resolved
Comment thread sdk/src/unplug/config/loader.py Resolved
@github-actions

github-actions Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

coverage

SDK Coverage •
FileStmtsMissCoverMissing
src/unplug/config
   guard.py76199%34
   loader.py3033788%64, 67, 160, 162, 228, 249, 262–270, 274, 278, 282, 286–289, 293, 297, 313, 354, 452, 454, 462, 468, 472, 476, 480, 484, 488, 492, 521
TOTAL750888788% 

Tests Skipped Failures Errors Time
1351 25 💤 0 ❌ 0 🔥 40.145s ⏱️

@chiruu12

Copy link
Copy Markdown
Collaborator Author

All three were real. Fixed in 4a52e48.

The two validation ones were regressions I introduced. model_copy(update=...) writes values straight in, so merging onto the bundled defaults cost the config-time error that ScannerConfig(**overrides) used to give. Both paths now construct through the model over the dumped defaults, which keeps the merge and keeps the validation.

block, redact and review are declared ge=0.0, le=1.0, so the threshold path was the worse of the two:

before  base_score='high'  -> stored 'high'
        block=5.0          -> stored 5.0
        block='0.2'        -> stored '0.2'
after   base_score='high'  -> ValidationError
        block=5.0          -> ValidationError
        block='0.2'        -> 0.2

The policy one was not a regression, since top-level [policy] was ignored outright before this PR, but the whole-table fallback was still the wrong shape. It merges per key now, [guard.policy] winning where both name the same key.

Four more tests. 721 passing, same 2 unrelated ML model-store failures.

@chiruu12
chiruu12 force-pushed the fix/dead-config-surfaces-169 branch from 6c6f25f to 4e8372b Compare August 31, 2026 18:39
@chiruu12
chiruu12 merged commit 8693c11 into dev Aug 31, 2026
7 checks passed
@chiruu12
chiruu12 deleted the fix/dead-config-surfaces-169 branch August 31, 2026 21:17
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.

Three config surfaces are parsed and then ignored

2 participants