Buckets:
mvp-ai/skill-base / github.com /zxhwolfe-dev /aiworkstation-open-source-intelligence /.github /workflows /live-contract-validation.yml
| name: live-contract-validation | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| base_url: | |
| description: Allowed public AI Workstation origin to validate | |
| required: true | |
| default: https://aiworkstation.cn | |
| type: choice | |
| options: | |
| - https://aiworkstation.cn | |
| - https://useaistation.com | |
| project_id: | |
| description: Stable public project ID used for detail checks | |
| required: true | |
| default: infiniflow/ragflow | |
| type: string | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: live-contract-validation-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| VALIDATION_ROOT: tmp/live-contract-validation | |
| BASE_URL: ${{ inputs.base_url || 'https://aiworkstation.cn' }} | |
| PROJECT_ID: ${{ inputs.project_id || 'infiniflow/ragflow' }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Validate workflow inputs | |
| run: | | |
| set -euo pipefail | |
| python - <<'PY' | |
| import os | |
| import re | |
| import urllib.parse | |
| base_url = os.environ["BASE_URL"].rstrip("/") | |
| project_id = os.environ["PROJECT_ID"].strip() | |
| parsed = urllib.parse.urlparse(base_url) | |
| allowed_hosts = {"aiworkstation.cn", "useaistation.com"} | |
| if parsed.scheme != "https" or parsed.hostname not in allowed_hosts or parsed.path not in {"", "/"}: | |
| raise SystemExit("base_url must be an allowed HTTPS AI Workstation origin") | |
| if not re.fullmatch(r"[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+", project_id): | |
| raise SystemExit("project_id must use owner/repository form") | |
| PY | |
| - name: Install validation runtime | |
| run: | | |
| set -euo pipefail | |
| python -m pip install --upgrade pip | |
| python -m pip install -e ".[mcp]" | |
| - name: Run offline quality gates | |
| run: | | |
| set -euo pipefail | |
| python -m unittest discover -s tests -v | |
| osi-validate-plugin --root . | |
| - name: Run English and Chinese public probes | |
| run: | | |
| set -euo pipefail | |
| mkdir -p "$VALIDATION_ROOT" | |
| osi-probe \ | |
| --base-url "$BASE_URL" \ | |
| --locale en \ | |
| --project-id "$PROJECT_ID" \ | |
| --output "$VALIDATION_ROOT/probe-en.json" | |
| osi-probe \ | |
| --base-url "$BASE_URL" \ | |
| --locale zh \ | |
| --project-id "$PROJECT_ID" \ | |
| --output "$VALIDATION_ROOT/probe-zh.json" | |
| - name: Capture sanitized public contracts | |
| run: | | |
| set -euo pipefail | |
| osi-capture-contracts \ | |
| --base-url "$BASE_URL" \ | |
| --locale en \ | |
| --project-id "$PROJECT_ID" \ | |
| --output-dir "$VALIDATION_ROOT/contracts-en" | |
| osi-capture-contracts \ | |
| --base-url "$BASE_URL" \ | |
| --locale zh \ | |
| --project-id "$PROJECT_ID" \ | |
| --output-dir "$VALIDATION_ROOT/contracts-zh" | |
| - name: Validate and replay captured contracts | |
| run: | | |
| set -euo pipefail | |
| for locale in en zh; do | |
| directory="$VALIDATION_ROOT/contracts-$locale" | |
| osi-validate-contracts --directory "$directory" | |
| osi-replay-contracts \ | |
| --directory "$directory" \ | |
| --output "$VALIDATION_ROOT/replay-$locale.json" | |
| done | |
| - name: Scan artifacts for forbidden JSON keys | |
| run: | | |
| set -euo pipefail | |
| forbidden_key_pattern='"(authorization|cookie|cookies|api[_-]?key|apikey|access[_-]?token|refresh[_-]?token|bearer[_-]?token|password|secret|email|client_id|request_id|query|prompt|raw|raw_content|source_hash|evidence_ids|claim_refs|publication_version|validated_version|assignment_version|prompt_version)"[[:space:]]*:' | |
| if grep -RniE \ | |
| "$forbidden_key_pattern" \ | |
| "$VALIDATION_ROOT/contracts-en" \ | |
| "$VALIDATION_ROOT/contracts-zh"; then | |
| echo "Forbidden or unsanitized JSON key found in captured artifacts." >&2 | |
| exit 1 | |
| fi | |
| - name: Write validation summary and evidence manifest | |
| run: | | |
| set -euo pipefail | |
| python - <<'PY' | |
| import hashlib | |
| import json | |
| import os | |
| from datetime import datetime, timezone | |
| from pathlib import Path | |
| root = Path(os.environ["VALIDATION_ROOT"]) | |
| rows = [] | |
| probe_status = {} | |
| replay_status = {} | |
| for locale in ("en", "zh"): | |
| probe = json.loads((root / f"probe-{locale}.json").read_text(encoding="utf-8")) | |
| replay = json.loads((root / f"replay-{locale}.json").read_text(encoding="utf-8")) | |
| probe_status[locale] = probe.get("ok") is True | |
| replay_status[locale] = replay.get("ok") is True | |
| rows.append( | |
| f"| {locale} | {probe.get('ok')} | {replay.get('ok')} | " | |
| f"{len(probe.get('checks') or [])} | {len(probe.get('errors') or [])} |" | |
| ) | |
| if not all(probe_status.values()) or not all(replay_status.values()): | |
| raise SystemExit("validation evidence cannot be written from failed probes or replay") | |
| summary = [ | |
| "# Live Radar contract validation", | |
| "", | |
| f"- Base URL: `{os.environ['BASE_URL']}`", | |
| f"- Project ID: `{os.environ['PROJECT_ID']}`", | |
| "- Requests: anonymous and read-only", | |
| "- Captures: sanitized and scanned before artifact upload", | |
| "", | |
| "| Locale | Probe passed | Replay passed | Probe checks | Probe errors |", | |
| "| --- | ---: | ---: | ---: | ---: |", | |
| *rows, | |
| "", | |
| "The workflow uploads an artifact only after probes, contract validation, replay, and forbidden-key scanning all pass.", | |
| ] | |
| rendered = "\n".join(summary) + "\n" | |
| (root / "SUMMARY.md").write_text(rendered, encoding="utf-8") | |
| github_summary = os.environ.get("GITHUB_STEP_SUMMARY") | |
| if github_summary: | |
| Path(github_summary).write_text(rendered, encoding="utf-8") | |
| protected_files = {} | |
| for path in sorted(root.rglob("*")): | |
| if not path.is_file() or path.name == "validation-evidence.json": | |
| continue | |
| relative = path.relative_to(root).as_posix() | |
| protected_files[relative] = hashlib.sha256(path.read_bytes()).hexdigest() | |
| evidence = { | |
| "schema_version": "osi.live-validation-evidence.v1", | |
| "generated_at": datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"), | |
| "workflow": "live-contract-validation", | |
| "run_id": os.environ.get("GITHUB_RUN_ID", ""), | |
| "run_attempt": os.environ.get("GITHUB_RUN_ATTEMPT", ""), | |
| "commit": os.environ.get("GITHUB_SHA", ""), | |
| "repository": os.environ.get("GITHUB_REPOSITORY", ""), | |
| "base_url": os.environ["BASE_URL"].rstrip("/"), | |
| "project_id": os.environ["PROJECT_ID"].strip(), | |
| "contracts": {"en": "contracts-en", "zh": "contracts-zh"}, | |
| "checks": { | |
| "probe_en": True, | |
| "probe_zh": True, | |
| "contract_validate_en": True, | |
| "contract_validate_zh": True, | |
| "replay_en": True, | |
| "replay_zh": True, | |
| "forbidden_key_scan": True, | |
| }, | |
| "files": protected_files, | |
| } | |
| (root / "validation-evidence.json").write_text( | |
| json.dumps(evidence, ensure_ascii=False, indent=2) + "\n", | |
| encoding="utf-8", | |
| ) | |
| PY | |
| - name: Upload sanitized validation bundle | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: live-contract-validation-${{ github.run_id }} | |
| path: ${{ env.VALIDATION_ROOT }} | |
| if-no-files-found: error | |
| retention-days: 14 | |
Xet Storage Details
- Size:
- 8.37 kB
- Xet hash:
- 602662c274e831f7f06a61e4eb350f6df5bbcf16c4e6293dc3a44a8b53af1053
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.