Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(ci): allow pinned canonical git source for contract types

Steven Enamakelad771bad4cee
diff --git a/scripts/__tests__/check-module-boundaries.test.mjs b/scripts/__tests__/check-module-boundaries.test.mjs
index 7e9f537a47..71c25bba45 100644
--- a/scripts/__tests__/check-module-boundaries.test.mjs
+++ b/scripts/__tests__/check-module-boundaries.test.mjs
@@ -48,6 +48,18 @@ test('contracts permit only the serialization/schema/error closure', () => {
const m = metadata({ 'tinyjuice-bus': [['serde'], ['thiserror']], serde: [['serde_derive']], serde_derive: [['syn']], thiserror: [['thiserror-impl']] });
assert.deepEqual(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations, []);
});
+test('contracts allow pinned canonical TSD vocabulary and reject other git sources', () => {
+ const m = metadata({ 'tinyjuice-bus': [['tinystoragedrivers-types']] });
+ const types = m.packages.find(pkg => pkg.name === 'tinystoragedrivers-types');
+ const revision = 'a'.repeat(40);
+ types.source = `git+https://github.com/tinyhumansai/tinystoragedrivers?rev=${revision}#${revision}`;
+ assert.deepEqual(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations, []);
+
+ types.source = `git+https://github.com/senamakel/tinystoragedrivers?rev=${revision}#${revision}`;
+ assert.equal(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations[0].package, 'tinystoragedrivers-types');
+ types.source = 'git+https://github.com/tinyhumansai/tinystoragedrivers#main';
+ assert.equal(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations[0].package, 'tinystoragedrivers-types');
+});
test('contracts reject transport, runtime, HTTP, database and native libraries', () => {
for (const dependency of ['tinybus', 'tokio', 'reqwest', 'rusqlite', 'cpal', 'tinyjuice']) {
const m = metadata({ 'tinyjuice-bus': [[dependency]] });
diff --git a/scripts/ci/check-module-boundaries.mjs b/scripts/ci/check-module-boundaries.mjs
index 9d22eb0668..f92cb6a61c 100644
--- a/scripts/ci/check-module-boundaries.mjs
+++ b/scripts/ci/check-module-boundaries.mjs
@@ -6,6 +6,19 @@ import { dirname, isAbsolute, join, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
export const CONTRACT_REGISTRY = 'registry+https://github.com/rust-lang/crates.io-index';
+const CONTRACT_GIT_SOURCES = new Map([
+ ['tinystoragedrivers-types', 'https://github.com/tinyhumansai/tinystoragedrivers'],
+]);
+
+function contractSourceAllowed(name, source) {
+ if (source === CONTRACT_REGISTRY) return true;
+ const repository = CONTRACT_GIT_SOURCES.get(name);
+ if (!repository || typeof source !== 'string') return false;
+ const prefix = `git+${repository}?rev=`;
+ if (!source.startsWith(prefix)) return false;
+ const [revision, resolved] = source.slice(prefix.length).split('#');
+ return /^[0-9a-f]{40}$/.test(revision) && resolved === revision;
+}
export const CONTRACT_CLOSURE = new Set([
'serde', 'serde_core', 'serde_derive', 'serde_json', 'itoa', 'memchr', 'zmij',
@@ -82,7 +95,7 @@ export function auditGraph(metadata, roots, policy, contract = null) {
if (path.length > 1) {
const sourceMismatch = !contract && policy.contractManifests?.[name] &&
packages.get(id).manifest_path !== policy.contractManifests[name];
- const forbidden = contract ? !CONTRACT_CLOSURE.has(name) || packages.get(id).source !== CONTRACT_REGISTRY :
+ const forbidden = contract ? !CONTRACT_CLOSURE.has(name) || !contractSourceAllowed(name, packages.get(id).source) :
isImplementation(name, policy) || sourceMismatch;
if (forbidden) {
const scope = contract ?? 'hosts';