Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 11.8 KB

evaluation-scope.md

File metadata and controls

43 lines (33 loc) · 11.8 KB

Evaluation scope resolver reference

Reference. resolveEvaluationScope and gsd_run check evaluation-scope (#5164, epic #5056, ADR-5057 §4). The overview is in Architecture.

resolveEvaluationScope(projectDir, unit, options) takes a unit — a phase, a plan (<phase>-<plan>) or a quick task id — and returns:

Field Meaning
status resolved (exactly the unit's own commits), degraded (the preferred evidence was absent or empty, so files come from wider evidence; reason says why) or unresolvable (git or the phase could not be read, including a git timeout; files is empty and means "could not look"). A plan or quick unit that matches nothing is resolved with reason: no-matching-commits (or empty-after-exclusions when its commits touched only excluded paths, or merge-only when every match is a merge, which carries only its own resolutions): git was read and the answer is "none", and the verb reports it as advisory, not pass
source task-commits, plan-subjects, quick-subjects, phase-range or none
commits the unit's commits (sha, subject, optionally body and files)
changedFiles / files / missingOnDisk every path the commits touched; the subset that exists on disk (the reviewable set); the subset that no longer exists, by name
outsideUnion files changed in the phase window by commits that are not the unit's, by name. What a listed catch-up merge (base branch merged into the phase branch) brought in from the base is base work the union deliberately omits, so it is not named here either, under an exact rule: a file is omitted only when it is in the merge's diff against its first parent, no listed commit sits on the merge's second-parent side, no listed non-merge commit is an ancestor of the second parent after the phase start (a branch forked from the phase), every merge-base of the two parents (git merge-base --all) is rangeBase or an ancestor of it (the fork-point rule: a side forked from phase work is phase work), and no commit of the phase window (<rangeBase>..<newest listed commit> minus what the second parent reaches, listed or not, made before or after the merge, the merge itself excluded) touched the file; any other merge commit in that window counts through its own changes against each of its parents (git log -m), so a phase-side merge's conflict resolution or edit is phase work, and a clean one over-includes (a file stays named, never hidden). Anything doubtful is named: an advisory false positive is accepted, hidden phase work is not. No merge-base, an empty-tree rangeBase (the phase directory arrived with the root commit) or any git call for that merge that fails or times out subtracts nothing for that merge only, and the scope stays resolved. Accepted cost: a second catch-up merge forks at the first catch-up's base commit, which is after rangeBase, so the base files it brings in are named as an advisory false positive. A SUMMARY whose every listed commit is a merge is merge-only-task-commits; a task commit that touched only excluded paths is not a merge, so it keeps the ordinary reasons. A phase branch merged into its base keeps its listed task commits on the merged side, so the base work in the window is still named
unreachable listed task commits that are not reachable from the evaluated ref (another branch, dropped by a rebase), by name
unparsedSummaries phase units: the live SUMMARY files that have a ## Task Commits section from which no commit id could be read, or in which a task row yielded no id, by name. Their work is not in the scope, so it is reported instead of left to read as complete. A task row may carry a qualifier before its colon (**Task 1 (tracer):**, **Task 1 RED:**), and the backticked ids on the first list level nested under a task row (a TDD task's RED and GREEN sub-bullets; wrapped description lines allowed, a blank line ends the row) belong to that row
rangeBase the phase-start anchor (the parent of the commit that first added the phase directory, or --since), for consumers that need an anchor sha

The design rules:

  • The scope is a union, not a range. A range keeps every interleaved non-phase commit in its window. Measured on a 9,676-commit repository, the range held 23, 194 and 602 files for three phases where the union of the phases' own commits held 9, 42 and 69. A phase's commits are the ## Task Commits rows of its SUMMARY files (section-scoped, row-scoped, backtick-anchored: a sha quoted in prose is not a task commit); a merge commit contributes only what the merge itself changed (its conflict resolutions and edits, from git show --remerge-diff, git 2.36 or newer), so a clean merge contributes nothing in either direction: a catch-up merge of the base branch into the phase branch adds none of the base's files, and a phase branch merged into its base adds none either, its files coming from its own task commits. On a git without --remerge-diff, and for an octopus merge, a merge contributes no files rather than the base branch's work. A SUMMARY whose listed commits are merges alone (for example only the phase-into-base merge sha) has no task commits of its own to read, so it degrades to the phase range with reason: merge-only-task-commits, never resolved with just the merge's edits.
  • Only commits reachable from the evaluated ref count. The former git log --all let a commit on any branch satisfy a check.
  • An empty union never becomes an empty scope. A phase with no SUMMARY, no task rows, no reachable task commits, or only planning paths degrades to the phase-directory range and reports degraded with the reason. A phase directory git has never seen, or an unreadable repository, is unresolvable.
  • Plan commits are matched on the subject. <type>(<phase>-<plan>): is anchored, tolerant of zero padding (03-01, 3-1) and of decimal, N-segment and letter-suffixed phase numbers, and escapes every metacharacter, so 03-01 never matches 03-010. An id carrying the project's CONFIGURED project_code (PRJ-01-01 with project_code: "PRJ", #5271) matches either spelling of the same plan — feat(PRJ-01-01): and feat(01-01): — because the two init verbs hand out different phase tokens for one plan. The code is stripped only when it is the configured one, matched case-sensitively; the configured value only has to pass a safety check (a letter first, then letters, digits, _, . or -, at most 32 characters), so gsd and AUTH-X work. An id that merely looks coded (AUTH-01-02), and an unusable project_code value, keeps the literal behaviour. Every spelling is built by qualifiedPlanSubjectPattern, the builder the workstream-qualified id proposed in #5177 is meant to share.
  • Every git call is bounded by the execGit seam; a timeout or a missing git is unresolvable, never a throw and never an empty scope.
  • A planning.sub_repos workspace is read repo by repo (#5867). The workspace root need not be a git repo: the resolver runs the same lookup in each configured sub-repo (and in the root, when the root is itself a repo) and merges the result. Commits are ordered newest first by committer time with maxCommits applied to the merged list; changedFiles, files, missingOnDisk, outsideUnion and each commits[].files are workspace-relative (<sub-repo>/<path>); a phase task-commit id is resolved in whichever sub-repo holds it, and one no sub-repo holds is named in unreachable. --ref, --pathspec, --milestone-bound (each repo bounded at its own latest tag; a repo with none is unbounded) and --committed-since apply inside every repo, and a sub-repo that has no such commit (an empty repo, or a --ref only another repo has) contributes nothing; a --since commit filters the repo that holds it by ancestry and every other repo by that commit's committer time (a --since no repo holds is unresolvable: since-not-found). Names are normalized (./app/ is app), at most 64 are read, a phase's task-commit ids times repos are capped at 1024 lookups (sub-repo-too-many-lookups), sub-repo git runs with core.fsmonitor=false, and a folder that is part of the workspace root's own repo is covered by the root. A configured sub-repo that is missing (also when the workspace root is itself a repo), escapes the project (symlinks included), or sits inside some other repo without being its own root makes the scope unresolvable with a reason naming it (sub-repo-unreadable:<name>:<cause>, sub-repo-escapes-root:<name>, sub-repo-invalid:<index>, sub-repo-too-many). A phase with no task commits has no phase-start anchor in a sub-repo, so unless the workspace root is a repo that tracked the phase directory it is an empty degraded scope whose reason ends :no-phase-start-anchor (advisory, never a pass). --pathspec is a git pathspec evaluated inside each repo, so it is repo-relative (src, not api/src); two config names that resolve to one repo are read once under the first spelling listed; a sub-repo whose directory cannot be run in makes the ancestry answer unknown (null). tdd-review-checkpoint's ancestry check asks the workspace root (when it owns its repo) and then each sub-repo, and the first repo that holds the commits answers; a repo that times out leaves the answer unknown (null), never "no". Without sub_repos nothing changes.

Workflows reach it as gsd_run check evaluation-scope:

gsd_run check evaluation-scope --phase <phase> [--since <sha>] --raw      # a phase (or --phase-dir <dir>; --ref <ref>)
gsd_run check evaluation-scope --plan <phase>-<plan> --raw                # a plan: --commits-only, --max-commits N,
                                                                          #   --milestone-bound, --committed-since <date>,
                                                                          #   --pathspec <glob> (repeatable),
                                                                          #   --all-branches (plan/quick only; see below)
gsd_run check evaluation-scope --quick <quick-id> --include-files --raw   # a quick task

--all-branches (plan and quick units only; a usage failure on a phase) looks the unit's commits up across every local branch instead of the commits reachable from --ref, and adds latestCommitTime (unix seconds of the newest match, or null) to the payload. It exists for the executor stall probe (#6117): a worktree executor's commits sit on its own unmerged agent branch until the wave merges. It is an explicit opt-in; the gates keep the reachable-from-ref contract above, and without the flag the payload is unchanged.

The verb is a resolver, not a policy: it always reports block: false, and the caller decides what a degraded or unresolvable scope means. scripts/lint-evaluation-scope-drift.cjs fails CI when a gate module, verify, a workflow or an agent derives its own range again (git log … --all, git diff … ..HEAD, a HEAD~N anchor, a hand-rolled phase-start anchor, a commit-message lookup); its allowlist pins exact non-scope sites and is drained, never renewed.

Behavior differences from the pre-resolver derivations: a UI file, task commit or decision that appears only in an interleaved non-phase commit, or only on another branch, no longer counts toward a phase or plan; ui-safety-gate reads the whole phase's commits instead of the last one and reports scopeStatus / scopeReason when the scope was widened or unreadable; decision-coverage-verify and verify schema-drift read the phase's own commit messages instead of the last 200 (or 50) commits of any branch; the code-review step names deleted files and out-of-scope files instead of counting them.