Skip to content

Add AI job A to propose rules from decision sources - #69

Merged
Viraj5503 merged 2 commits into
mainfrom
aryan-7-propose-rules
Nov 29, 2026
Merged

Viraj5503 merged 2 commits into
mainfrom
aryan-7-propose-rules

Conversation

@WiseyXD

@WiseyXD WiseyXD commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Closes #7

What this adds

codexray decisions propose --repo <id> finds the project's own decision sources at END, asks job A for one rule per source, checks every answer in code, runs each checkable rule against the map, and writes the proposals for a person to review.

  • decisions/sources.py finds sources by the globs in settings/judge.yaml (job_a.sources): architecture tests, import-ban blocks in build and lint files, static-analysis rules, decision documents, guidelines and rules files for agents.
    • A block such as <RestrictImports> runs from its first line to the next line indented no deeper.
    • A file over 200 lines is cut at section breaks.
    • A file below its group's min_lines is skipped and listed with the reason.
  • decisions/propose.py holds the job A prompt and schema.
    • The system text carries the map's module ids, folder roles and example paths. It is sent for prompt caching, and its hash is part of the prompt version, so a changed map gets new cache keys.
    • Code checks run on every answer: the shape has its arguments, every selector matches files in the map, every door is a real folder role, line numbers lie inside the source, and the statement is one sentence.
    • A failing answer is sent back once with the problems.
  • Dry run: every checkable proposal goes through analyze.checks.check_decision at END. proposals.json shows how many links it applies to, its exceptions, and the first five exception links.
  • rules/artemis.yaml, rules/graylog.yaml, rules/shopware.yaml: reviewed by hand, as described below.

The stage writes these to the run folder:

  • proposals.yaml: the rules-file format, with reviewed: false.
  • proposals.json.
  • judgements/cache/ and judgements/calls_a.json.
  • The job A calls, added to usage.json.

Change from the issue: proposals go to proposals.yaml, not decisions.yaml. codexray analyze already writes decisions.yaml (the decisions it used) and would overwrite them.

There are no new test files, per team rule 3. The decisions propose line is removed from STUBS.

What I ran and saw

These ran live against the gateway, at the pinned END commits:

Repo Sources Checkable Written, not checkable Not about structure Calls Cost Time
Graylog 6 2 1 3 6 $0.19 9 s
Artemis 58 11 24 23 59 $1.14 46 s
Shopware 390 10 58 322 393 $4.81 3 min 16 s
  • Four answers failed the checks the first time and passed on the retry. None failed twice, and every call was answered.
  • usage.json lists every job A call: 6, 59 and 393 entries.
  • Prompt caching works:
    • The first source goes alone, then six run side by side.
    • Shopware read 2.6M tokens and Artemis 225k from the prompt cache.
    • The first Graylog run, with all six sent at once, read none.
  • A second run without LLM_API_KEY made 0 gateway calls, and proposals.yaml, proposals.json and usage.json came out byte-identical. I checked this on all three repos.
  • The key appears in no file under runs/, src/ or rules/.
  • I also ran the stage with a fake gateway on a copy of the Graylog run:
    • An answer whose selector matches no file was sent back, and the second answer was kept.
    • With the gateway down, all six sources were listed "without an answer" and nothing was added to usage.json.
  • codexray analyze then uses only the reviewed rules:
    • Graylog: analyze: 3 decisions (2 reviewed from rules/graylog.yaml)
    • Artemis: analyze: 49 decisions (33 reviewed from rules/artemis.yaml)
    • Shopware: analyze: 66 decisions (65 reviewed from rules/shopware.yaml)
    • At END, the counts in decision_checks match the dry runs below for every reviewed rule.
    • Statuses at END:
      • 16 rules are holding or spreading;
      • shopware/core-never-imports-app-module is slipping, at 93%.
  • make check passes.

Review of the proposals

Graylog (2 reviewed)

  • graylog/datanode-packages-private: forbid !M:data-node → path:*/org/graylog/datanode/*, from pom.xml lines 1243–1252.
    • At END: 37,447 links and 0 exceptions.
  • graylog/no-permissions-mixin-import, from the web lint config lines 225–228.
    • The two files that carry the project's own eslint-disable-next-line no-restricted-imports are its allowed exceptions.
    • One exception remains: hooks/useHasEntityOwnership.ts line 19, with no disable comment.
  • Dropped: the data-node/pom.xml allowance. It is the other half of the ban and is already expressed by !M:data-node.

Artemis (33 reviewed: 9 checkable, 24 written)

  • artemis/module-access-via-api-domain-dto: only_via with doors api, domain and dto, from AbstractModuleAccessArchitectureTest.java lines 30–61.
    • The model's target was every server module, which gave 44% conformance.
    • The test only covers the 12 modules that subclass it. I narrowed target to those 12 and added their own getIgnoredClasses() lists (19 classes, with their lines) as allowed exceptions.
    • At END: 1,016 links and 1 exception. ExerciseRepository.java imports ExamResource only for a {@link} in a doc comment. The project's test reads compiled classes and cannot see that; our map can.
  • 8 more checkable rules have 0 exceptions at END:
    • two that keep aiworker isolated;
    • hyperion protocol not depending on runtime;
    • notification services not using the User entity;
    • the passkey service being centralised;
    • three client layering bans from eslint.config.mjs.
  • Kept unreviewed: artemis/repositories-not-access-services.
    • The test checks annotations: an @Repository must not access an @Service.
    • With folder roles it flags 11 links to DTOs, interfaces and exceptions that sit in service folders, so it would report things the project's test does not.
  • Dropped: artemis/tum-aet-ui-no-app-imports (from AGENTS.md), the same rule as the enforced lint block.
  • 163 one-module subclasses of the shared tests were skipped as under 30 non-blank lines. They only name the module a shared test covers.

Shopware (65 reviewed: 8 checkable, 57 written)

  • shopware/core-not-depend-on-bundles, from RestrictNamespacesRule.php lines 37–49.
    • The project's own nine @phpstan-ignore phpat.restrictNamespacesInCore lines are its allowed exceptions.
    • At END: 40,764 links and 10 exceptions. Most are PHP configuration files (DependencyInjection/*.php, tagged-service-contracts.php) that phpat does not check as classes.
  • The same file states three more rules, but the model gives one rule per source. I added them by hand (proposed_by: hand) for the Administration, Elasticsearch and Storefront bundles; each has 0 exceptions.
  • From decision documents:
    • storefront controllers use no repository directly (1 exception, RegisterController.php);
    • storefront code stops using the iterator helper (0 exceptions).
  • From the Administration lint config and AGENTS.md:
    • no imports from src/meta (0 exceptions);
    • Administration core never imports app or module code (28 exceptions).
  • Kept unreviewed:
    • The document v1/v2 rule. It is a feature-flag runtime principle, and the ADR itself moves shared classes into DocumentV2, so its 84 links are by design.
    • The media path rule. The ADR says URL generation can work without the DAL, not that it must not reference it.
    • The two documents in adr/_superseded/.
  • Changed to "written, not checkable": Administration modules do not import each other. These modules are folders below one map module, so none of the four shapes expresses the rule at this grain.
  • Dropped two duplicates:
    • the AGENTS.md copy of the rule above;
    • the Storefront/Mcp/AGENTS.md line that repeats the Core → Storefront ban.

The written-but-not-checkable rules were skimmed against their sources, not checked line by line. They never produce a finding; the report lists them.

Spec §15 question 5

Shopware has 190 decision documents:

  • 23 are about which code may use which code, and 2 of those are superseded.
  • 4 gave a rule in one of the four shapes, and 2 of those passed review.
  • The other 19 state structural rules that depend on runtime behaviour, annotations or naming.

Merging with #67

#67 adds jobs B and C.

  • judge.yaml merges cleanly; the effort line for A and B is the same change in both PRs.
  • tests/test_cli.py conflicts because both PRs remove neighbouring STUBS lines. Keep both removals.

@Viraj5503
Viraj5503 merged commit f83658e into main Nov 29, 2026
2 checks passed
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.

AI job A: propose rules from written decision sources (codexray decisions propose)

2 participants