Skip to content

fix(roadmap): implement runs the commit hooks on docs and archive #4781

Closed

Description

@dan-petty

Problem or Motivation

The implement Job makes its docs commit and its archive commit through _commit_if_changed (src/devops_cli/roadmap/implement/implement_run.py), and no hook runs on them. Its step commits run the commit stage (commit_stage in src/devops_cli/roadmap/implement/implement_hooks.py). A hygiene problem in a generated or archived file thus reaches the pull request with no local check.

Proposed Solution & Architectural Design

In _commit_if_changed, when self._hooks_config() gives a config, call commit_stage(self.path, config) before git commit. When a fixer changes files, stage them and run the stage once more, as the step commit does. The archive commit also runs the openspec gate through its path filter.

wip: commits do not change. The fixers would change files while the agent edits them, and #4713 sends wip commits to a branch with no pull request.

Target Subsystem

Roadmap Automation & Planning (src/devops_cli/roadmap/implement/).

Existing Tool Considered

pre-commit, with the trusted config of main that is already in the runner image. The change reuses commit_stage. Cost (estimate): about 80,000 tokens and 2 hours to build, near 0 to keep.

Acceptance Criteria

Tests:

  • A docs commit with trailing whitespace in a generated file is committed with the fix.
  • A hook that fails two times stops the item and shows the hook output.

On 2 CPUs, the archive commit takes at most 20 s more (13.2 s measured for the openspec gate).

Dependencies

None. Related: #4713.

Source: #4771

Alternatives check of 2026-11-14: in-use.
The repository already uses this tool.
Tool: pre-commit/pre-commit (https://github.com/pre-commit/pre-commit), MIT, last activity 2026-11-09, maintained.

Proposed design

Problem statement

The implement Job commits the regenerated docs and the archived change through _commit_if_changed, and no commit hook runs on those commits. A hygiene defect in a generated or archived file thus reaches the pull request with no local check. The change runs the trusted commit stage on the commits of _commit_if_changed, commits the files that a fixer rewrites, and stops the item when the stage still fails. The change stays on the commit path and adds no roadmap step.

Acceptance criteria

Requirement: Commit stage before commit

The implement Job SHALL run the trusted commit stage on the staged changes of each commit that _commit_if_changed makes, before git commit.

Scenario: Docs commit runs the stage

  • WHEN The docs generator changes a generated file and the job reaches _commit_if_changed.
  • THEN The commit stage runs over the staged changes before git commit.

Requirement: Fixer rewrite is committed

The job SHALL commit the files that a commit-stage fixer rewrites, with the rewritten content.

Scenario: Trailing whitespace is trimmed

  • WHEN A generated document holds trailing whitespace and the commit-stage hook rewrites the file.
  • THEN The docs commit holds the rewritten file, and that file has no trailing whitespace.

Requirement: Hook failure stops the item

The job SHALL stop the item with the hook output when the commit stage still fails after the fixer rerun.

Scenario: Second stage run fails

  • WHEN The commit stage fails, stages the files that the fixer changed, and fails again.
  • THEN The item stops with the hook output in the stop comment, and no docs or archive commit is made.

Requirement: No change runs no hook

The job MUST NOT run the commit stage when the commit holds no change.

Scenario: Docs generator writes nothing

  • WHEN The docs generator writes no file and the checkout holds no change.
  • THEN The job makes no commit and runs the commit stage zero times.

Requirement: WIP commit skips the stage

The job MUST NOT run the commit stage for a wip: commit of a step.

Scenario: Step keeps a ticked task

  • WHEN A step makes a wip: commit for a ticked task.
  • THEN The commit stage runs zero times for that commit.

Requirement: Archive commit runs a matching hook

The job SHALL run the commit stage over the staged archive commit, so a hook whose file filter matches openspec/changes/archive/ runs.

Scenario: OpenSpec gate matches the archived path

  • WHEN The archive commit stages a file under openspec/changes/archive/ and the configured hook filter matches that path.
  • THEN The hook runs on that file before the archive commit.

Requirement: Archive commit time

The archive commit SHALL add at most 20 s on 2 CPUs when the commit stage runs.

Scenario: Measured archive commit

  • WHEN The archive commit runs on 2 CPUs with the configured hooks, and the same commit runs with the stage disabled.
  • THEN The run with hooks takes at most 20 s more than the run without them.

Existing Tool Considered

pre-commit (https://github.com/pre-commit/pre-commit), MIT and maintained, is already in use and backs the existing commit_stage. It runs the configured commit hooks on staged files, and it supports fixer hooks that rewrite files, which commit_stage stages and runs again. It lacks the call from _commit_if_changed and the policy on which commits run it; the change supplies that project code.

Key questions

  • Which commits run the trusted commit stage?: Every commit that _commit_if_changed makes: the docs commit, the archive commit, and the amendment and split commits. The call sits in _commit_if_changed, after the status check and before git commit. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:749, src/devops_cli/roadmap/implement/implement_hooks.py]
    • Chosen: One call in _commit_if_changed. The commit path is single, so one call covers the docs, archive, amendment and split commits.
    • Rejected: A call at the docs and archive sites. It repeats the same code and leaves the amendment and split commits without the stage.
    • Rejected: A git hook in the checkout. The agent can edit the hook, and the process runner gives a git child the session token.
  • What does the job do when the commit stage still fails after the fixer rerun?: It raises a stop with the hook output, so the item stops and the comment shows the output. No docs or archive commit is made. (best practice) [sources: src/devops_cli/roadmap/implement/implement_hooks.py, src/devops_cli/roadmap/implement/implement_run.py]
    • Chosen: Stop the item with the hook output. A local check that fails stops the item, as a failed command of the job does.
    • Rejected: Commit anyway and let the pull request checks catch it. The issue asks for the local check, and the pull request checks would cost a repair round.
    • Rejected: Run the stage a third time. commit_stage already stages the fixer files and runs the stage once more.
  • Do wip: commits run the commit stage?: No. The step makes wip: commits in implement_step.py, and the job only records and pushes them in _keep. _commit_if_changed makes no wip: commit, so the new call leaves that path unchanged. [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/implement/implement_step.py]
  • Does the archive commit run a hook whose filter matches the archived path?: Yes. _commit_if_changed runs git add -A before the stage, so the archived folder openspec/changes/archive/<date>-<issue>-<slug>/ is in the staged set that pre-commit filters. [sources: src/devops_cli/roadmap/implement/implement_hooks.py]
  • Does this change need a dependency or a wait on fix(roadmap): the final push of the implement Job can miss the latest main #4957?: No. The issue records no dependency, and the lease push of fix(roadmap): the final push of the implement Job can miss the latest main #4957 is already in _push, so nothing waits on it. feat(roadmap): the implement Job opens its PR at the end #4713 is related and stays out of this change. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Hygiene gaps reach the pull request but do not block delivery or expose a security risk.
    • Value: Medium. Catches whitespace and format issues before the pull request, reducing review noise.
    • Effort: Low. The body estimates about 2 hours and 80,000 tokens to build, reusing the existing commit_stage call.
    • Related: feat(roadmap): devops roadmap implement runs every group of a staged change, archives it, fixes a failed check once and marks the pull request ready #2665, which asks for a different change. Both concern the implement job's commit behaviour, but #2665 delivers the job and #4771 fixes the missing hook call on its docs and archive commits.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Scope update from the Service step jobs plan (#5014).

    The owner asked on 2026-11-12 for a separate job for each step that the Service jobs run the same way every time. This issue is the archive-step item of that plan. The plan is extract-first: each repeated step becomes one module and one command (devops roadmap step <name>) that every caller uses, and then the steps that cost most move to their own Jobs.

    Proposed title: fix(roadmap): one finish step runs docs, archive and hooks

    Problem (plan evidence)

    implement_run.py:1236 (_finish_change) runs devops docs generate and devops openspec archive only at the end of the runner Job, and the commit hooks do not run on these commits (#4781). The fix-conflict step needs the same function to make the archive again after a spec conflict. 75 % of the measured conflicts are OpenSpec archive appends (merge-conflict census, 2026-11-11).

    Added scope

    steps/archive.py finish(path, change, issue): docs generate, then openspec archive with strict validation, then one commit with the hooks (the #4781 fix). The archived folder in git is the marker: when _active_change is None, the step skips. Results: archived, already, failed (typed stop plan_defect).

    CLI devops roadmap step archive. The implement Job calls it in place of _finish_change.

    Timeouts: docs 300 s, archive 300 s, step 600 s, inside the command limit of 1800 s.

    Start after push-step, because _finish_change (:1236) lies between _keep (:1187) and _push (:1258), so the two pull requests conflict when they run at the same time.

    Cost: about 0.5M tokens and 0.5 agent-day.

    Added acceptance

    Merge first

    Coordination

    #4771 stays the parent. This item widens #4781 to the one finish step that fix-conflict also calls.

  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Coordination note from #5163 (pull request #5198): that change edits _generate_docs in src/devops_cli/roadmap/implement/implement_run.py. The docs step now runs uv run devops docs generate with no --sync-readme, because the option is deleted. It does not change _commit_if_changed, so this item can build on either order.

  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found pre-commit, the maintained open-source git hook framework that the project already uses for its commit stage; it runs the configured hooks on staged content and supports fixer hooks that rewrite files and re-run, which is exactly what the issue wants on the docs and archive commits by reusing commit_stage. The issue itself names pre-commit as the existing tool to reuse, so it is already in use.

    The repository already uses this tool.

    Tool: pre-commit/pre-commit (https://github.com/pre-commit/pre-commit)

    • License: MIT
    • Last activity: 2026-11-09
    • Maintained: yes

    Covers:

    • Runs the project's configured commit hooks on staged files before a commit
    • Supports fixer hooks that modify files, which can then be staged and re-run
    • Is the framework behind the existing commit_stage that the issue reuses

    Lacks:

    • It does not wire the hook call into the implement job's _commit_if_changed; that integration is project code
    • It does not decide which commits (docs/archive vs wip:) run the hooks

    Tools considered:

    Searches run:

    • pre-commit framework run git commit hooks on commits, results: 5
    • pre-commit git hook manager pre-commit.com, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  8. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at e5dfddb while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/implement/implement_run.py.

  9. added
    status/ready
    and removed
    status/new
    on Nov 15, 2026
  10. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 6786f1a (see proposed design in issue body).

  11. added
    status/in-progress
    and removed
    status/ready
    on Nov 16, 2026
  12. added
    status/in-review
    and removed
    status/in-progress
    on Nov 16, 2026
  13. removed
    status/in-review
    on Nov 16, 2026
  14. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-16 06:35 UTC

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/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions