Skip to content

shape_advisory.py: a single-repository.yaml committed as a symlink is read as its path, so plan and check advise with a false (YamlError) NOTE where the doctor says recorded-single (#1163) #1272

Open

Description

@brettheap

(lane openRepoShape-1, 2026-11-08T19:17:12Z)

Goal: adopt-project.py plan and check read a single-repository.yaml (and a project.yaml or family.yaml) that the commit holds as a symlink the way the doctor reads it on the disk, or say plainly that they did not follow a link, so a project that recorded staying single gets no advisory and no it could not be read (YamlError) NOTE over a file that can be read.

Problem

The Triad advisory that plan and check print is read from the commit the plan is written against (adopt-project.py:5971-6016; shape_advisory.read(path, commit=commit) at :6004). Tree.text (scripts/shape_advisory.py:441-449 at main 81eaf757) gives a committed file's bytes with git cat-file blob <commit>:<rel> (:447-448). For a symlink that blob holds the PATH it points to, not the file's text, and Tree.kind (:427-439, cat-file -t) answers blob, so the link counts as a file. On the disk the operating system follows the link, so the doctor reads the file.

Three readers take the path as YAML:

  • read_record (:765-799), for single-repository.yaml: parse_yaml("docs/record.yaml") raises YamlError: line 1: expected `key: value`, got 'docs/record.yaml' (:789). The broad except (:790-792) turns it into RECORD_SILENCES_NOTHING with it could not be read (YamlError), and record_report (:266-272) prints it as NOTE single-repository.yaml does not silence this: .... The NOTE is false: the record can be read; it is a link. And plan advises "This is a single repository" over a project that recorded staying single, where the disk reading (the doctor's) is recorded-single and the doctor stays silent.
  • _read_mapping (:452-467), for project.yaml (:839) and family.yaml (:843): the same raise is swallowed to None by design (:453-461: a manifest it cannot read is a manifest it does not see), so there is no NOTE at all, and an assembly root or a family holder reads as neither (is_triad is False; the family-manifest test at :844 is False) and falls through to advise (:900).
  • adopt-project.py reads the record a second time, for the record question (adopt-project.py plan: ask about single-repository.yaml with its own drop-or-root rule, not the generic ambiguous-top-level-yaml question #528): ask_about_a_record_only (:3240-3269, called at :6483) asks read_record(Tree(source.path, source.commit)) (:3260-3261). A linked record is "no record" there, so the single-repository.yaml entry is asked the general ambiguous-top-level-yaml question (contracts/path-classification.yaml:474) with leg: null, in place of the record's ambiguous-single-repository-record question with its default drop (contracts/path-classification.yaml:453; the default was ruled by Brett Heap on 2026-10-12, adopt-project.py:3276). check --plan then finds plan-unresolved and exits 1, where a regular record plans clean and exits 0.

#1270 (for #1163) makes the commit reading follow a link for AGENTS.md only (Tree.is_link and Tree.text_through, shape_advisory.py:508 and :536 at its head 8e54c32d; neither exists on main). It lists this gap as a Known limit ("Unchanged by this PR."), and rejects following every file's link there because the record's reading also decides plan's record question (#528).

Measured

Main 81eaf757c1379f7a7e86e49940bef86def74fb34, git 2.43.0, CPython 3.12.3, in the probe environment (a stub gh first on PATH, a bogus GH_TOKEN, an empty GH_CONFIG_DIR, GIT_CONFIG_GLOBAL=/dev/null, GIT_SSH_COMMAND=false), no network. Each fixture is a one-commit repository in a folder Atlas whose origin is the acme/Orbit repository on github.com (never contacted), as r1163's fixtures are. The file is committed as a symlink to a regular file in docs/ of the same commit (docs/record.yaml, docs/project.yaml, docs/family.yaml), with a regular-file control beside each. The record holds the example of contracts/single-repository-record.yaml; project.yaml is a minimal Triad manifest (kind: project-manifest, schema: project-repo-schema, legs assembly, spec, code); family.yaml is kind: family-manifest. Per fixture:

adopt-project.py plan --source <Atlas> --project Orbit --org acme --elected-by 'Test Human' --elected-on 2026-10-06 --out <plan.yaml>
adopt-project.py check --plan <plan.yaml>
shape-doctor.py --root <Atlas> --json
shape_advisory.read(<Atlas>, commit=<sha>)   # the commit reading, in process
shape_advisory.read(<Atlas>)                 # the disk reading, in process (the doctor's)

1. The three files (exit codes: plan / check / doctor):

# committed as commit reading disk reading plan check --plan shape-doctor.py --json
1 single-repository.yaml -> docs/record.yaml advise, problem it could not be read (YamlError) recorded-single 0: the two triad lines, then the NOTE below; entry leg: null, rule ambiguous-top-level-yaml 1: the same three lines, and FINDING plan-unresolved: single-repository.yaml still has leg: null 2, kind none, NOT A SHAPE ROOT; no triad-advisory row
1c control: a regular single-repository.yaml recorded-single recorded-single 0: no Triad line; entry leg: drop, rule ambiguous-single-repository-record 0: no Triad line, no finding 2, kind none; no row
2a project.yaml -> docs/project.yaml, an assembly root advise triad-root 0: the two triad lines, no NOTE 1: the same lines; plan-unresolved and plan-root-symlink 1, kind project
2a-c control: a regular project.yaml triad-root triad-root 0: nothing 1: plan-unresolved only 1, kind project
2b the link of 2a beside a regular spec-leg AGENTS.md (r1163's leg fixture) leg-clone triad-root 0: NOTE this is a clone of the spec leg of a Triad (its AGENTS.md is the spec leg's, as templates/spec-root/ writes it) ... 1: that NOTE; plan-unresolved and plan-root-symlink 1, kind project
2b-c control: regular project.yaml beside the leg's AGENTS.md triad-root triad-root 0: nothing 1: plan-unresolved only 1, kind project
3 family.yaml -> docs/family.yaml, a family holder advise family-holder 0: the two triad lines, no NOTE 1: the same lines; plan-unresolved 1, kind family
3c control: a regular family.yaml family-holder family-holder 0: nothing 1: plan-unresolved only 1, kind family

The exact lines of row 1, in plan and in check:

triad      This is a single repository. The Triad -- an assembly root with a spec leg and a code leg -- is the preferred project shape, and this tool is how a repository reaches it, in place; preferred, not required: it confers nothing, and a single repository is reviewed identically.
           Nothing converts until `execute`, on the word of a person deciding for this project, and a project that stays single can say so in single-repository.yaml instead. `plan` and `check` change nothing in it.
NOTE single-repository.yaml does not silence this: it could not be read (YamlError) (its schema is openRepoShape's contracts/single-repository-record.yaml); nothing fails on its account.
  • Rows 2 and 3 exit 1 from check in the control too (a top-level project.yaml or family.yaml of the repository's own is an open question there), so the exit code does not tell the link from the control; the printed advisory does. plan exits 0 in all ten rows, as the advisory never changes an exit status.
  • Row 2a is the realistic fixture. A leg does not ordinarily hold a project.yaml, so row 2b is r1163's leg fixture with the link added; it shows project.yaml is read before the leg's AGENTS.md on the disk and not in the commit.
  • The doctor's --json rows are the same for each link and its control, but for shape-currency in rows 2 and 3, which says update-shape.py cannot re-pin this root: REFUSED update-rewrite-symlink: ... This command never writes through a symlink (update-shape.py:1558-1601). A linked record has no such refusal.
  • The doctor says recorded-single by saying nothing: its triad-advisory row is absent for that state unless the record has field problems (shape-doctor.py:12296-12306), as rows 1 and 1c show.
  • The doctor asks its triad-advisory row only of a directory with neither manifest (shape-doctor.py:12259-12267), so rows 2 and 3 have no such row, link or control: it classifies them as kind project and family, and the in-process disk reading names the state.

2. Other links to a record (exit codes plan / check / doctor are 0 / 1 / 2 in each row):

single-repository.yaml committed as commit reading disk reading
a link to a file of another kind (kind: release-config) advise, NOTE it could not be read (YamlError) advise, NOTE it declares kind 'release-config', not 'single-repository-record'
control: that file regular advise, the declares kind NOTE the same
a link spelled ./docs/record.yaml to a record in the commit (git 2.43 answers dangling for a . segment) advise, NOTE it could not be read (YamlError) recorded-single
a dangling link (docs/record.yaml is not in the commit) advise, NOTE it could not be read (YamlError) advise, no NOTE (the stat fails ENOENT: absent)
a link out of the commit (../elsewhere/record.yaml, a record beside the repository) advise, NOTE it could not be read (YamlError) recorded-single

3. #1270's head 8e54c32d against main. The same 13 fixtures (rows 1 to 3 and these), every printed field (exit codes, the advisory and NOTE lines, the plan entry, the doctor row, both readings): 0 differences. #1270 changes nothing here, as its body says.

4. A scratch prototype of following the link (not a patch; no tests run beyond these fixtures): #1270's head with read_record (:789) and _read_mapping (:463) changed to read tree.text_through(rel) if tree.is_link(rel) else tree.text(rel) (two call sites, 6 lines added and 2 removed; a None reads as absent). On the same fixtures:

fixture with the link followed
1, record link recorded-single; no Triad line; entry leg: drop, rule ambiguous-single-repository-record; check exits 0 (as the control)
2a, 2b, 3 triad-root, triad-root, family-holder: no Triad line, no leg NOTE (as the disk)
link to another kind NOTE it declares kind 'release-config', not 'single-repository-record' (as the disk)
link spelled ./docs/record.yaml recorded-single; entry leg: drop; check exits 0 (as the disk; text_through drops the . segment)
dangling link advise, no NOTE (as the disk)
link out of the commit advise, NOTE it could not be read (OutOfTheCommit): the exception's class name; the disk says recorded-single

Suggested fix

Two ways, and they combine.

A. Follow the link inside the commit, as #1270 does for AGENTS.md. Once #1270 has landed, read_record and _read_mapping read through Tree.is_link and Tree.text_through (measurement 4). For it:

  • On every fixture of measurement 4 that stays inside the commit the readings then agree, including what plan writes and check's exit, and a regular file reads as before (is_link costs one git ls-tree and answers False where git cannot say).
  • It is the only way project.yaml and family.yaml are reached: _read_mapping swallows every error by design and has no NOTE channel.
  • The ./docs/record.yaml spelling, which git 2.43 answers dangling, is already handled in text_through (_dot_segments_dropped; measured in measurement 4).

Against it:

B. An honest NOTE. read_record asks Tree.is_link(RECORD_FILE) first and, for a link it does not follow (or cannot), returns RECORD_SILENCES_NOTHING with a sentence that is true, for example it is a symlink in the commit, which the commit reading does not follow, so whether it records that this project stays a single repository is not known here. One call site, no change to the record question. Against it: plan still prints the advisory and still asks the general question (row 1's leg: null, plan-unresolved, exit 1), so it still disagrees with the doctor about a project that recorded staying single; only the false sentence goes. It cannot reach project.yaml or family.yaml without a new NOTE channel, so those would stay advise over a Triad root or a holder.

Weighing. Lead with the record; take A for the links that stay inside the commit, after #1270 lands, with the #528 consequence ruled first, and B's sentence for a link out of the commit and for any link git cannot follow. project.yaml and family.yaml come with A's two lines but are the less likely cases: update-shape.py already refuses to re-pin a root whose manifest is a link (update-rewrite-symlink), and the record's template says "Copy this file to the repository's ROOT" (templates/single-repository/single-repository.yaml:20). If they are left out, pin their advise with a row so the choice is on record.

Verify

Rows in tests/test_shape_advisory.py or a new tests/test_advisory_record_symlink.py beside #1270's tests/test_advisory_agents_md_symlink.py (the same fixtures and the read(commit=) and plan and check assertions), each failing on main:

  • The record linked to a record inside the commit: read(commit=) is recorded-single as read() is; plan prints no Triad line; the entry is leg: drop, rule ambiguous-single-repository-record; check --plan exits 0.
  • The same spelled ./docs/record.yaml, and through a linked folder.
  • A link to a file of another kind: the NOTE names the kind, as the disk's does, not YamlError; the entry stays leg: null.
  • A dangling link, a loop, a link to a directory, a link through a file, a link to a file that is not UTF-8 (the errors="replace" survivor of r1163, R6): under A the commit and the disk readings agree, with no YamlError NOTE where the disk says nothing.
  • A link out of the commit, relative and absolute: the NOTE says it is a link out of the commit, with no exception name in it.
  • project.yaml linked to a Triad manifest: triad-root, no advisory line; the same beside a regular leg AGENTS.md (row 2b: triad-root, not leg-clone); family.yaml linked to a holder's manifest: family-holder. Or, if left out, the three pinned as advise.
  • Controls: each of the three files regular, unchanged on main and with the change; a git whose ls-tree fails reads a regular file as before.
  • The doctor's leg audit (shape-doctor.py:9419-9424) and plan agree for a leg whose index holds the record as a link (tests/test_doctor_recorded_answers.py).
  • Mutants, each killed: the link not followed in read_record; not followed in _read_mapping; a dangling link read as a record; a link out of the commit read from the disk; the followed blob decoded with errors="replace"; ask_about_a_record_only handed a different tree than read_record reads; the leg audit following where plan does not.
  • Gate: the new file, tests/test_adopt_single_repository_record.py, tests/test_shape_advisory.py, tests/test_doctor_recorded_answers.py, tests/test_path_guard_hygiene.py; and, for a change to adopt-project.py, tests/test_shape_doctor.py (4 shards) and tests/test_scaffold_leg_path_collisions.py. Measured on git 2.43.0 and CPython 3.12.3 only; CI runs 3.14, and a git that follows a . segment answers the first ask.

Found by review r1163 of lane 1's PR #1270 (for #1163), Known limits (#1270 issuecomment-6724915296).

Outside v1.2.0 by Brett Heap's ruling of 2026-10-21T10:32:04Z.

Lane: openreposhape-1 (openRepoShape-1)

Activity

  1. added this to the v1.2.2 milestone on Nov 8, 2026
  2. brettheap commented on Nov 10, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-5, session 50cede29-ab82-4ca3-9f67-d98e1a58c8d2@Eagle, 2026-11-10T01:12:27Z, for #1272

    Logged in lanes/log/openRepoShape-5.md at db1db0d42c42c597e5ec1a3679f303cf89943668.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#1272:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#1272"`, kept where the row or its body names `#1272`:
    1270	shape_advisory.py: a leg's `AGENTS.md` committed as a symlink is read through it inside the commit, and one out of the commit leaves whether it is a leg unknown, so `adopt-project.py plan` and `check` stop calling the leg a single repository (#1163)	fix/1163-agents-md-symlink	OPEN
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `1272` as a whole token:
       none
    
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions