Skip to content

test(config): pin effective inventory contract - #2328

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/config-effective-state
Jun 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/config-effective-state

Conversation

@Sinity

@Sinity Sinity commented Jun 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds focused tests that make the #2309 effective-configuration inventory contract executable: unique inventory keys/env vars, required metadata, redacted env-sourced secrets, and typed env values flowing through effective_config_payload.

Problem

The downloaded #2309 patch is stale against current master; the main effective-config surfaces already exist (polylogue config --format json, configuration docs, and deployment-smoke runtime evidence). The remaining risk is that the inventory becomes decorative metadata: future config keys could drift from env mapping, source-layer reporting, or secret redaction without a direct test failing.

Solution

  • Assert every inventory row has a unique key and env var plus owner class, reload behavior, and effective inspection path.
  • Assert an env-sourced POLYLOGUE_API_AUTH_TOKEN appears only as <set>, reports secret_present, and preserves source_layer=env without leaking the real secret.
  • Assert a typed env value from the inventory (POLYLOGUE_BROWSER_CAPTURE_PORT) reaches effective_config_payload with the right value, env var, and source layer.

The patch file /realm/inbox/download/pths/polylogue_2309_config_inventory_effective_state.patch was not mechanically applied. Its major code/docs intent is already present on master; this PR hardens the missing contract coverage around that landed surface.

Verification

  • devtools test tests/unit/core/test_config.py::TestConfigInventoryPayload tests/unit/devtools/test_deployment_smoke.py::test_deployment_smoke_runtime_evidence_includes_effective_config tests/unit/devtools/test_deployment_smoke.py::test_deployment_smoke_includes_effective_config_evidence -> pass (5 passed)
  • devtools verify --quick -> pass (20260623T121441Z-quick-3443684-3ebc9195)
  • pre-push devtools verify --quick -> pass (20260623T121534Z-quick-3445534-f57a4d77)

Ref #2309

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for configuration payload validation, including verification of unique configuration keys, environment variable sourcing, and proper handling of sensitive values.

Problem: #2309 depends on the config inventory being executable rather than decorative, but the current tests did not directly prove key/env uniqueness or that env-sourced effective values preserve source metadata while redacting secrets.

What changed: add focused tests for unique inventory keys/env vars, required owner/reload/effective-path metadata, redacted env-sourced API auth token payloads, and typed env values flowing through effective_config_payload.

Verification: devtools test tests/unit/core/test_config.py::TestConfigInventoryPayload tests/unit/devtools/test_deployment_smoke.py::test_deployment_smoke_runtime_evidence_includes_effective_config tests/unit/devtools/test_deployment_smoke.py::test_deployment_smoke_includes_effective_config_evidence; devtools verify --quick.

Ref #2309
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3644b9c4-9d69-4e8d-ae01-33b0ec0016bc

📥 Commits

Reviewing files that changed from the base of the PR and between b66d71b and c0e4a45.

📒 Files selected for processing (1)
  • tests/unit/core/test_config.py

📝 Walkthrough

Walkthrough

A new pytest class TestConfigInventoryPayload is added to the existing config test module. It includes a site-disabling helper and three tests covering config_inventory_payload() key/env_var uniqueness with required metadata fields, effective_config_payload() secret redaction for API auth tokens, and typed numeric representation of env-sourced port overrides.

Changes

Config Inventory and Effective Payload Tests

Layer / File(s) Summary
Inventory payload uniqueness and metadata
tests/unit/core/test_config.py
Introduces TestConfigInventoryPayload with _disable_site helper (sets POLYLOGUE_SITE_CONFIG to empty string) and a test asserting config_inventory_payload() rows have unique key and env_var values and non-empty owner_class, reload_behavior, effective_path fields.
Effective payload secret redaction and typed env overrides
tests/unit/core/test_config.py
Two tests validate effective_config_payload(cfg): one sets POLYLOGUE_API_AUTH_TOKEN and asserts the raw secret is redacted while source_layer is "env" and the secret does not appear in serialization; another sets POLYLOGUE_BROWSER_CAPTURE_PORT and asserts a numeric typed value, env_var, and source_layer of "env".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, the payloads align,
Secrets redacted, all secrets fine,
Keys unique, env vars in a row,
The rabbit checks what configs bestow,
No site config sneaks through the door,
Tests pass — what could one ask for more? 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test(config): pin effective inventory contract' clearly describes the primary change: adding tests to enforce the effective configuration inventory contract.
Description check ✅ Passed The description covers all required sections: Summary, Problem, Solution, Verification, and Changelog (noted as skip for test-only PR). It provides comprehensive context about the #2309 contract, the risk being addressed, and specific test coverage added.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/config-effective-state

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 1cad0db into master Jun 23, 2026
11 checks passed
@Sinity
Sinity deleted the feature/feat/config-effective-state branch June 23, 2026 12:19
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.

1 participant