Skip to content

refactor(k8s): the kubernetes, argo, docker, terraform, observability and valkey tables move out of config/ next to their owners #1031

Closed as not planned

Description

@dan-petty

Problem

config/constants.py and config/defaults.py declare 98 names (61 constants, 37 defaults) that only one of these packages uses. Counted at 38517a8 (the release/v0.2.25 tip) by AST, with the method described in #1016: from-imports and attribute reads count, and re-exports do not. The counts are approximate (an independent count differs by up to about ten per item, mostly in how function-local imports and names that only build another config/ name are attributed); the baseline is the exact list.

  • By package: k8s/ 29, argo/ 14, valkey/ 12, docker/ 11, tf/ 10, prometheus/ 9, grafana/ 8 and cloudflare/ 5. 25 modules read them. The largest readers are argo/crd.py (12), tf/analysis.py (10), docker/engine.py (9), k8s/rbac.py (7), k8s/informer.py (7), grafana/builders.py (6) and prometheus/promql.py (6).
  • Three are read by two or more modules of one package: CONST_GRAFANA_DASHBOARD_GRID_WIDTH (constants.py:1617, grafana/builders.py, linter.py and schema.py), CONST_GRAFANA_DEFAULT_DATASOURCE_TYPE (:1620) and DEFAULT_VALKEY_TIMEOUT_SECONDS (defaults.py:612, valkey/client.py and pool.py).
  • Four test files import them from config/: test_argo_crd.py, test_docker_engine.py, test_k8s_service.py and test_valkey_concurrency.py.

The placement rule (#1016) puts each of these names next to the code that reads it. That item's baseline lists them under k8s, argo, valkey, docker, tf, prometheus, grafana and cloudflare, and its invariant fails once a listed name is moved and its entry is left behind, so this PR deletes those blocks.

Acceptance criteria

  • Each name listed under k8s, argo, valkey, docker, tf, prometheus, grafana and cloudflare in tests/fixtures/config_placement_baseline.json is declared in the one module that reads it, or in its package's constants.py when two or more modules of the package read it. Its name, value and comment are unchanged, and it is annotated Final. config/constants.py and config/defaults.py no longer declare it, and its block is gone from the baseline.
  • Every importer imports the name from its new module, including the test files named above. Nothing in config/ re-exports it.
  • A name that only code deleted by an earlier item read is deleted, not moved.
  • The two invariant tests from docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 pass.
  • Apart from the Final annotation added where a name lacked it, the PR only moves code: git diff --color-moved=zebra shows every other declaration line as moved. The diff touches only config/constants.py, config/defaults.py, the baseline, those eight packages and the tests that import the moved names.
  • uv run devops ci passes.

Key questions

  • Does a name go into the module that reads it, or into the package's constants.py? (proposed) Into the module, when one module reads it. Into the package's constants.py when two or more do, as the rule says. That applies to three names here, for example CONST_GRAFANA_DASHBOARD_GRID_WIDTH and DEFAULT_VALKEY_TIMEOUT_SECONDS.
  • When does it land? (proposed) After the open items that rewrite these modules' tables, when they are scheduled first. No filed refactor deletes these modules, so this slice can go early.
  • Can the move add an import cycle? (proposed) No. A moved table imports nothing new, and a package's constants.py imports nothing from its package. test_no_circular_imports_in_decoupled_subsystems (tests/test_architectural_invariants.py:308) is the check.

Depends on: #1016, #776.
Order: no ordering constraint beyond the dependencies. It shares no module with the other move items.
Related: #548, #776.

Activity

  1. added
    type/refactor
    scope/k8s
    scope/config
    priority/p3-low
    scope/infra
    on Oct 2, 2026
  2. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Lines cited at dcafadf.
    At 132ecc5, config/defaults.py:853 is :862 and :854 is :863; the other cited lines are unchanged.

    Two other items delete some of this item's tables. Leave these in config/, with their baseline entries:

    Move the other four valkey names as this item's rule says:

    #1113's second PR replaces client.py with one store module and deletes any of these four that the swap leaves unread. For any other name, this item's own criterion applies: if an earlier item deleted its only reader, delete the name instead of moving it.

    Test imports until those items land:

  3. added
    status/ready
    value/low
    effort/medium
    on Oct 28, 2026
  4. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned. The item conflicts with a more recent project direction. No code was written.

    This item is a bulk move of single-owner tables out of config/. Its acceptance criteria use the placement baseline and the invariant tests that #1016 planned.

    The owner decision of 2026-10-22 on #1016 replaced that plan:

    • "No constant moves in this pull request. A constant moves when its module is next touched."
    • "No gate checks the placement. The project adds no new ratchet." The module core/config_placement.py, the baseline file tests/fixtures/config_placement_baseline.json and the two invariants are not built.

    #2492 (merged 2026-10-28) put the rule in CONTRIBUTING.md: "When you change the owner of a table in config/ that only one package reads, move the table to its owner in the same pull request."

    On origin/main (2026-10-28) the baseline file, core/config_placement.py and the placement tests do not exist, so the criteria of this item that use them cannot be met. A bulk move also conflicts with each open pull request that changes config/constants.py or config/defaults.py. #1026, the sibling item, is closed with the same evidence.

    A table in config/ that only one package reads now moves to its owner in the pull request that next changes that owner.

  5. removed
    status/ready
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p3-lowscope/configscope/infrascope/k8stype/refactorvalue/low

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions