wenjin272 commented on code in PR #969:
URL: https://github.com/apache/flink-agents/pull/969#discussion_r3740994084
##########
.github/workflows/ci.yml:
##########
@@ -49,6 +49,8 @@ jobs:
run: ./tools/lint.sh -c
- name: Check AGENTS.md freshness
run: python3 tools/check-agents-md.py
+ - name: Check bundled YAML schema freshness
+ run: python3 tools/check-skill-schema.py
Review Comment:
This workflow also runs for `release-*` branches, but the new step always
validates the contract whose `source.ref` is `main`. If a schema change is
backported to a release branch, the check either leaves that branch's CI red or
asks us to record the release branch's blob SHA as `main` provenance. This is a
realistic path: `release-0.3` has already received schema-changing backports.
Could we restrict this step to `main` pushes and PRs targeting `main`, or make
contract selection branch-aware?
##########
tools/check-skill-schema.py:
##########
@@ -0,0 +1,101 @@
+#!/usr/bin/env python3
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#################################################################################
+"""Assert the coding-agent skill still bundles the current YAML schema.
+
+The skill ships a copy of docs/yaml-schema.json so it can answer YAML questions
+offline, and records in yaml-contracts.yaml the git blob SHA that copy was
taken
+from. Nothing regenerates either one, so both drift silently the moment the
+schema is re-exported. A stale copy teaches agents a schema the repository no
+longer has, and a stale blob SHA misreports which revision the copy describes.
+
+Only the unversioned "main" contract is checked. The versioned schemas beside
it
+pin released refs, so they are expected to differ from the working tree.
+
+Regex-only and dependency-free so it runs on any Python 3 without a build step.
+"""
+
+import hashlib
+import re
+import sys
+from pathlib import Path
+
+REPO_ROOT = Path(__file__).resolve().parent.parent
+DOCS_SCHEMA = REPO_ROOT / "docs" / "yaml-schema.json"
+ASSETS = REPO_ROOT / "dev" / "agent-skills" / "flink-agents-dev" / "assets"
+BUNDLED_SCHEMA = ASSETS / "yaml-schema.json"
+MANIFEST = ASSETS / "yaml-contracts.yaml"
+
+
+def blob_sha(path: Path) -> str:
+ """Return the git blob SHA of a file, matching `git hash-object <path>`."""
+ data = path.read_bytes()
+ return hashlib.sha1(b"blob %d\0" % len(data) + data).hexdigest()
Review Comment:
Hashing `read_bytes()` gives a worktree-content hash, which is not always
the Git blob SHA. With `core.autocrlf=true` and no `.gitattributes`, these JSON
files are checked out as CRLF, so this reports the recorded LF blob SHA as
stale and suggests a SHA that Linux CI will reject. Could we hash through Git's
clean filters (for example, `git hash-object --stdin
--path=docs/yaml-schema.json`) or enforce LF for these files?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]