Skip to content

Simplify inherited attribute handling - #144

Closed
shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:inherited-as-exprvar
Closed

shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:inherited-as-exprvar

Conversation

@shlevy

@shlevy shlevy commented Jul 15, 2013

Copy link
Copy Markdown
Member

This reduces the difference between inherited and non-inherited
attribute handling to the choice of which env to use (in recs and lets)
by setting the AttrDef::e to a new ExprVar in the parser rather than
carrying a separate AttrDef::v VarRef member.

As an added bonus, this allows inherited attributes that inherit from a
with to delay forcing evaluation of the with's attributes.

Depends on/includes #130 for the test case

@shlevy

shlevy commented Jul 15, 2013

Copy link
Copy Markdown
Member Author

Not including the additional tests, shlevy/nix@fecf5cf has 19 additions and 36 deletions.

@edolstra

Copy link
Copy Markdown
Member

Could you rebase this on the current master?

This reduces the difference between inherited and non-inherited
attribute handling to the choice of which env to use (in recs and lets)
by setting the AttrDef::e to a new ExprVar in the parser rather than
carrying a separate AttrDef::v VarRef member.

As an added bonus, this allows inherited attributes that inherit from a
with to delay forcing evaluation of the with's attributes.

Signed-off-by: Shea Levy <[email protected]>
@shlevy

shlevy commented Jul 31, 2013

Copy link
Copy Markdown
Member Author

Rebased

@edolstra

Copy link
Copy Markdown
Member

Applied.

@edolstra edolstra closed this Aug 26, 2013
ConnorBaker pushed a commit to ConnorBaker/nix that referenced this pull request Jul 25, 2025
ci: don't run the full test suite for x86_64-darwin
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 22, 2026
The catalog has accumulated enough cross-pass review work to need a
permanent rule about what counts as evidence. Prior passes shipped
findings that turned out to rest on weak ground:

- E2 grep'd `nix::settings.*` field reads in src/*-c/ and concluded
  no settings type was exposed across the C ABI. V1 found that 5 of
  6 C-API libraries install their *_internal.h(h) files, exposing
  layout to C++ consumers through the public include path. The
  inventory was correct; the conclusion was wrong because it
  reasoned about source-tree contents rather than shipped headers.
- E6 predicted "16/22 fixtures fit cleanly" for an N41 consolidation;
  V5 verified each fixture against the source body and corrected to
  "27/28 with (subdir, suffix)". The catalog body did not mark E6's
  numbers as predicted.
- The "NixOS#136 keystone for NixOS#134/NixOS#135/NixOS#137/NixOS#144/NixOS#149" chain propagated
  through three passes before B1 found that NixOS#135 does not actually
  depend on NixOS#136. Citation alone is not evidence; later passes
  inherited prior framing without re-deriving.
- E8 wrote "negligible performance benefit" without measuring; V4
  confirmed Direction A on four non-perf grounds and downgraded the
  perf framing.
- E4 reported "61 positional-format sites in libstore" as
  wire-crossing without filtering by reachability from a
  daemon-side WorkerProto::Op handler. (V2 still in flight.)
- B2 found that forceAttrs/forceList look like the rest of the
  force* family but use withTrace rather than addTrace+try/catch.
  The "10 force* overloads" claim was structurally similar function
  names treated as the same problem.

Add an "Evidentiary standard" section to candidates/README.md
enumerating eight rules:

  1. Walk the call graph (behaviour claims trace at least one
     caller; lifetime claims trace destruction order).
  2. Trace what ships, not what is in src/ (ABI claims must check
     install rules).
  3. Counts require closed enumeration.
  4. Distinguish predicted from verified.
  5. Re-derive inherited claims (citation alone is not evidence).
  6. "Same shape" is not "same problem".
  7. Numbers require measurement (or label "structural reasoning,
     unmeasured").
  8. Comments are hypotheses; verify against code.

Add review/AGENT-CHARTER.md as the operational form of the same
rules, intended for any future agent prompt to reference. The
charter requires every report to include a Method section, a
per-rule statement of which rules were exercised, and per-claim
verifiability labels (verified / predicted / unsupported).

Also drops the prior "8 verified counts" snapshot from
INVENTORY.md and replaces it with a pointer to the per-section
catalog (the snapshot was stale by the time the consolidation pass
ran). Drops one count line that referenced WorkerProto::latest as
"1.38" without disambiguating from the PROTOCOL_VERSION macro
(now 1.39); the macro and the struct are two genuinely different
version handles, see review/F3-proto-version-drift.md.

Lands all completed review reports under doc/inventory/review/:
E1-E8 + F1-F3 + B1-B3 + C1 + V1, V3, V4, V5. V2 still in flight
and will land separately.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 22, 2026
Folds the findings from E1-E8, F1-F3, B1-B3, C1, and V1-V5 into the
candidate sections as in-place body edits. Each affected candidate now
carries a See also: line pointing at the verifying report(s); counts
are re-derived where the V-pass produced a verified number; mechanism
corrections from source-level investigations replace inherited framing.

Substantive corrections to existing candidates:

- NixOS#134 / NixOS#135 / NixOS#138 (15-globals-settings.md):
  - B1 found that the catalog's "NixOS#136 keystone for NixOS#134/NixOS#135/NixOS#137/
    NixOS#144/NixOS#149" chain is wrong about NixOS#135. The body's keystone block
    now lists only NixOS#134/NixOS#137/NixOS#144/NixOS#149 as NixOS#136-blocked; NixOS#135 is
    independent. The reasoning is preserved in NixOS#134's and NixOS#135's
    bodies (asymmetry between virtual-base diamond and inline-member
    flattening).
  - V1 found that 5 of 6 C-API libraries install_headers with their
    *_internal.h(h) files, exposing layout to C++ consumers. The NixOS#138
    body now spells out the C++ ABI caveat for deleting the dead
    nix::ref<bool> readOnlyMode field, with a release-note requirement.
  - F1+V3 confirmed (via end-to-end source trace) a latent UAF in the
    _new-without-_load path: the heap bool is destroyed by
    nix_eval_state_builder_free while the resulting EvalState still
    holds a bool * to it. NixOS#138's body now folds the UAF repair into
    the readOnlyMode -> Store migration, so deleting the dangling
    field sweeps the bug away in the same change.

- NixOS#65 / NixOS#211 (08-duplicated-parsers.md, 21-eval-core-evalstate-value.md):
  - B2 verified by source reading that NixOS#65 has 79 canonical-template
    sites plus ~135 bespoke. NixOS#211 has 7 structurally-shared bodies,
    not 10 and not 16: forceAttrs/forceList use withTrace (a different
    shape) and forceString(NixStringContext &, ...) / forceStringNoCtx
    delegate to the single-overload forceString. The catalog's proposed
    merge of NixOS#65+NixOS#211 was rejected on different-risk-profile and
    different-consumer-scope grounds. NixOS#211 first (~1 week, internal);
    NixOS#65 second (~4-6 weeks, user-visible trace migration).

- NixOS#213 (21-eval-core-evalstate-value.md):
  - E8+V4 recommend Direction A on four non-perf grounds. V4 downgraded
    the unsupported "negligible perf benefit" framing and surfaced a
    critical observation: ExprOpEq::eval evaluates into stack-local
    Value v1/v2 and ExprVar::eval ends with v = *v2; — the highest-
    frequency eqValues caller cannot benefit from canonical pointer-
    equality regardless of direction.

- NixOS#18 (03-repeated-boilerplate.md):
  - B3 verified the hand-written CloneableError derivation count is 17
    (catalog said 14). 18a (the MakeError macro itself) is not a real
    refactor target because MakeError already is CRTP sugar. 18b is
    per-class because most carry intrinsic payload. 18c is too small
    for top-level status. Body now documents the SQLiteBusy/SQLiteError
    cross-link and the BadNixStringContextElem/GitError err.msg-
    mutation fragility.

- NixOS#166 (17-cross-cutting.md):
  - E7 verified per-file unique-header counts: 8 Source, 5 Sink, 20
    Store, 12 EvalState, 7 Value, 6 StorePath, 10 StoreDirConfig.
    Recommendation: ship serialise-fwd.hh AND store-fwd.hh AND
    eval-fwd.hh together. Self-forward-decl caveat: don't replace the
    inline self-decls in store-api.hh and eval.hh. Zero C-API impact.

- NixOS#125 (14-vestigial-stdlib.md):
  - E4+V2+F2 verified the wire-crossing scope. Daemon does NOT link
    libexpr; libexpr's 107 throws are local-only. Wire-crossing
    surface is libstore (199 throws, 71 positional %N%, 51 reachable)
    plus libutil (281 all-format, 50 positional, 45 reachable). V2
    found 5 categories of sites E4's grep missed including the
    load-bearing store-api.hh::Store::requireStoreObjectAccessor.
    F2 found a second wire-crossing text-grep contract: "is not valid"
    in BasicClientConnection::queryPathInfo. Phasing constraint:
    text-grep contracts span both %s and %1% sites; Phase 2 cannot
    batch positional and non-positional separately for any
    contract-bearing site.

- NixOS#128 (14-vestigial-stdlib.md):
  - Note added per CLAUDE.md: the landed cleanup/libmain-shared branch
    bundled this with the unrelated blockInt deletion (NixOS#49). Soft
    style issue; recorded for future cleanup-branch authors.

- NixOS#140 (15-globals-settings.md):
  - E1's verification cleared the deletion path. nm -m on the built
    dylib confirms internal linkage; lix already deleted it; commit
    50912d0 (2022-03-31) intended full removal but missed the
    namespace-scope definition.

- N41 (24-test-infrastructure-mirrors.md):
  - V5 verified each fixture body. 28 declaring fixture classes
    (E6's "22" was an undercount). 19 fit cleanly with subdir-only
    ctor; 27 of 28 fit with (subdir, suffix) ctor pair. One structural
    hazard: CaDerivationAdvancedAttrsTest reassigns unitTestData in
    SetUp() and is linked to DerivationAdvancedAttrsTest via
    TYPED_TEST_SUITE — needs common abstract base.

New candidate NixOS#218 (12-libutil-libstore-core-extras.md):
  - The Hash::dummy / StorePath::dummy sentinels are overloaded as
    both "uninitialised placeholder" and "wire-marker for missing".
    Independent grep identified 16 sites in three classes:
    placeholder-then-overwrite (6, including two FIXME-tagged sites
    in nar-info.cc), wire-marker (3 in worker-protocol.cc,
    serve-protocol.cc, legacy-ssh-store.cc), and test-fixture (3 +
    one legitimate constant). The right factoring is std::optional<Hash>
    / std::optional<StorePath> for the placeholder sites and a
    separately-named sentinel for the wire-marker sites.

Resumption documentation:

- INVENTORY.md was missing pointers to STATUS.md, AGENT-CHARTER.md,
  and review/00-INDEX.md. Added a paragraph after the "Consolidated
  duplication and refactoring candidates" section documenting all
  three plus the five-step read-first ordering for resumption.
- INVENTORY.md updated: 217 per-shard candidates -> 218 (with NixOS#218
  added during integration).

- STATUS.md cleaned up: dropped the 13 stale "Integration"
  sub-bullets (those tasks are now in candidate bodies), collapsed
  the duplicate "E1 implementation" entries, fixed the vague
  "completed in commit ahead of HEAD~0" line, added "E3
  implementation" and "E5 verifiable-counts manifest" to the queue.
  "Recently completed" annotated to note the post-integration count
  is 218 + 44.

- review/00-INDEX.md updated with an integration-status note above
  the "How a new agent should pick a report to read" section.

Self-check against AGENT-CHARTER.md eight rules:
1. Call graphs walked: V3's UAF chain through ~ProgressBar /
   ~InterruptCallbackImpl was already in V3's report; B1's
   addSetting(this) analysis already in B1's report.
2. Shipping artefacts traced: V1's install_headers finding cited in
   NixOS#134 and NixOS#138 bodies.
3. Counts cited their source: re-derived for the dummy pattern
   (16 sites) and CloneableError derivations (17); took V-counts
   where verified (V2's 71/281, V5's 28/19/27/1).
4. Predictions labelled: N41's V5-verified replaces E6's prediction.
5. Inherited claims re-derived: B3 said 22 hand-written
   CloneableError; my grep produced 17; used 17.
6. Same-shape walked individually: the dummy pattern split into 3
   classes (placeholder vs wire-marker vs test) rather than C1's
   single shape.
7. No invented numbers: V4's downgrade applied to NixOS#213.
8. Comments verified vs code: NixOS#213's "not a singleton" comment
   treated as hypothesis the consumers contradict.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants