Skip to content

Add SmallGroupsAddLayer - #74

Open
fingolfin wants to merge 3 commits into
masterfrom
add-layer
Open

Add SmallGroupsAddLayer#74
fingolfin wants to merge 3 commits into
masterfrom
add-layer

Conversation

@fingolfin

@fingolfin fingolfin commented Aug 16, 2026

Copy link
Copy Markdown
Member

Closes #67.

Extending the library means allocating two numbers and filling six global arrays. SOTGrps spends 70 lines on it, sglppow the same. This is very brittle, e.g. nothing checks that two packages pick different slots, and load order decides which of two overlapping layers wins.

With this PR, adding a new layer can be done with a simple function call:

SmallGroupsAddLayer( rec(
    name        := "SOTGrps",
    available   := order -> fail-or-record,
    group       := function( order, i, inforec ) ... end,
    id          := ...,          # optional; without it IdGroup stays unavailable
    number      := ...,          # optional; only where `available` omits it
    information := ...,          # optional
    select      := ..., count := ...,   # optional; the generic ones by default
    before := [ ], after := [ "sglppow" ] ) );

name is what other layers refer to a layer by. before and after name the layers this one wants consulted before or after; a name that is not registered is ignored, so wishing about a package that is not loaded does no harm, and wishes that cannot all be met are refused before anything is written. The registered layers are collected in SMALL_GROUPS_LAYERS.

Compatibility

The old route is untouched, so released sglppow and SOTGrps keep working. But new versions of those will make use of this new function, see gap-packages/sotgrps#58 and gap-packages/sglppow#13

For the time being, The eleven layers of this package keep their numbers and are not registered by name. This may or may not change in the future.

Care was taken to test various combinations of old versus new for sglppow/sotgrps/smallgrp, and everything worked fine.

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.07407% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.88%. Comparing base (ed2f323) to head (ac19b7b).

Files with missing lines Patch % Lines
gap/addlayer.gi 98.78% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
- Coverage   99.88%   99.88%   -0.01%     
==========================================
  Files         509      510       +1     
  Lines      373210   373386     +176     
==========================================
+ Hits       372793   372966     +173     
- Misses        417      420       +3     
Files with missing lines Coverage Δ
gap/small.gd 100.00% <100.00%> (ø)
gap/small.gi 98.00% <100.00%> (-0.15%) ⬇️
gap/smlinfo.gi 99.05% <100.00%> (+0.01%) ⬆️
gap/addlayer.gi 98.78% <98.78%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Extending the library meant allocating two numbers and filling six global
arrays; SOTGrps spends 70 lines on it, sglppow the same. Nothing checked
that two packages picked different slots, and load order decided which of
two overlapping layers won.

A layer is now one record. It carries a name, which is what other layers
refer to it by: `before` and `after` name the layers this one wants to be
consulted before or after, and a name that is not registered is ignored, so
wishing about a package that is not loaded does no harm. Neither number is
the layer's business any more -- `available` is wrapped so that `lib` and
`func` are filled in on the way out, which is also what lets a later
registration reorder earlier ones.

Registered layers take consecutive slots behind every layer added the old
way, so registering one never moves another across a slot this code did not
hand out, and released sglppow and SOTGrps keep working unchanged.

Ported SOTGrps' Integration.gi as a check: 70 lines to 20, and its own test
suite passes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fingolfin and others added 2 commits August 16, 2026 16:26
The layers of this package become one layer named "SmallGrp", whose methods
read the global arrays a layer used to be installed in -- and so also cover
those still added that way from outside. Every other layer is a record of
the same shape appended after it, and SMALL_AVAILABLE hands the layer that
answered back in the inforec, so the high-level functions call its methods
directly.

What this deletes: the slot arithmetic over eight arrays, the layer and func
numbers a registered layer carried, and all of the placement code -- the
relocation rule and its hazard go with it, since a layer added the old way
is now inside "SmallGrp" rather than between two registered ones.

Two components the record gained, because the compat layer cannot be
expressed without them: 'idAvailable', since the identification covers other
orders than the construction and under other func numbers (id2 stops at
1000, id3 uses func 13, which SMALL_GROUP_FUNCS does not even have), and
'properties', the indexing hook, which registered layers previously had no
way to supply.

Naming a layer in 'before' now includes "SmallGrp", so a layer may put
itself in front of this library.

Nothing under small*/ or id*/ is touched: those read inforec.func and
inforec.lib, and "SmallGrp" hands their own inforec straight back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Add a sane and clear extension API

1 participant