Skip to content

import has no stated contract: dockerfile counts FROM scratch, embedded_python's cell is the classifier's own discriminator, and apex/scala/shell/livecode count references, blocks and path arguments #2875

Closed

Description

@squid-protocol

Roadmap Phase 3 (docs/contract_roadmap.md, epic #2812), next by the mechanical audit after safety (#2869): the import row is draft and carries 2 of the report's 17 open-defect cells (dockerfile 4 vs median 3, embedded_python 7 vs 3; both extraction in the cause table — and both claimed only by batch4-dual-keyword-overlaps' signal×language cross-product, the #2856 shape).

_c("import", "architecture", "declaration", "Dependency resolution and module loading", planted=True)

Consumers: the statistical_auditor extraction-density group (SIGNAL_KEYS), two per-language fidelity coefficients (fidelity_table.py: dockerfile import: 0.75 and embedded_python import: 0.4286 — exactly 3/4 and 3/7, i.e. the table is currently pricing these two cells), the "Dependency Resolution" display row. The dependency graph itself (popularity, pagerank, blast radius, orphan→api conversion) is built by the sibling _dependency_capture, not by this count — which is what makes the count's unit a free choice this contract has to make.

The two open cells (finditer verdicts against corpus main)

  • dockerfile = 4 (main 1 + a 1 + b 1 + c 1) — c.dockerfile's FROM scratch. scratch is Docker's reserved empty base: no image is pulled, no layer is bound, _dependency_capture records an edge to a unit that cannot exist. Every other language's leaf file reads 0; the leaf FROM opens a build stage (class_start's unit, a deliberate dual kept by func_start & class_start have no stated contract: 5 open cells are all collective-entry cross-product mis-marks, not rule defects #2856) but declares no dependency. The rule counts it because it counts the FROM keyword, not the binding.
  • embedded_python = 7 (main 2 + a 2 + b 2 + c 1) — the chain (3) plus one import machine per file. That line is not a plant: embedded_python.py's detection regex is ^[ \t]*(?:import|from)\s+(?:machine|board|…)\b, so a file classifies as embedded_python only by carrying an import of a hardware module (ledger embedded-python-per-file-classification: machine.idle() alone did not discriminate). The language's floor is therefore 4 > 3 by construction — an inherency of the classifier, not an extraction defect, and no rule edit can move it without changing what the language is. The cell needs its own ledger entry (intended-morphology) instead of batch4's cross-product.

Also visible from main with no red cell (rule_probe, crucible)

  • apex 22/4f: acct.Id, LoggingLevel.INFO, Account.Name — the second alternation counts any receiver.Member reference. Apex has no import statement; Type.forName( is its only load form. apex import rule: re.IGNORECASE neutralises the [A-Z] guard, so every qualified reference (foo.bar) counts as an import #2671 scoped the guard; the contract removes the reference arm (C2).
  • scala 16/7f: [\w.{}\s,]+ swallows newlines, so a block of eight import lines and the def after them is one hit (the samples show it) — the opposite failure of one-statement-one-hit.
  • shell 103/256f: the . arm fires on any lone dot followed by a word — find -s . -mindepth, --init-path . unsupported_…, --playbook-dir . testns — a path argument, not a source command (C3 anchor: command position).
  • livecode 83/98f: 35 of the hits are end module (a block closer), case "module" (a string), and module com.livecode.array (the file's own module declaration); the LCB import form use com.livecode.foreign is not counted at all.
  • fortran 309/6f: bare \b(USE|INCLUDE|IMPORT)\b counts use ysu (option1) inside a string literal, and IMPORT — host association inside an interface body, nothing external is bound.
  • abap 7/7f: bare INCLUDE counts the word inside a template string (|… ENHO include should not be in TADIR …|).
  • m4 2/7f: include/Makefile \ — a path whose first component is a directory named include; the m4 form is include(.
  • agc_assembly 104/10f: bare BANK (no operand, 26×), BANK 31 (a numeric bank switch), TCF SETLOC (a label named SETLOC as an operand) — the capture's own reading is a symbolic operand in opcode position.
  • csharp: the alias directive using Alias = Target.Namespace; binds a unit and is captured for the graph but not counted.

What the contract must state

  1. One hit is a statement or directive that binds an external unit — a module, package, header, library, file, stage or base image — into the current unit, in the language's dependency form. A re-export counts (it binds the unit to re-publish it); a dynamic loader call counts where it is the language's load form (require(, import(, __import__(, Type.forName(, dofile(, load_extension().
  2. The unit is the statement, not the edge (the go/scala shape): import (…), use a::{b, c};, import a, b, with a, b; are one hit each; the graph's edges are _dependency_capture's. One statement per line is one hit per line — a regex must not span statements.
  3. A binding, not a reference or a self-declaration (the apex/livecode shape): a qualified name, a call through an imported symbol, a type annotation, the file's own module/package/library header, and host association (IMPORT) are invisible.
  4. A named unit (the dockerfile/agc shape): a reserved no-op (FROM scratch), a bare or numeric location directive, binds nothing.
  5. The ambiguity anchor: include, use, import, module, . fire only in statement/command position — not as a string word, a path component, a block closer or an argument.
  6. One owner, with the stated duals kept: dockerfile FROM (class_start, func_start & class_start have no stated contract: 5 open cells are all collective-entry cross-product mis-marks, not rule defects #2856), html <link href> (io's attribute reading, manifest-recorded), sqlite .read/.import (import's since io C2 io has no stated contract: javascript counts an identifier named path, sqlite counts every DML keyword, and tcl's source/close are claimed by two rules each #2841); markdown is the stated absence.

Done in the #2765/#2841/#2852/#2858/#2869 shape

docs/import_rule_contract.md, the sheet row → stated, one cross-language test_import_contract_<N>.py, engine PR labelled rosetta:rebless-owed, corpus PR with dockerfile c re-blessed 1 → 0 and a new intended-morphology entry for embedded_python's classifier floor, batch4's import half retired. Expected: import open defects 2 → 0 (dockerfile 3, embedded_python 7 ledgered inherency), no other corpus cell moves; bless scope names only the raw import count and the aggregates that read it (the graph must not move — _dependency_capture edits are limited to the same scratch/numeric exclusions).

Activity

  1. added
    metrics
    core-engine
    on Sep 8, 2026
  2. added a commit that references this issue on Sep 8, 2026
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

    core-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions