Skip to content

Fix fix-plan cleanup script bugs around duplicate section headings #309

Description

@DrumRobot

Problem

A tracking file processed by the fix-plan cleanup.py script can end up with the same top-level section heading (e.g. a recurring-tasks section) appearing twice, usually from independent sessions each appending content without checking whether the heading already exists. Two concrete bugs were found once that state occurred:

  1. Duplicate-heading insertion bug: cleanup.py's completed-item archival step inserts a fresh "Completed" section heading before every occurrence of the recurring-tasks heading it finds, with no guard checking whether a "Completed" section was already inserted earlier in the same run. When the recurring-tasks heading appears twice, running the script produces a duplicated "Completed" section instead of a single consolidated one.
  2. False-positive schema warning: A separate hook that checks tracking-file items for a required Why/How-to-apply structure fires an advisory warning on recurring-task items too, even though recurring-task items intentionally follow a different schema (condition/procedure/cost), not the Why/How-to-apply schema the check expects.

Scope

  1. Fix the archival step in cleanup.py to track whether it has already inserted a "Completed" section during the current run (e.g. an inserted_completed flag) and skip re-inserting it on a second occurrence of the recurring-tasks heading.
  2. Add an exception to the schema-check hook so recurring-task items (identified by their own marker/tag convention) are validated against their own condition/procedure/cost schema instead of the Why/How-to-apply schema, avoiding the false-positive advisory.
  3. Add a regression test/fixture for each fix: (a) a fixture tracking file with two occurrences of the same recurring-tasks heading, verifying only one "Completed" section is produced after archival; (b) a fixture recurring-task item, verifying the schema-check hook does not fire its advisory on it.

Verification

Feature Procedure Expected Result
No duplicate Completed section Run the archival step against a fixture file with a duplicated recurring-tasks heading Exactly one "Completed" section exists in the output, not one per heading occurrence
Schema check no longer false-positives on recurring-task items Run the schema-check hook against a fixture recurring-task item (condition/procedure/cost schema, no Why/How-to-apply fields) No advisory warning fires
Existing schema-check behavior preserved Run the schema-check hook against a fixture normal item missing Why/How-to-apply Advisory warning still fires as before
Existing cleanup fixtures Run the cleanup script's existing test suite All existing tests still pass

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions