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
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ jobs:
shard: [1, 2, 3]
steps:
- uses: actions/checkout@v7
with:
# The native pin suite reads the manifests at published companion tags.
fetch-depth: 0

- name: Setup Flutter
uses: subosito/flutter-action@v2
Expand Down Expand Up @@ -619,6 +622,7 @@ jobs:
LLAMADART_TEST_MODELS_DIR: ${{ github.workspace }}/.dart_tool/test_models
LLAMA_CPP_TEMPLATES_DIR: ${{ github.workspace }}/.dart_tool/llama_cpp_templates
REQUIRE_LLAMA_CPP_TEMPLATES: '1'
LLAMADART_REQUIRE_PUBLISHED_COMPANION_TAGS: '1'
run: dart test -p vm -j 1 --exclude-tags local-only ${{ needs.changes.outputs.coverage == 'true' && '--coverage=coverage' || '' }} --file-reporter=json:.dart_tool/test_events.jsonl ${{ steps.shard.outputs.files }}

- name: Check the LiteRT-LM cache canary
Expand Down Expand Up @@ -1250,7 +1254,6 @@ jobs:
flutter-version: 3.47.1
channel: stable
cache: true
- run: dart pub get
- run: flutter pub get
working-directory: example/chat_app
- run: flutter test test/validation_controller_test.dart test/validation_app_test.dart
Expand Down
9 changes: 6 additions & 3 deletions doc/ci_selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PR. A path filter must not prevent a required workflow from reporting.
|---|---|---|
| Documentation, website, docs tooling | Docs build/tool tests plus version and bridge-pin checks | None |
| Any path | Adds `Markdown Tests`, unless the Linux VM tests are selected | None |
| Genkit or Model Store package | Affected package checks and root Linux VM tests | None |
| Studio core or UI package (`web/`, `windows/`, `linux/` packaging vs shared/macOS) | Studio core and Flutter UI format, analysis and VM tests; `studio-macos` for non-exempt inputs; Web files also run version and bridge-pin checks | None |
| One companion package | Root static checks, affected package's Flutter/SwiftPM/publish checks, Apple cache check, root Linux coverage and full macOS/Windows VM checks, Studio + `studio-macos`, Web Chat consumer | Android, Web, iOS inputs |
| Validation package tests/schemas or unbundled assets (`process_memory_test.dart` / `process_memory_probe.dart` also run Mac memory) | Root static checks, Linux VM tests, private suite and Flutter consumer contracts | None |
Expand All @@ -23,7 +24,7 @@ PR. A path filter must not prevent a required workflow from reporting.
| Root `test/**` (extant Linux-only leaf suite on PR vs host-sensitive suite, helper/fixture, deleted/unknown, or push) | Static, all Linux VM tests, Chrome and Windows host tests; Mac native shards only when `test_shards.dart hosts-json` reports host-relevant or on helper/fixture/push/probe-failure; shared fixtures/helpers also run Studio, `studio-macos` and Apple cache | None |
| Browser backend trees (`lib/src/backends/web/**`, `lib/src/backends/webgpu/**`) | Non-Mac full graph (Linux, Chrome, Windows native, Ubuntu Studio, Web Chat, Genkit, Model Store, examples) with zero Mac allocations | Linux, Windows desktops; apps (PR defers Android) |
| Root runtime/hooks/dependencies, other example packages, conditional backend entrypoints | Full behavioral graph | All targets; a PR defers macOS desktop and Android unless it changes their build inputs (`.flutter-version` included for `macos-15`) |
| Workflow/selector or unclassified paths | Full graph including synthetic artifact transport (workflows/selector) | All targets; a PR defers `macos-15` and `android` unless it changes their build inputs (`validation_bundles.yml`, `select_jobs.py`, `hook/`, `lib/src/hook/`, `pubspec.*`, `.flutter-version`, `tool/testing/validation*`, or compiled `packages/llamadart_validation/` for `macos-15`) |
| Workflow/selector or unclassified paths | Full graph including synthetic artifact transport (workflows/selector) | All targets; a PR defers `macos-15` and `android` unless it changes their build inputs (`validation_bundles.yml`, `select_jobs.py`, `hook/`, `lib/src/hook/`, `pubspec.*`, `.flutter-version` for `macos-15`, `tool/testing/validation*`, or compiled `packages/llamadart_validation/`) |
| Missing, empty or invalid diff; explicit manual bundle run | Full fallback | All targets (`macos-15` retained) |

Selections combine for mixed changes. Version checks already executed by the
Expand Down Expand Up @@ -57,8 +58,10 @@ This is executable job accounting, not a new repository protection setting.
`tool/ci/markdown_test_suites.txt`, for every change that selects no Linux VM
tests. It carries no coverage, so a Markdown-only commit uploads none to
Codecov. Every path selects it, not only Markdown: any file a root suite
reaches can start reading Markdown without a test changing, and the website,
Genkit and Model Store lanes run no other root test.
reaches can start reading Markdown without a test changing. Website changes
run the site build script's root suite here. Genkit and Model Store package
changes select the Linux VM tests because root tooling also reads their
package files.

`markdown_test_suites_test.dart` keeps the inventory complete. Every root suite
whose static reach shows Markdown evidence must be listed in the inventory or
Expand Down
11 changes: 6 additions & 5 deletions doc/high_risk_pre_merge_readiness.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ snippet must occur in its exact candidate blob, like any source reference.
This does not admit other harness assets or arbitrary package paths, or relax
compiled-grammar, independent-audit or external-authentication requirements.

Studio admits production references only under
The evaluator admits Studio production references under
`packages/llamadart_studio_core/lib/` and `packages/llamadart_studio/lib/`.
Its tests are the corresponding `test/**/*_test.dart` trees and the Flutter
app's `integration_test/**/*_test.dart` tree. These paths retain exact-blob,
complete changed-production coverage, snippet and observed causal-control
requirements; they do not admit arbitrary packages or platform assets.
It admits tests from both packages' `test/**/*_test.dart` trees and the Flutter
app's `integration_test/**/*_test.dart` tree. It does not require package-local pairing.
The independent reviewer verifies each test reaches the cited production code.
Exact-blob, complete changed-production coverage, snippet and observed
causal-control requirements apply.
Studio inference, message/settings, MCP schema, and Chat/Coding boundaries are
conservative structured-output surfaces with all three minimum impacts.
An unchanged root grammar does not establish that adapter-produced schemas,
Expand Down
14 changes: 8 additions & 6 deletions test/ci/test_select_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_every_path_runs_the_markdown_reader_guard(self):
jobs = ci.select([path], pull_request=pull_request)['jobs']
self.assertNotEqual(jobs['markdown-tests'], jobs['test-linux-coverage'])
for path in ('tool/docs/build_site.sh', 'website/lib/src/site/site_model.dart',
'packages/genkit_llamadart/lib/a.dart', 'LICENSE'):
'LICENSE'):
with self.subTest(path=path):
plan = ci.select([path])
self.assertTrue(plan['jobs']['markdown-tests'])
Expand All @@ -101,8 +101,10 @@ def test_deleted_and_renamed_markdown_keep_tooling_and_specialized_jobs(self):
for raw in (b'D\0website/docs/integrations/genkit.md\0',
b'R100\0packages/genkit_llamadart/README.md\0website/docs/new.md\0'):
plan = ci.select(ci.inventory(raw))
self.assertTrue(plan['jobs']['markdown-tests'])
self.assertTrue(plan['jobs']['genkit'])
source_is_package = raw.startswith(b'R')
self.assertEqual(plan['jobs']['test-linux-coverage'], source_is_package)
self.assertEqual(plan['jobs']['markdown-tests'], not source_is_package)
self.assertEqual(plan['apps'], [])
self.assertEqual(plan['desktops'], [])

Expand Down Expand Up @@ -136,12 +138,12 @@ def test_genkit_gateway_runs_package_snippet_compilation_with_docs(self):
self.assertEqual(plan['companions'], [])
self.assertEqual(plan['apps'], [])

def test_genkit_is_independent_but_core_and_shared_changes_test_the_adapter(self):
def test_genkit_package_changes_run_root_readers_and_the_adapter(self):
for path in ('lib/genkit_llamadart.dart', 'README.md', 'pubspec.yaml',
'.github/check_docs.py', 'test/contract_test.dart'):
plan = ci.select(['packages/genkit_llamadart/' + path])
self.assertEqual({j for j, v in plan['jobs'].items() if v},
{'genkit', 'markdown-tests'})
{'genkit', 'test-linux-coverage'})
self.assertEqual(plan['companions'], [])
self.assertEqual(plan['apps'], [])
self.assertEqual(plan['desktops'], [])
Expand Down Expand Up @@ -206,12 +208,12 @@ def test_root_test_fixtures_studio_reads_run_the_studio_lanes(self):
self.assertTrue(plan['jobs']['studio'], path)
self.assertTrue(ci.expected_jobs(plan)['studio-macos'], path)

def test_model_store_is_independent_but_core_changes_test_it(self):
def test_model_store_package_changes_run_root_readers_and_package_tests(self):
for path in ('lib/llamadart_model_store.dart', 'README.md', 'pubspec.yaml',
'test/model_store_test.dart'):
plan = ci.select(['packages/llamadart_model_store/' + path])
self.assertEqual({j for j, v in plan['jobs'].items() if v},
{'model-store', 'markdown-tests'})
{'model-store', 'test-linux-coverage'})
self.assertEqual(plan['companions'], [])
self.assertEqual(plan['apps'], [])
self.assertEqual(plan['desktops'], [])
Expand Down
20 changes: 16 additions & 4 deletions test/unit/hook/native_release_pins_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,26 @@ void main() {
expect(published, isNotEmpty);
for (final MapEntry(key: tag, value: checksum) in published.entries) {
expect(checksum, llamaCppCompatibleAppleCompanionChecksums[previous]);
// Release tags are absent from shallow CI checkouts; the recorded
// value is checked against the tag wherever it is present.
final ref = 'refs/tags/$tag';
final tagExists =
Process.runSync('git', [
'show-ref',
'--verify',
'--quiet',
ref,
]).exitCode ==
0;
if (!tagExists &&
Platform.environment['LLAMADART_REQUIRE_PUBLISHED_COMPANION_TAGS'] !=
'1') {
continue;
}
final shown = Process.runSync('git', [
'show',
'$tag:packages/llamadart_llama_cpp_flutter/darwin/'
'$ref:packages/llamadart_llama_cpp_flutter/darwin/'
'llamadart_llama_cpp_flutter/Package.swift',
]);
if (shown.exitCode != 0) continue;
expect(shown.exitCode, 0, reason: '$ref: ${shown.stderr}');
final manifest = shown.stdout as String;
expect(
manifest,
Expand Down
33 changes: 31 additions & 2 deletions test/unit/tooling/check_released_changelog_sections_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,12 @@ void main() {
expect(run().exitCode, 0);
});

test('exempts release prep', () {
repo.commit({'CHANGELOG.md': '## 1.2.0\n\n- Pending.\n\n$_released'});
test('exempts release prep from the released-text comparison', () {
const promoted = '## 1.2.0\n\n- Pending.\n\n$_released';
repo.commit({
'CHANGELOG.md': promoted,
_docsChangelog: '$_docsIntro$promoted',
});

expect(run().exitCode, 1);
for (final result in [
Expand All @@ -571,6 +575,31 @@ void main() {
}
});

test(
'rejects a stray Unreleased heading in either release-prep changelog',
() {
const promoted = '## 1.2.0\n\n- Pending.\n\n$_released';
for (final path in ['CHANGELOG.md', _docsChangelog]) {
repo.commit({
'CHANGELOG.md':
"${path == 'CHANGELOG.md' ? '## Unreleased\n\n' : ''}$promoted",
_docsChangelog:
"$_docsIntro${path == _docsChangelog ? '## Unreleased \n\n' : ''}$promoted",
});
for (final result in [
run(labels: ['release-prep']),
run(headRef: 'release/prep-1.2.0'),
]) {
expect(result.exitCode, 1, reason: '${result.stdout}');
expect(
result.stderr,
contains('$path must not keep `## Unreleased` when publishing.'),
);
}
}
},
);

test('fails closed when the base branch is not fetched', () {
final result = run(baseRef: 'release-branch');
expect(result.exitCode, 1);
Expand Down
8 changes: 5 additions & 3 deletions test/unit/tooling/check_webgpu_bridge_tag_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,12 @@ void main() {
expect(findRuntimeBaselineDrift(root), hasLength(4));
});

test('frozen sections keep their own tags', () {
test('a frozen top section keeps the tags it shipped with', () {
final released = paragraph(liteRt: 'v0.18.0', sd: 'v0.2.0');
final root = baselineRepo(
changelog: '## 1.0.0\n\n${paragraph(liteRt: 'v0.18.0', sd: 'v0.2.0')}',
docs: paragraph(),
heading: '1.0.0',
changelog: released,
docs: released,
);
expect(findRuntimeBaselineDrift(root), isEmpty);
});
Expand Down
24 changes: 22 additions & 2 deletions test/unit/tooling/ci_workflow_selection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ for event,mode,oldflag,owner,attempt,cancel,good,main in itertools.product(('pus
(plan['jobs'] as Map).entries
.where((e) => e.value == true)
.map((e) => e.key),
unorderedEquals(['model-store', 'markdown-tests']),
unorderedEquals(['model-store', 'test-linux-coverage']),
);

final job = readWorkflow('ci')['jobs']['model-store'] as Map;
Expand Down Expand Up @@ -1422,6 +1422,27 @@ for event,flag,native,cancel,good,main in itertools.product(('push','pull_reques
},
);

test('Linux VM tests have published companion tags and require them', () {
final steps = readWorkflow('ci')['jobs']['test-linux-vm']['steps'] as List;
final checkout = steps.singleWhere(
(step) => '${step['uses']}'.startsWith('actions/checkout@'),
);
expect(checkout['with']?['fetch-depth'], 0);
final tests = steps.singleWhere((step) => step['name'] == 'Run VM tests');
expect(tests['env']['LLAMADART_REQUIRE_PUBLISHED_COMPANION_TAGS'], '1');
});

test('validation consumer resolves dependencies only in the chat app', () {
final steps =
readWorkflow('ci')['jobs']['validation-integration']['steps'] as List;
final resolution = steps.where(
(step) => '${step['run']}'.contains('pub get'),
);
expect(resolution, [
{'run': 'flutter pub get', 'working-directory': 'example/chat_app'},
]);
});

test('selection uses complete checkout and safe event metadata boundary', () {
for (final name in ['ci', 'validation_bundles']) {
final job = readWorkflow(name)['jobs']['changes'];
Expand Down Expand Up @@ -1476,7 +1497,6 @@ for event,flag,native,cancel,good,main in itertools.product(('push','pull_reques
'tool/docs/build_site.sh',
'tool/docs/new_reader.dart',
'website/tool/finalize_site.dart',
'packages/genkit_llamadart/lib/genkit_llamadart.dart',
]) {
final jobs = (await selected([path]))['jobs'] as Map;
expect(jobs['markdown-tests'], isTrue, reason: path);
Expand Down
32 changes: 23 additions & 9 deletions test/unit/tooling/docs_changelog_drift_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ void main() {
);
});

test('ignores Unreleased and sections only one file has', () {
expect(
docsChangelogDriftProblems(
{'Unreleased': '- A.\n', '0.1.0': '- Old.\n'},
{'Unreleased': '- B.\n'},
),
isEmpty,
);
test('rejects missing or changed Unreleased bullets on either side', () {
const pending = {'Unreleased': '- Pending.\n'};
for (final (core, docs) in [
(pending, {'Unreleased': '- Different.\n'}),
(pending, {'Unreleased': ''}),
(pending, <String, String>{}),
(<String, String>{}, pending),
]) {
expect(docsChangelogDriftProblems(core, docs), [
contains('section "## Unreleased" differs from CHANGELOG.md'),
]);
}
expect(docsChangelogDriftProblems({'Unreleased': '\n'}, {}), isEmpty);
});

test('ignores released sections that are present in only one file', () {
expect(
docsChangelogDriftProblems({'0.1.0': '- Old.\n'}, {'0.2.0': '- New.\n'}),
isEmpty,
Expand Down Expand Up @@ -149,6 +157,12 @@ void main() {
expect(problems.single, contains('bridge line must read'));
}
expect(docsChangelogDriftProblems({}, {'0.2.0': bridgeCore}), hasLength(1));
expect(docsChangelogDriftProblems({}, {'Unreleased': bridgeCore}), isEmpty);
expect(
docsChangelogDriftProblems(
{'Unreleased': bridgeCore},
{'Unreleased': bridgeDocs},
),
isEmpty,
);
});
}
8 changes: 8 additions & 0 deletions test/unit/tooling/high_risk_readiness_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4300,6 +4300,14 @@ final segment = '${Object()}ImageEditingRequest${Object()}';
'packages/llamadart_studio/lib/src/services/runtime_factory.dart',
'packages/llamadart_studio/test/runtime_factory_test.dart',
),
(
'packages/llamadart_studio_core/lib/src/services/lifecycle_coordinator.dart',
'packages/llamadart_studio/test/lifecycle_integration_test.dart',
),
(
'packages/llamadart_studio/lib/src/services/runtime_factory.dart',
'packages/llamadart_studio_core/test/runtime_integration_test.dart',
),
(
'packages/llamadart_studio/lib/src/services/runtime_factory.dart',
'packages/llamadart_studio/integration_test/local_workflows_acceptance_test.dart',
Expand Down
8 changes: 8 additions & 0 deletions test/unit/tooling/high_risk_review_policy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ void main() {
expect(runbook, contains('reviewed as a change in its own right'));
});

test(
'the runbook states the evaluator uses no package-local Studio pairing',
() {
final runbook = read('doc/high_risk_pre_merge_readiness.md');
expect(runbook, contains('does not require package-local pairing'));
},
);

test('classifier help preserves rename and deletion visibility', () {
final classifier = read('tool/testing/classify_high_risk_changes.dart');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ void main() {
expect(project, isNot(contains('macos_litert_lm_prepare_app.sh')));
});

for (final docs in _installationDocs) {
final versions =
jsonDecode(File('website/versions.json').readAsStringSync()) as List;
for (final docs in [
..._installationDocs,
'website/versioned_docs/version-${versions.first}/platforms/apple-setup.md',
]) {
// Only macOS can run the documented script, so its text may change only
// together with this fixture, which selects the macOS tests.
test('$docs build phase is the reviewed script', () {
Expand Down
18 changes: 18 additions & 0 deletions test/unit/tooling/markdown_test_suites_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ void main() {
);
});

test('the Markdown lane covers the site build script', () {
expect(
inventory,
contains('test/unit/tooling/build_site_script_test.dart'),
);
});

test('the workflow row attributes the macOS SDK input correctly', () {
final row = File('doc/ci_selection.md').readAsLinesSync().singleWhere(
(line) => line.startsWith('| Workflow/selector or unclassified paths |'),
);
expect(row, contains('`.flutter-version` for `macos-15`'));
expect(
row,
isNot(contains('`packages/llamadart_validation/` for `macos-15`')),
);
});

test('the Markdown Tests job runs the inventory on Linux', () {
final workflow =
loadYaml(File('.github/workflows/ci.yml').readAsStringSync())
Expand Down
Loading
Loading