A backend maintainer expects service-policy, calls cfg.get("service", "route", fallback="service-policy"), and receives shared-policy. Nothing necessarily failed inside ConfigParser. The surprise comes from treating fallback as though it were a higher-priority override. Python documents a different selection order: call-local vars, the named section, and the default section are considered before a supplied fallback is used. The same documentation also warns that section views include inherited defaults, so a value visible through cfg["service"] is not evidence that the option was physically defined under [service].
That distinction creates two independent review questions. First, does the effective string equal the value the application approves? Second, was that value supplied by an owner the application policy permits? A configuration can pass the first question while failing the second. Conversely, inherited DEFAULT data can be entirely acceptable when inheritance is deliberately authorized.
This article builds a bounded qualification fixture around those questions. The proposed reproduction baseline is the historical CPython 3.13.3 release dated April 8, 2025; its release page now explicitly says that 3.13.3 has been superseded by 3.13.18. The /3.13 documentation consulted for this article currently identifies itself as Python 3.13.18 documentation; that page header describes the documentation being served, not an interpreter that has actually run the fixture.
No laboratory was executed during preparation. Every behavioral result below is therefore EXPECTED / NOT EXECUTED, and the overall qualification remains HOLD_PENDING_EXECUTION until a retained runtime record exists.
Declare who is allowed to supply this service option and freeze the laboratory
The policy belongs in fixture data before ConfigParser is invoked. For this narrow experiment, use two application policies.
ALLOW_INHERITANCE permits the service to resolve its approved value from its own section, the normal DEFAULT section, or the explicitly supplied call fallback. It does not mean inheritance is universally preferable; it means this application owner has chosen to permit those sources for this option.
REQUIRE_EXPLICIT_SECTION requires the approved value to be physically present under [service]. An inherited DEFAULT value with identical bytes still fails that ownership rule. This is the central difference between Python INI configuration ownership and simple value equality.
The fixture also declares four other facts independently of the resolver: the approved service value is service-policy; an accepted persistent service value must be nonempty; [worker] must continue to resolve worker-policy; and C05 alone authorizes a temporary call-local vars={"route": "call-policy"} lookup. This ownership framing is analogous only at a high level to Refonte Learning's discussion of shared and private Git configuration scopes: both exercises distinguish an effective setting from where it is owned, but Git's scope rules do not define ConfigParser semantics.
The historical runtime pin is CPython 3.13.3, not because the behavior is new there, and not because that release is current. The Python release page identifies 3.13.3 as the third 3.13 maintenance release and says it has been superseded. A qualification run must therefore record what actually executes before any cases are evaluated: sys.version, platform.python_implementation(), platform.platform(), and sys.executable. If the machine runs another interpreter, the evidence should say so rather than silently rewriting the proposed baseline.
The production parser configuration is deliberately small:
configparser.ConfigParser(interpolation=None)Interpolation is disabled so each tested option remains a literal string. Normal option normalization is retained; the standard implementation lowercases option names by default. The experiment uses one fresh parser per case except for the explicit within-case transitions in C07 through C10. It reads only in-memory strings, starts no service, performs no network access, and introduces no environment, command-line, framework, or multi-file precedence.
The intended layout is one file and one retained report:
configparser_ownership_lab.py
configparser_evidence.jsonA reviewer would invoke the candidate interpreter explicitly, then inspect the report:
/path/to/python3.13 configparser_ownership_lab.py \
--output configparser_evidence.jsonThe script records the actual interpreter at runtime; an executable filename containing 3.13 is not accepted as version evidence by itself.
The authored ten-case manifest is the acceptance oracle, not data reverse-engineered from ConfigParser:
Case | Literal starting condition | Expected effective result | Expected owner | Expected application result |
C01 | Empty service; no route in DEFAULT; fallback supplied | service-policy | fallback | ACCEPT only under policy permitting fallback |
C02 | DEFAULT=shared-policy; empty service | shared-policy | DEFAULT | REPAIR |
C03 | DEFAULT=service-policy; empty service | service-policy | DEFAULT | REPAIR under explicit-section policy |
C04 | Service explicitly=service-policy | service-policy | service | ACCEPT |
C05 | C04 plus one-call vars | first call-policy, then service-policy | first vars, then service | ACCEPT only with authorized temporary override |
C06 | Explicit service value is empty | "" | service | REPAIR_VALUE |
C07 | C04 then remove service route | shared-policy after removal | DEFAULT | REPAIR |
C08 | C02 then remove inherited-only route from service | shared-policy | DEFAULT | REPAIR |
C09 | C04 then clear service proxy | shared-policy | DEFAULT | REPAIR |
C10 | C02 then set explicit service value | service-policy | service | ACCEPT repaired candidate |
Every row remains EXPECTED / NOT EXECUTED in this article.
The explicit-source manifest is separate data. For example, C02 is authored as {"DEFAULT": ["route"], "service": [], "worker": ["route"]}; C04 is {"DEFAULT": ["route"], "service": ["route"], "worker": ["route"]}. That inventory is not computed by asking the production parser whether route appears to exist.
Separate effective lookup from explicit ownership and reproduce the fallback surprise
Python's documented parser-level get() order is exact enough for the principal diagnosis: if vars is supplied it is considered first, then the named section, then DEFAULTSECT; only if the key is not found is a supplied fallback used. The documentation separately gives the practical consequence: default values have precedence over fallback values.
That produces four different questions that should not be collapsed into one boolean:
Evidence question | Example field | What it establishes |
What string did resolution return? | effective_value | Effective selection |
Is the option visible through the section? | effective_membership | Mapping-view visibility, including inherited defaults |
Was it explicitly authored under [service]? | explicit_service_option | Local source ownership |
Does the result satisfy application policy? | application_verdict | Acceptance decision |
The distinction matters because the mapping protocol includes default values in every ordinary section. Python's documentation illustrates iteration over a section returning names inherited from DEFAULT, and explicitly says all sections include DEFAULTSECT values. Consequently, 'route' in cfg["service"], cfg.has_option("service", "route"), or cfg.items("service") can participate in diagnostics, but they are not an oracle for physical ownership by [service].
This is a narrower problem than Compose interpolation and runtime value selection. Compose has multiple phases and runtime/container boundaries; this fixture has one in-process parser. The only relationship is methodological: do not confuse a resolved value with the source or phase that supplied it.
The principal source is intentionally minimal:
[DEFAULT]
route = shared-policy
[service]
[worker]
route = worker-policyThe failing call is:
cfg.get("service", "route", fallback="service-policy")Under the documented selection contract, the authored expectation for C02 is shared-policy, not service-policy, because DEFAULT is consulted before fallback. That API-consistent result can still be wrong for the application if the service owner required an explicit service-policy.
C01 changes only one source condition: the DEFAULT section has no route.
[DEFAULT]
[service]
[worker]
route = worker-policyThe same call is expected to return service-policy. This isolates absent input from inherited input. [service] still exists in both cases, so the experiment does not accidentally turn into a missing-section test.
C02 is therefore not evidence that fallback is ignored in every circumstance. It is evidence that a present inherited default outranks it. C01 is the positive fallback control.
C03 is more subtle:
[DEFAULT]
route = service-policy
[service]
[worker]
route = worker-policyNow a value-only assertion would pass: the effective string and the approved service string are both service-policy. The ownership assertion must still fail under REQUIRE_EXPLICIT_SECTION, because the expected explicit service inventory is empty. This is why the expected owner must be authored independently rather than inferred from whichever value happens to win.
Under ALLOW_INHERITANCE, the same C03 state could be acceptable. A reviewer changing from explicit ownership to allowed inheritance should treat that as an application-policy change owned by the service/configuration owner, not as a test fix. The library documentation establishes how defaults are resolved; it does not decide whether this application is allowed to inherit them.
The ledger therefore retains three columns even when they happen to agree:
approved value: service-policy
effective value: service-policy
observed owner: DEFAULTThe first is policy, the second is resolver output, and the third is provenance evidence. Treating all three as "the configuration value" destroys the distinction the qualification is meant to preserve.
Qualify explicit section values, call-local vars, and empty strings
C04 is the positive explicit-section control:
[DEFAULT]
route = shared-policy
[service]
route = service-policy
[worker]
route = worker-policyThe expected effective service value is service-policy, and the authored explicit inventory contains route under [service]. Because the worker has its own route, it remains worker-policy. The result is acceptable under REQUIRE_EXPLICIT_SECTION, subject to actual execution matching the expectation.
C05 adds a temporary lookup argument rather than changing the configuration source:
cfg.get(
"service",
"route",
fallback="service-policy",
vars={"route": "call-policy"},
)Python documents vars as the first lookup location for parser-level get(). Therefore the first expected result is call-policy. The fixture must immediately perform a second lookup without vars:
cfg.get("service", "route", fallback="service-policy")That second result is expected to return service-policy from the section. The evidence record retains both argument sets and both results. A one-call variable override is not a persisted update merely because it won one lookup.
The audit inventory is also checked before and after C05. If the section's explicit source inventory changes, the case fails even if the two effective strings look correct. That guards against an implementation or wrapper that accidentally persists a supposedly temporary override.
C06 covers an entirely different condition: present-but-empty.
[DEFAULT]
route = shared-policy
[service]
route =
[worker]
route = worker-policyWith ordinary ConfigParser parsing, this option has an explicit string value of "", not absence. The fallback is therefore not a blank-value replacement. Python's lookup rule says fallback is used when the key is not found; it does not define fallback as "replace any value the application dislikes."
The authored evidence for C06 keeps exact presence and exact bytes separate:
explicit_service_option = true
effective_value = ""
effective_type = "str"
fallback_used = false
nonempty_policy_ok = false
application_verdict = "REPAIR_VALUE"The application rejects the blank because this fixture declares a nonempty-value policy. That policy is not supplied by ConfigParser.
This distinction should not be imported from Helm's treatment of explicit false. That article examines a template helper whose default predicate includes an "emptiness" concept. The Python case here is different: literal string lookup is being qualified, and the documented fallback condition is option absence after the higher-priority lookup locations, not Helm/Sprig's emptiness predicate.
A reviewer should therefore resist "fixing" C06 by supplying another fallback. The owner is already explicit; its value violates the application policy. The repair target is the service-owned value.
Remove and clear local state without claiming the effective option disappeared
Removal creates one of the easiest misleading receipts in this workflow.
C07 begins from C04, where the service explicitly owns route = service-policy. It executes:
removed = cfg.remove_option("service", "route")Python documents remove_option() as returning True when the specified option existed in that section and was removed, and False otherwise. For C07, the expected Boolean is therefore True.
That Boolean says something precise: a local option existed and the operation removed it. It does not say the option is now effectively unavailable. Because [DEFAULT] still contains route = shared-policy, the subsequent service lookup is expected to resolve shared-policy. The mapping documentation explicitly describes this effect: deleting a section override can make the default value visible again.
The post-removal ledger must consequently keep separate fields:
remove_option_result = true
post_explicit_service_option = false
post_effective_value = shared-policy
post_effective_owner = DEFAULTC08 begins from C02, where the service never owned route locally. Calling the same method against the service is expected to return False because there is no local option to remove. The effective lookup remains shared-policy, and the inherited name remains visible through the section view. Python's mapping documentation says default values are not actually present inside each ordinary section, which is why deleting from a section cannot remove them there.
That means a reviewer must not interpret C08's False as "the option did not exist." It means "the option was not removed from this section." The inherited option can still exist effectively.
Nor should the fixture automatically delete route from [DEFAULT]. That would affect every section that relies on the shared default and would turn a local ownership mismatch into a shared-policy change. The unaffected worker control exists partly to make that risk visible.
C09 addresses cfg["service"].clear(). It begins from C04 and clears the service section proxy. Python's documentation directly warns that clearing an ordinary section may not leave its view visibly empty because default values remain accessible; it also explains that deleting an override causes the default to reappear.
The expected C09 state is therefore:
explicit service inventory: []
effective service route: shared-policy
effective service owner: DEFAULT
worker route: worker-policyThe operation is not used as a general tour of mutable-mapping methods. It answers a single acceptance question: after removing the service's local entries, can a reviewer still distinguish an empty explicit inventory from a nonempty effective view?
A useful operational rule follows: local mutation status and resolved availability are different evidence dimensions. Neither True from removal nor an empty explicit inventory is an effective-absence receipt.
Build a bounded public-API ownership audit
The production parser should remain the production resolver. Source ownership is diagnosed with a second parser whose default-section name is deliberately changed:
configparser.ConfigParser(
interpolation=None,
default_section="__audit_no_defaults__",
)Python documents default_section as the configurable name of the special section used for defaults while reading and writing. In this tightly constrained fixture, changing the diagnostic parser's special name means the literal [DEFAULT] header is read as an ordinary section instead of the inheritance source. Because no constructor defaults are supplied and no source section is allowed to use the reserved audit name, audit.options("service") can be compared with the independently authored local-option manifest.
That is a deliberately bounded technique. It is not a universal INI provenance parser. It assumes the exact fixture contract described here: literal in-memory sources, normal option normalization, no constructor defaults, no interpolation, and a prohibited __audit_no_defaults__ source section.
Before constructing the diagnostic view, the fixture uses a normal public ConfigParser to reject a source that contains the reserved section. It does not inspect private _sections.
The audit output never defines the expected owner. It is an observation to compare against the manifest. For C02, for example, the authored expectation says [service] has no explicit options. The diagnostic parser should independently observe that same inventory. If it does not, evidence reconciliation fails.
Mutation cases require an additional rule. C07 through C10 must not keep consulting an audit built from the original literal source after the production parser has changed. Python documents write() as writing a representation that can be parsed again with read(). The fixture therefore serializes the current production state through io.StringIO, preserves that serialization as evidence, and builds a fresh audit parser from it.
The original source and current serialization are deliberately different fields. ConfigParser.write() is not treated as a lossless source-code round trip; the documentation notes, for example, that original comments are not preserved. Here the serialization exists only as a public-API snapshot of the parser's current state after a controlled mutation.
The expected post-mutation inventory remains literal fixture data:
Case | Authored post-mutation explicit inventory |
C07 | DEFAULT:[route], service:[], worker:[route] |
C08 | DEFAULT:[route], service:[], worker:[route] |
C09 | DEFAULT:[route], service:[], worker:[route] |
C10 | DEFAULT:[route], service:[route], worker:[route] |
The diagnostic parser is never asked to select the production service route. Its sole job is to expose a public-API audit view whose local inventories can be reconciled against authored expectations. Production resolution, source audit, and policy checking remain separate functions in the implementation.
Reconcile all ten cases in one evidence document
The test framework is part of the evidence mechanism, not the source of expected values. Python's unittest documentation recommends TestCase assertion methods such as assertEqual and assertRaises, and explains that the runner accumulates outcomes rather than relying on bare language-level assert statements. The fixture therefore executes named checks under unittest.TextTestRunner and preserves the runner's failure status.
JSON provides one complete evidence envelope. Python's json documentation maps strings and booleans distinctly and warns that repeated dump() calls to the same stream do not constitute a framed sequence of independent JSON documents. The fixture accordingly builds one top-level report object, serializes it once, parses that finished document again as a reconciliation check, and then writes it.
The report schema records:
Field group | Retained evidence |
Runtime | interpreter version, implementation, platform, executable, UTC execution timestamp |
Fixture identity | revision, script digest, manifest digest, case IDs |
Source | original literal INI, source digest, explicit authored source manifest |
Lookup | section, option, fallback, optional vars |
Pre/post state | audit inventory, effective value, owner, membership, worker value |
Mutation | action, Boolean removal result where applicable, current serialization |
Policy | approved service value, allowed ownership policy, nonempty rule, vars permission |
Reconciliation | expected data, measured observation, per-case verdict, unittest failures |
Top-level status | PASS_10_CASES or FAIL_EVIDENCE_GATE |
Because the code has not been executed for this article, there is no populated observation document to quote here. The current article-level observation remains null, EXPECTED / NOT EXECUTED.
The complete standard-library fixture follows. Its literal case data is intentionally verbose so expected source ownership is visible in review rather than computed from the resolver under test.
#!/usr/bin/env python3
"""
ConfigParser selection-and-ownership qualification fixture.
Commissioned: 2026-11-26
Historical proposed baseline: CPython 3.13.3
Article preparation status: NOT EXECUTED
Run:
python configparser_ownership_lab.py --output configparser_evidence.json
"""
from future import annotations
import argparse
import configparser
import copy
import hashlib
import io
import json
import platform
import sys
import unittest
from datetime import datetime, timezone
from pathlib import Path
REVISION = "refonte-configparser-ownership-v1"
AUDIT_DEFAULT_SECTION = "__audit_no_defaults__"
ALLOW_INHERITANCE = "ALLOW_INHERITANCE"
REQUIRE_EXPLICIT_SECTION = "REQUIRE_EXPLICIT_SECTION"
APPROVED_RECORD = {
"service": {
"option": "route",
"value": "service-policy",
"owner": "service",
"nonempty": True,
},
"worker": {
"option": "route",
"value": "worker-policy",
},
}
SOURCES = {
"C01": (
"[DEFAULT]\n"
"[service]\n"
"[worker]\n"
"route = worker-policy\n"
),
"C02": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"[worker]\n"
"route = worker-policy\n"
),
"C03": (
"[DEFAULT]\n"
"route = service-policy\n"
"[service]\n"
"[worker]\n"
"route = worker-policy\n"
),
"C04": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"route = service-policy\n"
"[worker]\n"
"route = worker-policy\n"
),
"C05": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"route = service-policy\n"
"[worker]\n"
"route = worker-policy\n"
),
"C06": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"route =\n"
"[worker]\n"
"route = worker-policy\n"
),
"C07": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"route = service-policy\n"
"[worker]\n"
"route = worker-policy\n"
),
"C08": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"[worker]\n"
"route = worker-policy\n"
),
"C09": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"route = service-policy\n"
"[worker]\n"
"route = worker-policy\n"
),
"C10": (
"[DEFAULT]\n"
"route = shared-policy\n"
"[service]\n"
"[worker]\n"
"route = worker-policy\n"
),
}
SOURCE_MANIFESTS = {
"C01": {
"DEFAULT": [],
"service": [],
"worker": ["route"],
},
"C02": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
"C03": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
"C04": {
"DEFAULT": ["route"],
"service": ["route"],
"worker": ["route"],
},
"C05": {
"DEFAULT": ["route"],
"service": ["route"],
"worker": ["route"],
},
"C06": {
"DEFAULT": ["route"],
"service": ["route"],
"worker": ["route"],
},
"C07": {
"DEFAULT": ["route"],
"service": ["route"],
"worker": ["route"],
},
"C08": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
"C09": {
"DEFAULT": ["route"],
"service": ["route"],
"worker": ["route"],
},
"C10": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
}
POST_MUTATION_MANIFESTS = {
"C07": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
"C08": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
"C09": {
"DEFAULT": ["route"],
"service": [],
"worker": ["route"],
},
"C10": {
"DEFAULT": ["route"],
"service": ["route"],
"worker": ["route"],
},
}
EXPECTED = {
"C01": {
"policy": ALLOW_INHERITANCE,
"effective": "service-policy",
"owner": "fallback",
"effective_membership": False,
"explicit_service": False,
"worker": "worker-policy",
"verdict": "ACCEPT",
},
"C02": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective": "shared-policy",
"owner": "DEFAULT",
"effective_membership": True,
"explicit_service": False,
"worker": "worker-policy",
"verdict": "REPAIR",
},
"C03": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective": "service-policy",
"owner": "DEFAULT",
"effective_membership": True,
"explicit_service": False,
"worker": "worker-policy",
"verdict": "REPAIR",
},
"C04": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective": "service-policy",
"owner": "service",
"effective_membership": True,
"explicit_service": True,
"worker": "worker-policy",
"verdict": "ACCEPT",
},
"C05": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective_with_vars": "call-policy",
"owner_with_vars": "vars",
"effective_after_vars": "service-policy",
"owner_after_vars": "service",
"explicit_service": True,
"worker": "worker-policy",
"verdict": "ACCEPT",
},
"C06": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective": "",
"owner": "service",
"effective_membership": True,
"explicit_service": True,
"worker": "worker-policy",
"verdict": "REPAIR_VALUE",
},
"C07": {
"policy": REQUIRE_EXPLICIT_SECTION,
"remove_result": True,
"effective": "shared-policy",
"owner": "DEFAULT",
"explicit_service": False,
"worker": "worker-policy",
"verdict": "REPAIR",
},
"C08": {
"policy": REQUIRE_EXPLICIT_SECTION,
"remove_result": False,
"effective": "shared-policy",
"owner": "DEFAULT",
"explicit_service": False,
"worker": "worker-policy",
"verdict": "REPAIR",
},
"C09": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective": "shared-policy",
"owner": "DEFAULT",
"explicit_service": False,
"worker": "worker-policy",
"verdict": "REPAIR",
},
"C10": {
"policy": REQUIRE_EXPLICIT_SECTION,
"effective": "service-policy",
"owner": "service",
"explicit_service": True,
"worker": "worker-policy",
"verdict": "ACCEPT",
},
}
CASE_IDS = [f"C{i:02d}" for i in range(1, 11)]
def sha256_text(text: str) -> str:
return hashlib.sha256(text.encode("utf-8")).hexdigest()
def build_production_parser(source: str) -> configparser.ConfigParser:
cfg = configparser.ConfigParser(interpolation=None)
cfg.read_string(source)
return cfg
def reject_audit_collision(source: str) -> None:
guard = configparser.ConfigParser(interpolation=None)
guard.read_string(source)
if guard.has_section(AUDIT_DEFAULT_SECTION):
raise ValueError(
f"reserved audit section present: {AUDIT_DEFAULT_SECTION}"
)
def audit_inventory(source: str) -> dict[str, list[str]]:
reject_audit_collision(source)
audit = configparser.ConfigParser(
interpolation=None,
default_section=AUDIT_DEFAULT_SECTION,
)
audit.read_string(source)
return {
section: sorted(audit.options(section))
for section in audit.sections()
}
def serialize_parser(cfg: configparser.ConfigParser) -> str:
buffer = io.StringIO()
cfg.write(buffer)
return buffer.getvalue()
def normalized_vars(
cfg: configparser.ConfigParser,
variables: dict[str, str] | None,
) -> set[str]:
if not variables:
return set()
return {cfg.optionxform(name) for name in variables}
def observed_owner(
cfg: configparser.ConfigParser,
inventory: dict[str, list[str]],
section: str,
option: str,
variables: dict[str, str] | None,
) -> str:
normalized = cfg.optionxform(option)
if normalized in normalized_vars(cfg, variables):
return "vars"
if normalized in inventory.get(section, []):
return section
if normalized in inventory.get("DEFAULT", []):
return "DEFAULT"
return "fallback"
def snapshot(
cfg: configparser.ConfigParser,
inventory: dict[str, list[str]],
*,
variables: dict[str, str] | None = None,
) -> dict:
lookup = {
"section": "service",
"option": "route",
"fallback": "service-policy",
"vars": variables,
}
effective = cfg.get(
"service",
"route",
fallback="service-policy",
vars=variables,
)
worker = cfg.get(
"worker",
"route",
fallback="worker-policy",
)
return {
"lookup": lookup,
"effective": effective,
"effective_type": type(effective).__name__,
"owner": observed_owner(
cfg,
inventory,
"service",
"route",
variables,
),
"effective_membership": "route" in cfg["service"],
"explicit_service": "route" in inventory.get("service", []),
"worker": worker,
"worker_type": type(worker).__name__,
}
def compute_verdict(case_id: str, observation: dict) -> str:
if observation["worker"] != APPROVED_RECORD["worker"]["value"]:
return "HOLD_WORKER_CHANGED"
if case_id == "C05":
if (
observation["effective_with_vars"] == "call-policy"
and observation["owner_with_vars"] == "vars"
and observation["effective_after_vars"] == "service-policy"
and observation["owner_after_vars"] == "service"
and observation["explicit_service"] is True
):
return "ACCEPT"
return "REPAIR"
effective = observation["effective"]
owner = observation["owner"]
if case_id == "C06" and effective == "":
return "REPAIR_VALUE"
policy = EXPECTED[case_id]["policy"]
value_ok = (
effective == APPROVED_RECORD["service"]["value"]
and effective != ""
)
if policy == ALLOW_INHERITANCE:
owner_ok = owner in {"service", "DEFAULT", "fallback"}
elif policy == REQUIRE_EXPLICIT_SECTION:
owner_ok = owner == "service"
else:
return "HOLD_UNKNOWN_POLICY"
if value_ok and owner_ok:
return "ACCEPT"
return "REPAIR"
def run_case(case_id: str) -> dict:
source = SOURCES[case_id]
cfg = build_production_parser(source)
pre_inventory = audit_inventory(source)
record = {
"case_id": case_id,
"source_original": source,
"source_sha256": sha256_text(source),
"source_manifest_expected": SOURCE_MANIFESTS[case_id],
"pre_inventory_observed": pre_inventory,
"policy": EXPECTED[case_id]["policy"],
"remove_option_result": None,
"serialized_post": None,
"serialized_post_sha256": None,
"post_inventory_observed": None,
}
if case_id == "C05":
first = snapshot(
cfg,
pre_inventory,
variables={"route": "call-policy"},
)
second = snapshot(cfg, pre_inventory)
current = serialize_parser(cfg)
post_inventory = audit_inventory(current)
record.update({
"effective_with_vars": first["effective"],
"owner_with_vars": first["owner"],
"effective_after_vars": second["effective"],
"owner_after_vars": second["owner"],
"explicit_service": second["explicit_service"],
"effective_membership": second["effective_membership"],
"worker": second["worker"],
"lookup_with_vars": first["lookup"],
"lookup_after_vars": second["lookup"],
"serialized_post": current,
"serialized_post_sha256": sha256_text(current),
"post_inventory_observed": post_inventory,
})
elif case_id in {"C07", "C08", "C09", "C10"}:
pre = snapshot(cfg, pre_inventory)
record["pre_operation"] = pre
if case_id in {"C07", "C08"}:
record["remove_option_result"] = cfg.remove_option(
"service",
"route",
)
elif case_id == "C09":
cfg["service"].clear()
elif case_id == "C10":
cfg.set("service", "route", "service-policy")
current = serialize_parser(cfg)
post_inventory = audit_inventory(current)
post = snapshot(cfg, post_inventory)
record.update(post)
record.update({
"serialized_post": current,
"serialized_post_sha256": sha256_text(current),
"post_inventory_observed": post_inventory,
})
if case_id == "C10":
record["approved_record_before"] = copy.deepcopy(
APPROVED_RECORD
)
record["repair_candidate"] = {
"value": post["effective"],
"owner": post["owner"],
"worker": post["worker"],
}
else:
current = snapshot(cfg, pre_inventory)
record.update(current)
record["application_verdict"] = compute_verdict(
case_id,
record,
)
return record
OBSERVATIONS: dict[str, dict] = {}
class QualificationTests(unittest.TestCase):
maxDiff = None
def test_case_inventory_is_exact(self) -> None:
self.assertEqual(sorted(SOURCES), CASE_IDS)
self.assertEqual(sorted(SOURCE_MANIFESTS), CASE_IDS)
self.assertEqual(sorted(EXPECTED), CASE_IDS)
self.assertEqual(sorted(OBSERVATIONS), CASE_IDS)
def test_reserved_audit_section_is_rejected(self) -> None:
colliding = (
"[DEFAULT]\n"
"route = shared-policy\n"
f"[{AUDIT_DEFAULT_SECTION}]\n"
"route = collision\n"
"[service]\n"
"[worker]\n"
"route = worker-policy\n"
)
with self.assertRaises(ValueError):
audit_inventory(colliding)
def test_authored_source_manifests(self) -> None:
for case_id in CASE_IDS:
with self.subTest(case_id=case_id):
self.assertEqual(
OBSERVATIONS[case_id]["pre_inventory_observed"],
SOURCE_MANIFESTS[case_id],
)
def test_post_mutation_manifests(self) -> None:
for case_id in ["C07", "C08", "C09", "C10"]:
with self.subTest(case_id=case_id):
self.assertEqual(
OBSERVATIONS[case_id]["post_inventory_observed"],
POST_MUTATION_MANIFESTS[case_id],
)
def test_expected_behavior(self) -> None:
simple_fields = [
"effective",
"owner",
"explicit_service",
"worker",
"verdict",
]
for case_id in CASE_IDS:
expected = EXPECTED[case_id]
observed = OBSERVATIONS[case_id]
with self.subTest(case_id=case_id):
if case_id == "C05":
self.assertEqual(
observed["effective_with_vars"],
expected["effective_with_vars"],
)
self.assertEqual(
observed["owner_with_vars"],
expected["owner_with_vars"],
)
self.assertEqual(
observed["effective_after_vars"],
expected["effective_after_vars"],
)
self.assertEqual(
observed["owner_after_vars"],
expected["owner_after_vars"],
)
self.assertEqual(
observed["explicit_service"],
expected["explicit_service"],
)
self.assertEqual(
observed["worker"],
expected["worker"],
)
else:
for field in simple_fields:
observed_field = (
"application_verdict"
if field == "verdict"
else field
)
self.assertEqual(
observed[observed_field],
expected[field],
)
if "effective_membership" in expected:
self.assertEqual(
observed["effective_membership"],
expected["effective_membership"],
)
if "remove_result" in expected:
self.assertEqual(
observed["remove_option_result"],
expected["remove_result"],
)
def test_c05_call_override_does_not_persist(self) -> None:
observed = OBSERVATIONS["C05"]
self.assertEqual(
observed["pre_inventory_observed"],
observed["post_inventory_observed"],
)
self.assertEqual(
observed["effective_after_vars"],
"service-policy",
)
def test_worker_is_unchanged_in_every_case(self) -> None:
for case_id in CASE_IDS:
with self.subTest(case_id=case_id):
self.assertEqual(
OBSERVATIONS[case_id]["worker"],
"worker-policy",
)
def test_rejected_candidate_retains_previous_record(self) -> None:
previous = copy.deepcopy(APPROVED_RECORD)
rejected_candidate = {
"service": {
"option": "route",
"value": "",
"owner": "service",
"nonempty": True,
},
"worker": {
"option": "route",
"value": "worker-policy",
},
}
accepted = False
selected = rejected_candidate if accepted else previous
self.assertEqual(selected, APPROVED_RECORD)
def script_sha256() -> str:
try:
return hashlib.sha256(Path(__file__).read_bytes()).hexdigest()
except OSError:
return "UNAVAILABLE"
def fixture_manifest_sha256() -> str:
material = {
"revision": REVISION,
"sources": SOURCES,
"source_manifests": SOURCE_MANIFESTS,
"post_mutation_manifests": POST_MUTATION_MANIFESTS,
"expected": EXPECTED,
"approved_record": APPROVED_RECORD,
}
encoded = json.dumps(
material,
sort_keys=True,
separators=(",", ":"),
).encode("utf-8")
return hashlib.sha256(encoded).hexdigest()
def result_failures(result: unittest.TestResult) -> list[dict[str, str]]:
rows: list[dict[str, str]] = []
for test, text in result.failures:
rows.append({
"kind": "failure",
"test": str(test),
"detail": text,
})
for test, text in result.errors:
rows.append({
"kind": "error",
"test": str(test),
"detail": text,
})
return rows
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--output",
default="configparser_evidence.json",
)
args = parser.parse_args()
# Runtime identity is captured before any case is executed.
runtime = {
"captured_at_utc": datetime.now(timezone.utc).isoformat(),
"sys_version": sys.version,
"python_version": platform.python_version(),
"implementation": platform.python_implementation(),
"platform": platform.platform(),
"executable": sys.executable,
"historical_proposed_baseline": "CPython 3.13.3",
}
for case_id in CASE_IDS:
OBSERVATIONS[case_id] = run_case(case_id)
suite = unittest.defaultTestLoader.loadTestsFromTestCase(
QualificationTests
)
runner_stream = io.StringIO()
runner = unittest.TextTestRunner(
stream=runner_stream,
verbosity=2,
)
result = runner.run(suite)
failures = result_failures(result)
report = {
"schema": "refonte-configparser-ownership-evidence-v1",
"fixture_revision": REVISION,
"script_sha256": script_sha256(),
"fixture_manifest_sha256": fixture_manifest_sha256(),
"runtime": runtime,
"actual_case_ids": list(OBSERVATIONS),
"expected_case_ids": CASE_IDS,
"approved_record": APPROVED_RECORD,
"expected_manifest": EXPECTED,
"observations": OBSERVATIONS,
"test_runner": {
"tests_run": result.testsRun,
"successful": result.wasSuccessful(),
"failures": failures,
"text": runner_stream.getvalue(),
},
"status": (
"PASS_10_CASES"
if result.wasSuccessful()
else "FAIL_EVIDENCE_GATE"
),
}
encoded = json.dumps(
report,
indent=2,
sort_keys=True,
)
# Reconcile the complete JSON document before writing it.
decoded = json.loads(encoded)
if decoded["actual_case_ids"] != CASE_IDS:
report["status"] = "FAIL_EVIDENCE_GATE"
report["json_reconciliation_error"] = (
"case inventory changed during serialization"
)
encoded = json.dumps(
report,
indent=2,
sort_keys=True,
)
Path(args.output).write_text(
encoded + "\n",
encoding="utf-8",
)
return 0 if report["status"] == "PASS_10_CASES" else 1
if name == "__main__":
raise SystemExit(main())The source intentionally computes digests and timestamps only when it runs. No hash or execution time has been invented for this article. It also preserves empty strings and Boolean removal results as distinct JSON values, which is consistent with the standard library's JSON type mappings.
A diagnostic suite can pass because it correctly recognizes a deliberately unacceptable candidate. PASS_10_CASES, if eventually produced, means the measured behavior matched the independently authored expectations. It does not mean every row is acceptable application configuration.
The capture ledger follows the same separation principle as Refonte Learning's Python logger and handler filtering boundaries: evidence collection should not depend on the mechanism whose behavior it is trying to diagnose. That logging article does not define ConfigParser; the useful connection is the discipline of keeping instrumentation outside the contested selection path.
Repair the explicit owner, preserve the previous approved record, and decide
C10 starts from the same source as C02:
[DEFAULT]
route = shared-policy
[service]
[worker]
route = worker-policyThe repair is intentionally bounded:
cfg.set("service", "route", "service-policy")Python documents set() as assigning the specified string option to an existing section. After that operation, the fixture serializes the current parser, builds a fresh audit from that serialization, and expects [service] to contain explicit route. The effective service value should be service-policy, its observed owner should be service, and worker should remain worker-policy.
The candidate is validated before any approved record is replaced. This is conceptually similar to the boundary described in Refonte Learning's article on validation after a Pydantic copied update: constructing a changed candidate is not the same action as accepting it. The Pydantic API is unrelated to ConfigParser; the shared engineering idea is to keep candidate construction and acceptance as separate states.
The fixture retains APPROVED_RECORD independently of the mutable parser. C10 stores the previous approved record alongside the repaired candidate. If reconciliation fails, the prior record remains the accepted record in the review artifact.
A rejected branch is correspondingly simple:
previous = copy.deepcopy(APPROVED_RECORD)
candidate = {
"service": {
"option": "route",
"value": "",
"owner": "service",
"nonempty": True,
},
"worker": {
"option": "route",
"value": "worker-policy",
},
}
candidate_accepted = False
selected_record = candidate if candidate_accepted else previousThat restoration is only an in-memory review decision. This laboratory never starts a service, so it makes no claim about reversing runtime side effects, reloading processes, rolling back deployed artifacts, or reconstructing an external application's prior state.
The final operational decision should be made from both value evidence and ownership evidence:
Evidence state | Application decision | Primary owner |
Effective value matches and owner is permitted by ALLOW_INHERITANCE | ACCEPT under that declared inheritance policy | Service/configuration owner |
Effective value matches but owner is DEFAULT under REQUIRE_EXPLICIT_SECTION | REPAIR owner | Service/configuration owner |
Effective value is wrong but provenance is complete | REPAIR value or owner indicated by evidence | Service owner |
Explicit value is blank under nonempty policy | REPAIR value | Service owner |
Removal succeeded but inherited value reappeared | REPAIR or ACCEPT according to inheritance policy; do not infer absence | Service owner/reviewer |
Resolver behavior differs from documented expectation | HOLD; preserve disagreement | Python/application maintainer and reviewer |
Runtime identity differs from the requested baseline | HOLD unless explicitly requalified | Reviewer |
Case missing, duplicated, audit collision present, or JSON/test evidence incomplete | HOLD | Reviewer |
C10 matches approved value, explicit owner, and unchanged worker | ACCEPT repaired candidate | Service owner plus reviewer |
The service/configuration owner decides whether inheritance, fallback, or call-local override is authorized. A maintainer owns changes to resolver code or wrappers. The reviewer owns evidence completeness: exact case IDs, runtime identity, literal source, expected manifests, measured observations, and test-runner status must be preserved rather than silently normalized.
If the documentation, the historical pinned interpreter, and actual observations disagree, qualification stops. The discrepancy itself becomes evidence. Do not edit the expected manifest to match a surprising run, do not substitute a newer Python release merely because /3.13 documentation currently serves a later maintenance version, and do not treat the docs page's 3.13.18 header as evidence that 3.13.18 executed. The release page independently confirms both the April 8, 2025 date of 3.13.3 and its superseded status.
The limits are equally important. This result covers literal string options, interpolation=None, one normal DEFAULT section, normal lowercase option transformation, one service, one unaffected worker, and the exact operations represented by C01 through C10. It does not qualify multi-file loading, environment variables, command-line precedence, interpolation languages, typed converters, frameworks, production endpoints, secrets, or arbitrary INI provenance.
Because the laboratory was not executed for this article, none of the expected rows is measured evidence. The current review decision is therefore HOLD_PENDING_EXECUTION.
Extend backend debugging practice with Refonte Learning
A useful backend handoff is small enough to review: retain the source, declare the ownership policy, run an executable check, and keep one structured record that distinguishes expected behavior from measured behavior. That prevents a green lookup, a successful removal, or a matching string from carrying more meaning than the evidence supports.
Refonte Learning's Backend Developer Program is described as a three-month program requiring about 10–12 hours per week and a basic understanding of programming concepts; its page also lists a separate admission prerequisite of working toward a bachelor's or higher-level degree. The published curriculum names Node.js and Express, MongoDB and SQL, RESTful APIs and microservices, authentication and authorization, testing and debugging backend services, Docker/cloud deployment, and a capstone project. The same page describes hands-on projects, virtual-internship elements, educational mentoring, and, on successful completion, a Training Certificate and Certificate of Internship.
Those verified testing/debugging and backend-engineering foundations are the relevant connection to this article. No claim is made that this particular exercise is taught by the program or that participation guarantees placement or a specific career outcome.
