Skip to content

feat(metadata): merge scoring output into existing metadata - #177

Merged
KartikP merged 4 commits into
mainfrom
kp/metadata-merge-not-overwrite
Oct 8, 2026
Merged

KartikP merged 4 commits into
mainfrom
kp/metadata-merge-not-overwrite

Conversation

@KartikP

@KartikP KartikP commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Scoring used to treat an existing metadata file in two incompatible ways:

  • handle_metadata.main skipped generation entirely when a schema 2.0 file existed, so computed values (parameter count, architecture, layers) never reached a submitted v2 file.
  • ModelMetadataGenerator.create_yaml replaced models[<name>] wholesale whenever it did run.

This PR makes scoring merge instead of replace:

  • v2 files: computed values become a from_legacy entry and fill only empty fields. The legacy block gets missing keys. A v2 field is filled only if it is empty and no assertion covers it or a parent section, so submitted values and documented absences ("undocumented") stay. Filled fields carry probable evidence from the unreviewed legacy source. The result is validated with brainscore_core.metadata.dump before writing.
  • v1 files: keys that already have a value are kept; empty keys are filled.
  • When it runs: models are loaded only while some entry in the v2 file has no legacy block, that is, no computed values yet. Metadata-only merges (editor PRs, the vision back-fill) therefore do not reload models on the GitHub runner.
  • PR: a v2 file that gained values gets the usual auto/metadata-update PR; an unchanged file gets none. Publication stays with the merged-PR publisher.
  • File name: an existing metadata.yaml is updated in place instead of being shadowed by a new metadata.yml.

Tests: a submitted v2 field survives a scoring run, a documented absence is not filled, an existing v1 value survives, main opens a PR only when the v2 file changed, and an already-scored v2 file does not reload models. Local run: 37 passed (tests/test_plugin_management metadata modules and tests/test_metadata).

After merge, the web app's METADATA_CORE_REF pin needs bumping (separate PR).

Note: vision and language install brainscore-core from PyPI, which is on 2.3.8. That release predates the v2 contract, so today every v2 metadata-only merge fails vision's "Process metadata changes" job ("Top-level key 'schema_version' is not allowed"). That failure is pre-existing; a core release fixes it and ships this change.

Scoring now fills only empty fields of an existing metadata file instead
of replacing the model entry. Schema 2.0 files keep submitted values and
documented absences; computed values go to the legacy block and to empty
v2 fields with probable, unreviewed evidence. A v2 file that gains values
gets the usual metadata PR, and metadata.yaml is no longer shadowed by a
new metadata.yml.
Metadata-only merges run handle_metadata on every touched folder. Without
this, each merge of a v2 file would reload its models on a GitHub runner
even when every entry already carries computed legacy values.
The installed resnet50_tutorial plugin now ships a v2 metadata.yaml,
which the generator updates in place, so the test found no metadata.yml
and would also have modified the installed package.
The real-model test copies resnet50_tutorial to a scratch folder, reads
the result through metadata_file_path, checks the computed legacy values,
and checks that curated v2 fields, sources and assertions are unchanged.
The installed package is never written.
@KartikP
KartikP merged commit 7028174 into main Oct 8, 2026
3 checks passed
KartikP added a commit that referenced this pull request Oct 9, 2026
Every qualifying merge to `main` is versioned and published
automatically. There is no bump PR, no approval step and no personal
access token.

**Release rule** (`.github/workflows/release.yml`, one decision per
squash merge)
1. **Path gate:** the merge must change a shipped file. For core that
means a file under `brainscore_core/` or the `[project] dependencies` in
`pyproject.toml`. Changes only to tests, docs, `.github`, `*.md`,
`sqlite3.db` and so on never release, whatever the title says.
2. **Title type:** `feat` gives a minor release; `fix` and `perf` give a
patch. Every other allowed type gives no release: `refactor`, `docs`,
`test`, `ci`, `chore`, `build`, `plugin`, `model`, `benchmark`, `data`,
`metric`.
3. **Major:** needs `!` in the title or a `BREAKING CHANGE` footer,
**and** the `major update` label on the PR. Without the label it is
downgraded to minor.

The workflow computes the level and passes it to python-semantic-release
as a forced bump (`force: patch|minor|major`). python-semantic-release
then:
- updates `version` in `pyproject.toml`;
- commits `chore(release): X.Y.Z` with the skip-ci marker;
- tags `vX.Y.Z` and pushes to `main` with a GitHub App token
(`actions/create-github-app-token`);
- builds the sdist and wheel, and creates a GitHub release.

A separate `publish` job in the `pypi` environment uploads with
`pypa/gh-action-pypi-publish` through trusted publishing (`id-token:
write`, no stored PyPI token).

The level is forced rather than left to python-semantic-release, because
it would otherwise read every commit since the last tag, and a skipped
`feat` (for example, a tests-only merge) would leak into the next
release.

- **Loop guard:** the skip-ci marker on the release commit, plus a job
condition that skips head commits starting with `chore(release):`.
- **`workflow_dispatch`** with a `level` choice is for the first release
and for missed ones. Merging this PR does not release by itself, because
it changes no shipped file. Cutting **2.4.0** (feat #172, #177 and #178
since v2.3.8) is one manual run with `minor`.

**PR title check** (`.github/workflows/pr-title.yml`,
`amannn/action-semantic-pull-request`)
- It runs on `pull_request_target` (opened, edited, synchronize,
reopened, labeled, unlabeled), so fork PRs get it too. It never checks
out PR code, and its only permission is `pull-requests: write`.
- On an invalid title it posts one sticky comment showing:
  - the failing title;
  - each type with the release it causes;
  - the major-label rule and the path rule;
  - the `type(scope): subject` format and three examples.
- The comment updates in place on each edit and is deleted once the
title passes.
- A second sticky comment warns when a breaking title or body has no
`major update` label.

**Reuse:** both workflows also declare `workflow_call`. Vision and
language call them from `main` (`secrets: inherit`), and their only
setting is the `release-paths` regex. For vision, for example:
`^brainscore_vision/(?!(models|benchmarks|data|metrics)/)`, so
plugin-only PRs never release.

**Local checks**
- Path and title gate on a scratch repo:

| Merge | Level |
|---|---|
| `feat` under `brainscore_core/` | minor |
| `feat` only under `tests/` | none |
| `fix` | patch |
| `docs` in the package | none |
| `build(deps)` | none |
| `fix(deps)` changing dependencies | patch |
| version-only `pyproject` edit | none |
| `feat!` without the label | minor |
| `feat!` with the label | major |
| `plugin` | none |

- python-semantic-release 10.7.0 `--noop` on current main: forced patch
gives 2.3.9, minor gives 2.4.0, major gives 3.0.0.
- The vision regex keeps `model_helpers/` and `__init__.py` as shipped,
and excludes `models/`, `benchmarks/` and `metrics/`.
- Neither new workflow runs on this PR (push-only and
`pull_request_target` read from `main`). Jenkins and
`metadata-contract.yml` are unchanged.

**Before merging**, complete the one-time setup in the hive note
`shared/core_auto_release.md`: the App, the secrets, a ruleset with the
App as bypass and the title check required, squash-only merging with the
PR title, and the PyPI trusted publisher.
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.

1 participant