Skip to content

refactor: remove the second copy of four rules - #12

Merged
jerryshell merged 1 commit into
mainfrom
refactor/dedupe
Nov 4, 2026
Merged

jerryshell merged 1 commit into
mainfrom
refactor/dedupe

Conversation

@jerryshell

@jerryshell jerryshell commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Why

The last weeks added four rules in two places each, plus two build-stamp readers that disagreed. A rule with two homes is a rule that lands in one of them.

What changed

Engine (modules/gai_agent):

  • _access_name wrapped the free gai_access_name, while the same file already called the free function. Removed.
  • audit_path was assigned at startup and never read. Removed.
  • lock.release and lock.renew repeated the params check, the lock lookup, and the owner rule. One _lock_for(params, error) now owns that rule.
  • _forbidden returned a dictionary holding a single string, unwrapped by the caller. It returns the string.

Game (game/tests/gai_test_case.gd): the stub key "" if args == null else var_to_str(args) was written in four places and the "create the slot" shape in three. _args_key and _slot do it once.

CLI (bin/gai): build_is_stale read the stamp and then re-read it through stamp_is_current, and --check carried a half-applied special case for a missing stamp. One stamp_state answers current, stale, or absent, and the special case is gone.

Verification

  • The module compiles three ways: editor, target=template_release object, and Windows/MinGW object (8.1 s).
  • 17 game tests pass, including the stub, sequence, scoped-stub, and inherited-method cases that exercise the consolidated key.
  • test_agent 19, test_build 16, test_next 18, test_check 14 pass; bin/gai check green; bin/gai build --check up to date.
  • pre-commit passes over every touched file.
  • Net 45 lines added, 43 removed.

Each of these was a place where one rule lived twice, so a change could land in
one copy only.

- `_access_name` wrapped `gai_access_name` and the file already called the free
  function elsewhere. Gone; every caller uses the free function.
- `audit_path` was written at startup and never read. Gone.
- `lock.release` and `lock.renew` each repeated the params check, the lookup, and
  the owner rule. One `_lock_for` returns the lock or the error, so the owner rule
  has one home.
- `_forbidden` built a dictionary holding one string, which the caller unwrapped
  with `Dictionary(...)["$gai_forbidden"]`. It returns the string.

On the game side, the stub harness built its argument key in four places and its
slot in three; `_args_key` and `_slot` do it once. In `bin/gai`,
`build_is_stale` read the stamp and then re-read it through `stamp_is_current`,
and `--check` had a half-applied special case for a missing stamp; one
`stamp_state` answers `current`, `stale`, or `absent`.

Net: 45 lines added, 43 removed, and four rules with one home each.

Verified: the module compiles for editor, template, and Windows/MinGW; 17 game
tests, the agent suite, and the build, next, and check suites pass; pre-commit
passes.
@jerryshell
jerryshell merged commit a527e35 into main Nov 4, 2026
24 checks passed
@jerryshell
jerryshell deleted the refactor/dedupe branch November 4, 2026 10:47
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.

1 participant