Skip to content

Commit cf15aa7

Browse files
committed
Harden conformance expiry and vocabulary checks
1 parent d42dcc6 commit cf15aa7

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

.github/tests/test_repository_contract.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
REPO = Path(__file__).resolve().parents[2]
1717
RUNTIME = REPO / "boatstack"
1818
CONFIG = REPO / "project.example.json"
19-
DOMAIN_NEUTRAL_PATTERN = re.compile(
20-
r"\b(?:git|repository|worktree|branch|pull request|coding agent|publication)\b",
21-
re.IGNORECASE,
22-
)
19+
DOMAIN_NEUTRAL_WORDS = {"git", "repository", "worktree", "branch", "publication"}
20+
DOMAIN_NEUTRAL_PHRASE = re.compile(r"\b(?:pull\s+request|coding\s+agent)\b", re.IGNORECASE)
21+
GO_IDENTIFIER = re.compile(r"[A-Za-z_][A-Za-z0-9_]*")
22+
GO_IDENTIFIER_PART = re.compile(r"[A-Z]?[a-z]+|[A-Z]+(?![a-z])|[0-9]+")
2323

2424

2525
def go_source_metadata(paths: list[Path]) -> list[dict[str, object]]:
@@ -43,8 +43,18 @@ def go_source_metadata(paths: list[Path]) -> list[dict[str, object]]:
4343
def domain_vocabulary_hits(paths: list[Path]) -> list[tuple[Path, str]]:
4444
hits: list[tuple[Path, str]] = []
4545
for path in paths:
46-
for match in DOMAIN_NEUTRAL_PATTERN.finditer(path.read_text()):
46+
source = path.read_text()
47+
for match in DOMAIN_NEUTRAL_PHRASE.finditer(source):
4748
hits.append((path, match.group(0).lower()))
49+
for identifier in GO_IDENTIFIER.findall(source):
50+
if identifier.lower() == "github":
51+
continue
52+
parts = [
53+
part.lower()
54+
for component in identifier.split("_")
55+
for part in GO_IDENTIFIER_PART.findall(component)
56+
]
57+
hits.extend((path, part) for part in parts if part in DOMAIN_NEUTRAL_WORDS)
4858
return hits
4959

5060

@@ -430,8 +440,15 @@ def test_general_kernel_is_domain_neutral_and_owns_shared_control_laws(self) ->
430440
self.assertEqual([], domain_vocabulary_hits(kernel_files))
431441
with tempfile.TemporaryDirectory() as temporary:
432442
fixture = Path(temporary) / "domain_leak_test.go"
433-
fixture.write_text('package kernel\nconst fixtureDomain = "pull request"\n')
434-
self.assertEqual([(fixture, "pull request")], domain_vocabulary_hits([fixture]))
443+
for source, token in (
444+
('package kernel\nconst fixtureDomain = "pull request"\n', "pull request"),
445+
("package kernel\ntype gitClient struct{}\n", "git"),
446+
("package kernel\nvar testRepository string\n", "repository"),
447+
("package kernel\ntype worktreeManager struct{}\n", "worktree"),
448+
):
449+
with self.subTest(token=token):
450+
fixture.write_text(source)
451+
self.assertEqual([(fixture, token)], domain_vocabulary_hits([fixture]))
435452

436453
boatstack_packages = "github.com/operatorstack/boatstack/boatstack/"
437454
kernel_package = boatstack_packages + "kernel"

boatstack/kernel/conformance/conformance.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ func (suite KernelConformance) expiredAuthorityFailsClosed(t *testing.T) {
256256
func (suite KernelConformance) authorityExpiryInvalidatesPrescription(t *testing.T) {
257257
fixture, runtime := suite.fresh(t, SetupBound)
258258
transition := fixture.Scenario.AdvanceTransitions[0]
259-
request, prescription := resolve(t, runtime, fixture.Scenario, transition, &fixture.Scenario.Objective, fixture.Scenario.Authority)
259+
authority := fixture.Scenario.Authority
260+
authority.Receipts = append([]kernel.AuthorityReceipt(nil), authority.Receipts...)
261+
authority.Receipts[0].ExpiresAt = fixture.Clock.Now().Add(time.Hour)
262+
request, prescription := resolve(t, runtime, fixture.Scenario, transition, &fixture.Scenario.Objective, authority)
260263
fixture.Scenario.AdvanceClock(2 * time.Hour)
261264
before := fixture.Scenario.Snapshot()
262265
_, err := runtime.Apply(context.Background(), kernel.ApplyRequest{ResolveRequest: request, Prescription: prescription})

boatstack/kernel/conformance/integer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func newIntegerFixture(setup Setup) KernelConformance {
347347
state.Mode, state.ObjectiveBinding, value = "one", &binding, 1
348348
}
349349
now := time.Date(2026, 8, 12, 10, 0, 0, 0, time.UTC)
350-
authority := kernel.Authority{Receipts: []kernel.AuthorityReceipt{{ID: "human-counter", Subject: "fixture", Fingerprint: "fixture-authority", Capabilities: []kernel.Capability{"counter.audit", "counter.increment", "counter.reset", "objective.bind"}, IssuedAt: now.Add(-time.Minute), ExpiresAt: now.Add(time.Hour)}}}
350+
authority := kernel.Authority{Receipts: []kernel.AuthorityReceipt{{ID: "human-counter", Subject: "fixture", Fingerprint: "fixture-authority", Capabilities: []kernel.Capability{"counter.audit", "counter.increment", "counter.reset", "objective.bind"}, IssuedAt: now.Add(-time.Minute), ExpiresAt: now.Add(24 * time.Hour)}}}
351351
domain := &IntegerDomain{value: value, executions: map[string]int{}}
352352
receipts := &MemoryReceipts{}
353353
store := &MemoryStateStore{state: state, receipts: receipts}

0 commit comments

Comments
 (0)