CodeHerderSearch⌘KCtrl KGet started →

Change shape

Read the size and spread of a task's change at a glance, and optionally require it to stay under a limit before a stage advance.

A big, spread-out change is harder to review than a small, focused one — not because the code is worse, but because there’s more of it to hold in your head at once. CodeHerder measures this for you automatically and calls it a task’s change shape: how many files it touches, how many lines it adds and removes, how many separate top-level areas of the repo it reaches, and how many commits it’s made. You can also ask a workflow stage to enforce a limit, so a task that grows too large or too spread out is stopped before it advances any further.

Where to see it

Web app: open the task’s page. The details list has a Change shape row, after the capability rows. It shows a verdict badge, then each figure on its own, then the reasons a limit tripped. For example:

tangled   18 files   +820/-140   5 dirs   3 commits   18 files across 5 top-level directories

A shape with a single file, directory or commit reads 1 file, 1 dir or 1 commit. A shape inside every limit shows the ok badge and the figures, with no reasons.

When no shape exists yet, the row shows an unknown badge and one of two sentences:

  • No repo is attached to this task, so there is no change to measure. Attach a repo to the task.
  • No session has reported a change shape yet. A shape appears after a session runs in the task’s sandbox.

If the numbers are behind the task’s latest work, (stale) follows the commits figure. See Staleness below.

CLI:

ch task show <taskId>

prints a change shape: row. A shape that trips a limit looks like this:

change shape:   18 files · +820/-140 · 5 dirs · 3 commits · tangled — 18 files across 5 top-level directories

A shape inside every limit shows only the figures:

change shape:   12 files · +210/-40 · 2 dirs · 3 commits

Before any session has reported a shape, it reads:

change shape:   unknown (no session has reported one yet)

ch task list doesn’t include change shape. Check an individual task’s page or ch task show for it.

A task spanning more than one repository

Once a task’s change touches more than one repo, the rollup is followed by one line per repo. See Tasks that span several repositories. The task page shows these lines under the rollup in the same row. ch task show indents them. A single-repo task’s output doesn’t change.

What the numbers mean

Four figures make up a task’s change shape. CodeHerder measures them against the branch the task’s work started from. More precisely, it measures against the point where the task’s own commits left that branch. The figures then describe only the task’s own work, even if the base branch has moved on.

  • Files changed: how many files differ from the starting branch.
  • Insertions / deletions: lines added and lines removed, shown as +N/-N.
  • Distinct top-level directories: how many separate top-level areas of one repo the change touches. A change confined to one part of a repo counts as 1. A change that reaches five unrelated top-level folders of that repo counts as 5.
  • Commits: how many commits the task’s sessions have recorded on the task’s branch.

On a task spanning more than one repository, files, insertions, deletions and commits are totalled across every repo. Distinct top-level directories is not a sum. It is the highest count from any single repo. Five repos that each touch one top-level folder still roll up to 1 dir.

The numbers cover the task’s worktree as it stands. Changes that are tracked but not yet committed count too.

A session reports its task’s shape when it starts, again mid-session whenever the set of touched files changes, and once more when it finishes. If a shape can’t be measured, nothing is recorded. The task then shows unknown rather than a shape that reads as “nothing changed.” The same report also tells CodeHerder when two sessions touch the same files. See Working nearby.

Staleness

(stale) means the recorded numbers may be behind the task’s work. A shape is stale in these cases:

  • A session in the task’s sandbox ended after CodeHerder measured the shape.
  • A session is running and the shape is more than 5 minutes old.
  • The task spans several repos and at least one attached repo has no measurement yet. The rollup is then stale.

Stale is not a problem on its own. The next session report catches the numbers up. You can also reload the page after a session finishes.

After the work merges

When a repo’s work merges, the change shape keeps showing what the task delivered. It does not reset to zero. Follow-up commits made after the merge add to the delivered figures.

What the verdict means

Every recorded change shape gets one of four verdicts:

Verdict Meaning
ok Every counter is within its limit.
large Too many files or too many changed lines, without also spreading across too many top-level directories.
tangled The change reaches across too many top-level directories. This wins over large when both trip, since a spread-out change is usually the one worth splitting up.
unknown No shape has been recorded for this task yet.

The badge takes its limits from the task’s current stage. It reads the task’s own workflow when it has one, and the task’s type otherwise. If that stage sets no limit (see Setting a limit on a stage below), CodeHerder uses built-in advisory numbers: more than 25 files changed, more than 1,000 changed lines (insertions and deletions combined), or more than 4 distinct top-level directories. The advisory verdict is informational only. It flags a change worth a second look, but it never stops a task from advancing. To make it a real limit, set one on the stage. The next section covers that.

A task with its own workflow uses that workflow’s limit, not the type’s. See Workflow overrides. The badge and the limit that can refuse an advance read the same stage limit. To see whether it refuses the move, read the advance to <stage> row in ch task show or on the task page.

Setting a limit on a stage

A workflow stage can enforce its own change-shape limits instead of the advisory defaults above. This is off everywhere by default. No built-in workflow ships with a limit. You turn it on per stage, typically the stage where an agent writes code.

Setting a limit needs a workspace owner or admin, like any other workflow edit. The stage setting has no control in the web editor, so you set it from the CLI. Print the type’s composition document, add the limit, and write it back:

ch workspace workflow composition <type> > <type>.json

In the document, add a change_shape object under the gate of that stage’s entry in instances:

{
  "instances": [
    {
      "name": "code",
      "stage": "code",
      "gate": {
        "required_fields": ["artifact"],
        "change_shape": {
          "max_files_changed": 20,
          "max_changed_lines": 800,
          "max_top_level_dirs": 3
        }
      }
    }
  ]
}

Keep the gate the instance already has, and add change_shape beside its other keys. Then write it back:

ch workspace workflow edit <type> --from-file <type>.json

A type with no stage instances has no composition to print. Read it with ch workspace workflow show --type <type> --json, copy the schema object, and add the same change_shape object under that stage’s entry in stage_gates.

edit replaces the whole workflow. Keep every other stage, gate and field in the file, not just the one you’re touching. See Manage workflows from the CLI in Customising workflows for the full round-trip.

You don’t have to set all three counters. Include only the ones you care about. A counter you leave out, or set to 0, isn’t checked. At least one must be non-zero, though. CodeHerder rejects a change_shape clause where every counter is 0. Leave the whole clause out if you want no limit on that stage.

Which kind of type you’re editing

  • A type composed from the stage library, or a hand-written type. Both use the steps above. See Customising workflows for how the two kinds differ.
  • A built-in type your workspace hasn’t copied. ch workspace workflow edit refuses it. Submit a workflow proposal that adds the limit, and have an owner or admin apply it. See Built-in types: the shared definition and your own copy and Proposing a workflow change for review.
  • One task’s own workflow. When a task has a per-task workflow override, the limit on the override’s stage decides the advance. The type’s limit does not, and the badge shows the verdict from the same limit. To change it, edit the override’s schema as Workflow overrides describes.

What happens when a task trips the limit

A task whose recorded shape exceeds a limit is refused when it tries to leave that stage. The refusal names the one counter that tripped, its actual value and the limit it exceeded, for example:

advancing out of stage "code" is blocked by its change-shape gate: max_files_changed is 34, exceeding the threshold of 20

On a task that spans several repos, a limit trips when the total exceeds it, or when any single repo exceeds it. If one repo tripped it, the refusal adds in repo "<name>".

The advance to <stage> row in ch task show names the refusal before you try the move. See Why isn’t my task moving?.

If you hit this, split the change into smaller tasks so each one fits inside the limit. Or raise, or remove, the limit on that stage if it’s too tight for the work.

What a change-shape limit never blocks

A limit only checks a move out of the stage that declared it, and only once a shape is known. It never blocks:

  • a task whose change shape hasn’t been recorded yet (unknown),
  • cancelling, blocking or archiving a task,
  • reopening a task out of a finished stage,
  • a counter that’s left at 0 or not included in the clause.

The web workflow editor shows the limit but can’t change it

The Workflows editor in the web app has no control for change_shape. You set, change or remove a limit from the CLI. Saving a type from the web app leaves every stage’s limit as it was. Each stage that has a limit shows it read-only, labeled “Change-shape limit:”, beside its required-fields and approval controls. An administrator can see what’s enforced without leaving the web app.

Last updated

Try it on one repository for two weeks.

File a task. An agent builds it. You see the cost of each task.

Try "pricing", "connect a device", or "who reviews the code"

↑↓ move · ↵ open · esc close