Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/decisions/0063-complete-bounded-ci-test-shards.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,18 @@ exception. The Decision and metadata remain historical. The
[Phase 03 record](../roadmap/phase-03-delivery-log.md#p03-4-step-7-forty-five-minute-execution-windows-and-parser-timeout-2026-11-06)
owns the dependent implementation and fresh source-bound qualification.

### Amendment 4 — Larger filter and argument bounds (2026-11-21)

Accepted [ADR-0105](0105-ci-selector-filter-and-argument-bounds.md) raises this
record's initial bounds, a 32 KiB filter argument and 64 KiB for all argument
strings of one invocation, to 64 KiB and 128 KiB. An oversize filter or vector is
still refused before spawning and never split or run unfiltered. Counts, the
assignment algorithm, the B salt, weights, whole-job ceilings and complete
two-layout qualification are unchanged, and the larger filters qualify with a
complete A and B on the same source. The Decision and metadata remain historical.
The [acceptance record](../roadmap/phase-03-delivery-log.md#adr-0105-acceptance-and-implementation-2026-11-21)
owns the measurements, implementation and qualification receipts.

## References

- [ADR-0062](0062-native-crash-proof-ci-provisioning.md).
Expand Down
110 changes: 110 additions & 0 deletions docs/decisions/0105-ci-selector-filter-and-argument-bounds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# ADR-0105: CI Selector Filter And Argument Bounds

## Status

Accepted

**Date:** 2026-11-21
**Deciders:** @cemil
**Bounded supersession:** the 32 KiB filter-argument and 64 KiB argument-vector
bounds that [ADR-0063](0063-complete-bounded-ci-test-shards.md) records as its
initial bounds. A dated Amendment in ADR-0063 discloses this change; its
historical body, status and date remain intact.

Maintainer acceptance changes only the two argument bounds. Counts, the
assignment algorithm, the B salt, weights, whole-job ceilings and the complete
two-layout qualification stay fixed. Executable change and the hosted
qualification of both layouts are separate gates; the
[acceptance record](../roadmap/phase-03-delivery-log.md#adr-0105-acceptance-and-implementation-2026-11-21)
owns them.

## Decision Drivers

- The first hosted layout-B run of the P03-9 source refuses `backend-ordinary-11`
with `filter_bound` before any test runs: its selector filter is 33,367 bytes
against the 32,768-byte ceiling, and `ordinary-7` is at 31,989. The result is
deterministic from the manifest and the plan, so no rerun can pass.
- Layout A holds the same population in 27,144 to 28,123 bytes: the average
ordinary shard already fills about 84 % of the ceiling. There are 2,052
distinct ordinary selectors in twelve shards, the Accepted upper count, so
growth is absorbed by longer filters, not by another shard.
- A salt cannot repair this. Over 200 candidate B salts on the current
population the largest filter has a median of 33,070 bytes; 86 of 200 fit and
none stays under 90 %. Every added selector reshuffles a hash-ordered
assignment, so a salt chosen for today's population is a fresh draw tomorrow.
- ADR-0063 calls these bounds LearnStack ceilings, not claimed platform maxima,
whose hosted behaviour must qualify. A filter is one argument; Linux allows
a single argument of 128 KiB.
- Whatever changes must keep exact case-identity reconciliation: refuse an
oversize filter before spawning and never split or run unfiltered.

## Considered Options

1. **Raise the filter to 64 KiB and the argument vector to 128 KiB** (chosen).
Doubles both ceilings. The median layout-B filter falls to about half of the
new bound, and nothing else in the plan moves.
2. **Make the assignment byte-aware** (valid, not selected). Bin choice would
also balance filter bytes, which brings layout B down to layout A's roughly
84 %. It is a new algorithm version with new code and tests, and it leaves
about 16 % of growth before the same refusal.
3. **Choose another B salt** (rejected). Measured above: at best a one-time
fit that the next added selector undoes.
4. **Add a thirteenth ordinary shard** (rejected). It exceeds the Accepted count
range, costs another VM and reopens the count envelope for a byte ceiling.
5. **Split a filter across invocations or run unfiltered** (rejected).
ADR-0063 forbids both; the exact filter-to-case-ID equality needs one
filter per owner.

## Decision

LearnStack bounds a generated selector filter argument to 64 KiB of UTF-8
(65,536 bytes) and all argument strings of one invocation, separators
included, to 128 KiB (131,072 bytes). The committed plan carries both in
`bounds` and the plan validator pins exactly these values. An oversize filter
or vector is still refused before spawning, as `filter_bound` or `argv_bound`;
it is never split and the run is never unfiltered. Everything else in
ADR-0063 stays in force.

The bounds remain LearnStack ceilings, not claimed platform maxima. Their
hosted behaviour qualifies with a complete layout A and a complete layout B on
the same final source after the change. The refused layout-B run supplies the
first filters above 32 KiB, and independent rediscovery of each filter before
execution continues to prove that no argument was truncated or altered.

## Consequences

### Positive

- Layout B stops refusing on this population, and both layouts gain roughly
twice the room for selector growth with no new shard, VM or algorithm.
- The bounds stay finite, validated and refused before spawning.

### Negative

- A filter of up to 64 KiB passes through `dotnet test` and the vendor test
host on hosted runners. If a tool in that chain refuses or alters it, the
failure is detected by rediscovery and shows as a failed attempt, not as a
silent partial run; qualification is what proves the larger size.
- The room is finite. Roughly doubled population reopens this question, and the
byte-aware assignment remains the next candidate.

### Neutral

- Counts, salt, algorithm, weights and every job ceiling are unchanged.

## Implementation Notes

- The plan, its validator and the shard tests change together; ADR-0063 gains a
dated Amendment 4 pointing here.
- The Phase 03 delivery log owns the measurements, the implementation record
and the hosted qualification receipts.

## References

- [ADR-0063](0063-complete-bounded-ci-test-shards.md): the bounds this record
replaces and the rules it keeps.
- [ADR-0075](0075-ordinary-ci-job-window.md) and
[ADR-0082](0082-current-source-ci-execution-windows.md): the precedent for
changing an ADR-0063 ceiling by a bounded decision and a dated Amendment.
- [Standards 06](../standards/06-testing.md): the complete bounded CI
assignments rule.
1 change: 1 addition & 0 deletions docs/decisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ records hosted qualification. Phase 11 owns production qualification.
| 0102 | [Production Tenant Onboarding](0102-production-tenant-onboarding.md) | Accepted 2026-11-19: operator-admitted tenant, host, Role-template, first-administrator and recovery commands on the app role, with a confined operator source and target announcement; the seed stays seed-only. |
| 0103 | [Operator Recovery of Asynchronous Work](0103-operator-recovery-of-asynchronous-work.md) | Accepted 2026-11-19: metadata inspection on column grants, fenced targeted subscriber replay and a narrow producer reset on a confined outbox-role owner; no job release and no dashboard. |
| 0104 | [Controlled Issuer Rebind](0104-controlled-issuer-rebind.md) | Accepted 2026-11-19: an offline operator act through a dedicated rebind role, with advisory-lock freeze, a continuity proof over every stored subject key, intent and result audit rows. |
| 0105 | [CI Selector Filter And Argument Bounds](0105-ci-selector-filter-and-argument-bounds.md) | Accepted 2026-11-21: raises ADR-0063's 32 KiB filter and 64 KiB argument bounds to 64 KiB and 128 KiB after layout B refused a 33,367-byte filter; counts, salt and algorithm unchanged. |

## Proposed ADRs

Expand Down
27 changes: 26 additions & 1 deletion docs/roadmap/phase-03-delivery-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ not acceptance of implementation choices. Navigate by the generated index below.
- [P03-8 OpenAPI transition implementation and reviews (2026-11-18)](#p03-8-openapi-transition-implementation-and-reviews-2026-11-18) — 54 lines
- [P03-8 PR review disposition (2026-11-18)](#p03-8-pr-review-disposition-2026-11-18) — 101 lines
- [P03-8 merge and delivery closeout (2026-11-19)](#p03-8-merge-and-delivery-closeout-2026-11-19) — 73 lines
- [P03-9 — Platform authority and operational recovery](#p03-9--platform-authority-and-operational-recovery) — 1,291 lines
- [P03-9 — Platform authority and operational recovery](#p03-9--platform-authority-and-operational-recovery) — 1,315 lines
- [P03-9 proposed platform authority and recovery package (2026-11-19)](#p03-9-proposed-platform-authority-and-recovery-package-2026-11-19) — 136 lines
- [P03-9 package review dispositions and acceptance (2026-11-19)](#p03-9-package-review-dispositions-and-acceptance-2026-11-19) — 126 lines
- [P03-9 Step 1 — operator authority and killswitch (2026-11-19)](#p03-9-step-1--operator-authority-and-killswitch-2026-11-19) — 108 lines
Expand All @@ -531,6 +531,7 @@ not acceptance of implementation choices. Navigate by the generated index below.
- [P03-9 Step 5 — hosted CI correction, third run (2026-11-21)](#p03-9-step-5--hosted-ci-correction-third-run-2026-11-21) — 24 lines
- [P03-9 Step 5 — hosted CI, the opposite shard layout (2026-11-21)](#p03-9-step-5--hosted-ci-the-opposite-shard-layout-2026-11-21) — 30 lines
- [P03-9 Step 5 — a local guard for unserializable theory data (2026-11-21)](#p03-9-step-5--a-local-guard-for-unserializable-theory-data-2026-11-21) — 16 lines
- [ADR-0105 acceptance and implementation (2026-11-21)](#adr-0105-acceptance-and-implementation-2026-11-21) — 24 lines

<!-- END GENERATED INDEX -->

Expand Down Expand Up @@ -25479,3 +25480,27 @@ This replaces the reflection rule the question proposed. An analyzer knows what
serialize, shows the fault in the editor and needs no catalogue entry, and the architecture
catalogue and its counts are unchanged. Standards 06 states the rule beside the
discovery protocol it protects.

### ADR-0105 acceptance and implementation (2026-11-21)

The maintainer accepted [ADR-0105](../decisions/0105-ci-selector-filter-and-argument-bounds.md)
after the measurements below, choosing a higher bound over a new B salt and over a
byte-aware assignment. The salt was first proposed as the cheap route and measurement
overturned it: over 200 candidate B salts on the current population the largest filter has
a median of 33,070 bytes against the 32,768-byte ceiling, 86 of 200 fit, none stays under
90 % and the best reaches 91.8 %. The assignment is hash-ordered, so each added selector
reshuffles it and a salt fitted to today's population is a fresh draw tomorrow.

The change is the two bounds and nothing else: the committed plan carries a 65,536-byte
filter and a 131,072-byte argument vector, the plan validator pins those values, and the
four boundary controls of the shard tests move to them. The refusal-at-the-boundary
controls still pass at the new boundaries, the aggregate and result tests are unchanged,
and ADR-0063 gains Amendment 4. Counts, salt, algorithm, weights and every job ceiling are
untouched.

Run against the layout-B-refused population with the new plan, every layout-A filter is
accepted with the largest at 28,123 bytes and every layout-B filter is accepted with the
largest at 33,367 bytes, 43 % and 51 % of the new bound, and the two layouts remain
distinct. The 88 shard tests and 42 result tests pass. What local runs cannot show is how
the hosted test chain handles a filter above 32 KiB: that is the qualification this record
leaves open until a complete layout A and a complete layout B pass on the same source.
4 changes: 2 additions & 2 deletions scripts/ci-test-shards-plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"learnstack.tests.architecture"
],
"bounds": {
"argvBytes": 65536,
"filterBytes": 32768
"argvBytes": 131072,
"filterBytes": 65536
},
"counts": {
"architecture": 6,
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci-test-shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def validate_plan(plan):
'architecture_project_invalid')
require(plan['salt'] == 'LearnStack.CI.B.v1' and integer(plan['defaultMethodMs'], 1, 86400000),
'plan_estimate_invalid')
require(plan['bounds'] == {'filterBytes': 32768, 'argvBytes': 65536}
require(plan['bounds'] == {'filterBytes': 65536, 'argvBytes': 131072}
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
and all(type(x) is int for x in plan['bounds'].values()), 'plan_bounds_invalid')
sources = plan['sources']
require(isinstance(sources, dict) and 0 < len(sources) <= 100, 'weight_sources_invalid')
Expand Down
16 changes: 8 additions & 8 deletions scripts/test-ci-test-shards.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,23 @@ def test_filter_has_whole_method_clauses_and_selection_requires_actual_ids(self)
foreign = copy.deepcopy(cases); foreign[0]['id'] = self.manifest()['native'][0]['id']
self.refuses('selected_population_mismatch', OWNER.selected_equal, cases, foreign)
OWNER.validate_argv(['dotnet', '--filter', expression], self.plan)
self.refuses('argv_bound', OWNER.validate_argv, ['dotnet', 'x' * 65536], self.plan)
self.refuses('argv_bound', OWNER.validate_argv, ['dotnet', 'x' * 131072], self.plan)
self.refuses('argv_bound', OWNER.validate_argv, ['dotnet', '\0'], self.plan)

def test_filter_and_argv_accept_the_boundary_and_refuse_one_more_byte(self):
cases = [self.case('tests', 'Class.' + 'M' * 1900 + str(i), i) for i in range(16)]
cases = [self.case('tests', 'Class.' + 'M' * 1900 + str(i), i) for i in range(33)]
cases.append(self.case('tests', 'Class.Boundary', 99))
expression = OWNER.filter_for('ordinary-0', 'tests', cases, self.plan)
cases[-1]['method'] += 'x' * (32768 - len(expression.encode()))
self.assertEqual(32768, len(OWNER.filter_for('ordinary-0', 'tests', cases, self.plan).encode()))
cases[-1]['method'] += 'x' * (65536 - len(expression.encode()))
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Resolved
self.assertEqual(65536, len(OWNER.filter_for('ordinary-0', 'tests', cases, self.plan).encode()))
cases[-1]['method'] += 'x'
self.refuses('filter_bound', OWNER.filter_for, 'ordinary-0', 'tests', cases, self.plan)
OWNER.validate_argv(['dotnet', 'x' * (65536 - len('dotnet') - 2)], self.plan)
OWNER.validate_argv(['dotnet', 'x' * (131072 - len('dotnet') - 2)], self.plan)
self.refuses('argv_bound', OWNER.validate_argv,
['dotnet', 'x' * (65536 - len('dotnet') - 1)], self.plan)
['dotnet', 'x' * (131072 - len('dotnet') - 1)], self.plan)

def test_oversize_filter_refuses_instead_of_splitting_rows(self):
cases = [self.case('tests', 'Class.' + 'M' * 1000 + str(i), i) for i in range(40)]
cases = [self.case('tests', 'Class.' + 'M' * 1000 + str(i), i) for i in range(70)]
self.refuses('filter_bound', OWNER.filter_for, 'ordinary-0', 'tests', cases, self.plan)

def test_complete_aggregate_refuses_missing_extra_and_wrong_owner_despite_equal_union(self):
Expand Down Expand Up @@ -716,7 +716,7 @@ def execute(_argv, _deadline, _work, _consume, progress):
def test_all_shard_dotnet_arguments_are_bounded_before_spawn(self):
with mock.patch.object(LAUNCHER, 'dotnet', return_value=0) as spawn:
with self.assertRaises(LAUNCHER.Refusal) as caught:
LAUNCHER.shard_dotnet(['x' * 65536], time.monotonic() + 5, '/owned', lambda _: None)
LAUNCHER.shard_dotnet(['x' * 131072], time.monotonic() + 5, '/owned', lambda _: None)
self.assertEqual('argv_bound', caught.exception.reason)
spawn.assert_not_called()
self.assertEqual(0, LAUNCHER.shard_dotnet(['--version'], time.monotonic() + 5,
Expand Down
Loading