Build Member 2 fixture review-to-release pipeline
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
name: Final project review (fixture)
|
||||
on:
|
||||
push:
|
||||
branches: [feature/final-ci-demo, final-project-demo]
|
||||
jobs:
|
||||
review:
|
||||
runs-on: manual-latex
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
persist-credentials: false
|
||||
- name: Verify source and run fixture contract tests
|
||||
env:
|
||||
SOURCE_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
set -eu
|
||||
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
|
||||
python3 -m unittest discover -s ci/tests -v
|
||||
- name: Produce explicitly simulated review bundle
|
||||
env:
|
||||
SOURCE_SHA: ${{ github.sha }}
|
||||
ACTIONS_RUN_ID: ${{ github.run_id }}
|
||||
ACTIONS_ATTEMPT: ${{ github.run_attempt }}
|
||||
run: |
|
||||
set -eu
|
||||
echo 'Mode: fixture. No live model or live token evidence.'
|
||||
python3 ci/fixtures/reviewer_stub.py --input ci/fixtures/demo_broken.txt --source-commit "$SOURCE_SHA" --out-dir out/review
|
||||
python3 ci/final_project.py bundle --review-dir out/review --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode fixture --output out/review-bundle.zip
|
||||
- name: Publish ready bundle for this exact run and attempt
|
||||
uses: https://github.com/actions/upload-artifact@c6a366c94c3e0affe28c06c8df20a878f24da3cf
|
||||
with:
|
||||
name: review-${{ github.run_id }}-attempt-${{ github.run_attempt }}-${{ github.sha }}
|
||||
path: out/review-bundle.zip
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,4 @@
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
out/
|
||||
documentation/build/
|
||||
@@ -0,0 +1,77 @@
|
||||
pipeline {
|
||||
agent { label 'assignment8-trusted' }
|
||||
options { disableConcurrentBuilds(); skipDefaultCheckout(); timeout(time: 45, unit: 'MINUTES'); timestamps() }
|
||||
parameters {
|
||||
string(name: 'SOURCE_SHA', defaultValue: '', description: 'Full SHA of this reviewed pipeline branch and Actions run')
|
||||
string(name: 'ACTIONS_RUN_ID', defaultValue: '', description: 'Exact successful Gitea Actions run')
|
||||
string(name: 'ACTIONS_ATTEMPT', defaultValue: '1', description: 'Exact attempt')
|
||||
choice(name: 'MODE', choices: ['fixture'], description: 'Live mode requires Member 1 integration and review')
|
||||
}
|
||||
stages {
|
||||
stage('Checkout exact source') {
|
||||
steps {
|
||||
script {
|
||||
if (!(params.SOURCE_SHA ==~ /[0-9a-f]{40}/) || !(params.ACTIONS_RUN_ID ==~ /[1-9][0-9]*/) || !(params.ACTIONS_ATTEMPT ==~ /[1-9][0-9]*/)) { error('Invalid run identity') }
|
||||
}
|
||||
deleteDir()
|
||||
checkout scm
|
||||
sh '''set -eu
|
||||
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
|
||||
mkdir -p out
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Retrieve exact Actions bundle') {
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'final-project-gitea-read', variable: 'GITEA_TOKEN')]) {
|
||||
sh '''set +x
|
||||
set -eu
|
||||
python3 ci/final_project.py fetch --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --output out/review-bundle.zip > out/actions-run.json
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Validate identity and payload hashes') {
|
||||
steps { sh '''set -eu
|
||||
python3 ci/final_project.py verify --bundle out/review-bundle.zip --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --output out/verified
|
||||
sh ci/toolchain.sh start
|
||||
''' }
|
||||
}
|
||||
stage('Reserve durable release version') {
|
||||
steps {
|
||||
script {
|
||||
env.RELEASE_VERSION = sh(script: 'sh ci/toolchain.sh exec python3 ci/final_project.py reserve --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --state /state --baseline 1.0', returnStdout: true).trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Compile LaTeX report') {
|
||||
steps { sh '''set -eu
|
||||
RUN_NUMBER=$(python3 -c 'import json;print(json.load(open("out/actions-run.json"))["run_number"])')
|
||||
sh ci/toolchain.sh exec python3 documentation/ci/build_manual.py --sha "$SOURCE_SHA" --run-number "$RUN_NUMBER" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --review-bundle /work/out/review-bundle.zip --release-version "$RELEASE_VERSION" --mode "$MODE" --jenkins-build "$BUILD_NUMBER"
|
||||
''' }
|
||||
}
|
||||
stage('Unit, syntax and reviewed-file smoke tests') {
|
||||
steps { sh '''set -eu
|
||||
sh ci/toolchain.sh exec python3 -m unittest discover -s tests -v
|
||||
sh ci/toolchain.sh exec python3 -m unittest discover -s ci/tests -v
|
||||
sh ci/toolchain.sh exec python3 ci/final_project.py test --review-dir out/verified --output out/test-result.json
|
||||
''' }
|
||||
}
|
||||
stage('Package immutable release') {
|
||||
steps { sh '''set -eu
|
||||
sh ci/toolchain.sh exec python3 ci/final_project.py publish --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --bundle out/review-bundle.zip --pdf documentation/build/main.pdf --state /state --output out/release --jenkins-build "$BUILD_NUMBER"
|
||||
sh ci/toolchain.sh collect
|
||||
''' }
|
||||
}
|
||||
stage('Publish downloadable ZIP') {
|
||||
steps { archiveArtifacts artifacts: 'out/collected/release/*', fingerprint: true }
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh 'sh ci/toolchain.sh collect || true'
|
||||
sh 'sh ci/toolchain.sh stop || true'
|
||||
archiveArtifacts artifacts: 'out/actions-run.json,out/collected/test-result.json,out/collected/verified/verified.json', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
SSW590 Member 2 operations — fixture stage
|
||||
|
||||
Starting main SHA: 5373351a7e7ac2bc0f34bae19c25383de3843ca7
|
||||
Branch: feature/final-ci-demo
|
||||
Workspace: /home/codex/ssw590-member2
|
||||
Member 1's earlier uncommitted draft remains in /home/codex/ssw590-final-project.
|
||||
No reviewer/ or tests/smoke_demo.py ownership is assumed here.
|
||||
|
||||
Run local unit checks:
|
||||
python3 -m unittest discover -s ci/tests -v
|
||||
python3 -m unittest discover -s tests -v
|
||||
|
||||
Actions:
|
||||
The final-project workflow runs only on feature/final-ci-demo or
|
||||
final-project-demo. It uses the existing manual-latex label and proven
|
||||
action pins. It runs only simulated review until Member 1 is integrated.
|
||||
Copy the successful full source SHA, numeric Actions run ID and attempt.
|
||||
The name is review-RUN_ID-attempt-ATTEMPT-FULL_SHA.
|
||||
|
||||
Jenkins setup (requires an authenticated administrator):
|
||||
1. Create Pipeline job final-project-fixture.
|
||||
2. Pipeline from SCM: Git, existing public repository URL, branch
|
||||
*/feature/final-ci-demo, Script Path Jenkinsfile.final-project.
|
||||
3. Keep the existing myfileagent-python-ci required check unchanged.
|
||||
4. Create a Secret text credential final-project-gitea-read containing an
|
||||
appropriately scoped Gitea read token. Do not store it in Git or chat.
|
||||
5. Run once to load parameters; then Build with Parameters using the exact
|
||||
successful run SHA/ID/attempt. If branch HEAD has advanced, select the
|
||||
corresponding new successful run (pipeline refuses a checkout mismatch).
|
||||
6. Use the existing assignment8-trusted agent. The job creates a temporary
|
||||
compiler container, network disabled, memory 256 MiB, 0.65 CPU; no
|
||||
Docker socket or secrets are mounted into that compiler container.
|
||||
7. The dedicated Docker volume ssw590-final-project-state retains
|
||||
versions.json and releases/. Do not delete it on cleanup/retry.
|
||||
8. Download the archived out/collected/release/*.zip and companion checksum.
|
||||
Extract freshly, verify every manifest payload hash, inspect PDF identity,
|
||||
and execute python3 reviewed.py (expected hello).
|
||||
|
||||
Version policy:
|
||||
1.0 is a provisional baseline for fixture development, not a team-approved
|
||||
final baseline. State locks serialize allocation across processes. Source
|
||||
SHA and mode select a reservation; model/runtime must be pinned in source
|
||||
before live integration. An unchanged retry reuses original immutable
|
||||
published bytes/identity. Changed reviewed bytes under the same identity
|
||||
fail. Final live baseline/identity must be agreed with Member 1.
|
||||
|
||||
Report builds:
|
||||
Ordinary mode remains: python3 documentation/ci/build_manual.py with the
|
||||
existing GITEA_SHA/RUN_NUMBER/RUN_ID/RUN_ATTEMPT variables.
|
||||
Final mode additionally accepts --review-bundle, --release-version,
|
||||
--jenkins-build and --mode. It validates the bundle before inserting data.
|
||||
Both modes require the pinned TeX image. See ci/toolchain.sh.
|
||||
|
||||
Failure exercises:
|
||||
reviewer_stub.py --case rejected/error produces diagnostics, no reviewed.py.
|
||||
--case runtime produces valid Python that fails execution; hash it normally.
|
||||
For transfer corruption, create/hash a good bundle first, then mutate one
|
||||
payload without updating SHA256SUMS. Validation must fail before TeX.
|
||||
For wrong identity, use a different expected run ID or SHA. Do not publish.
|
||||
Execute deliberate TeX failures only in isolated test copies.
|
||||
Fixture tests never establish real-model accuracy, memory or token evidence.
|
||||
|
||||
Monitoring handoff:
|
||||
ci/final_project.py metrics accepts explicitly live review metadata only.
|
||||
It emits availability gauges, counts when known and a supplied measured
|
||||
completion timestamp, using atomic textfile replacement. Existing Node
|
||||
Exporter textfile collection is not yet enabled by this change. Coordinate
|
||||
paths, mounts and real metric evidence with Member 1 before deployment.
|
||||
|
||||
No paid resizing or production pricing/Zammad deployment is included.
|
||||
@@ -0,0 +1,334 @@
|
||||
"""Exact-bundle validation and immutable release tooling; standard library only."""
|
||||
import argparse
|
||||
import contextlib
|
||||
import fcntl
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib.request
|
||||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BASE = 'https://myfileagent.tech'
|
||||
REPO = 'myfileagent/myfileagent-pipeline'
|
||||
PAYLOAD = {'reviewed.py', 'review.json'}
|
||||
FILES = PAYLOAD | {'bundle.json', 'SHA256SUMS'}
|
||||
MAX_BYTES = 2 * 1024 * 1024
|
||||
|
||||
|
||||
def digest(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def write_json(path, data):
|
||||
path = Path(path)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = path.with_name(path.name + '.tmp')
|
||||
tmp.write_text(json.dumps(data, sort_keys=True, indent=2) + '\n', encoding='utf-8')
|
||||
os.replace(tmp, path)
|
||||
|
||||
|
||||
def identity(sha, run, attempt, mode):
|
||||
if not re.fullmatch('[0-9a-f]{40}', str(sha)):
|
||||
raise ValueError('Expected full lowercase SHA-1 source commit')
|
||||
if any(not re.fullmatch('[1-9][0-9]*', str(x)) for x in (run, attempt)):
|
||||
raise ValueError('Run ID and attempt must be positive integers')
|
||||
if mode not in ('fixture', 'live'):
|
||||
raise ValueError('Explicit fixture/live mode required')
|
||||
return dict(schema_version=1, source_commit=sha, run_id=str(run), attempt=str(attempt), mode=mode)
|
||||
|
||||
|
||||
def bundle_name(meta):
|
||||
return f"review-{meta['run_id']}-attempt-{meta['attempt']}-{meta['source_commit']}"
|
||||
|
||||
|
||||
def review_metadata(raw, expected):
|
||||
data = json.loads(raw)
|
||||
required = {'source_commit', 'model_id', 'status', 'summary', 'diff', 'input_tokens', 'output_tokens'}
|
||||
if not isinstance(data, dict) or not required <= data.keys():
|
||||
raise ValueError('Missing review metadata fields')
|
||||
if data['source_commit'] != expected['source_commit'] or data['status'] not in ('corrected', 'unchanged'):
|
||||
raise ValueError('Review identity/status does not permit a ready bundle')
|
||||
if not all(isinstance(data[x], str) for x in ('summary', 'diff')):
|
||||
raise ValueError('Review summary and diff must be strings')
|
||||
if data.get('mode', expected['mode']) != expected['mode']:
|
||||
raise ValueError('Review mode mismatch')
|
||||
for key in ('input_tokens', 'output_tokens'):
|
||||
value = data[key]
|
||||
if value is not None and (type(value) is not int or value < 0):
|
||||
raise ValueError('Invalid token count')
|
||||
if data['status'] == 'corrected' and (not isinstance(data['model_id'], str) or not data['model_id']):
|
||||
raise ValueError('Corrected review must identify its model')
|
||||
if expected['mode'] == 'fixture' and data['model_id'] != 'fixture-model':
|
||||
raise ValueError('Fixture model ID required')
|
||||
if expected['mode'] == 'live' and data['model_id'] == 'fixture-model':
|
||||
raise ValueError('Fixture data cannot be released in live mode')
|
||||
return data
|
||||
|
||||
|
||||
def zip_bytes(contents):
|
||||
out = io.BytesIO()
|
||||
with zipfile.ZipFile(out, 'w', compression=zipfile.ZIP_DEFLATED) as z:
|
||||
for name, data in sorted(contents.items()):
|
||||
info = zipfile.ZipInfo(name, date_time=(2020, 1, 1, 0, 0, 0))
|
||||
info.compress_type = zipfile.ZIP_DEFLATED
|
||||
info.external_attr = 0o100644 << 16
|
||||
z.writestr(info, data)
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
def create_bundle(review_dir, output, expected):
|
||||
output = Path(output)
|
||||
if output.exists():
|
||||
raise ValueError('Refuse to overwrite a bundle')
|
||||
files = {}
|
||||
for name in PAYLOAD:
|
||||
path = Path(review_dir) / name
|
||||
if path.is_symlink() or not path.is_file() or path.stat().st_size > MAX_BYTES:
|
||||
raise ValueError('Invalid review file')
|
||||
files[name] = path.read_bytes()
|
||||
review_metadata(files['review.json'], expected)
|
||||
files['bundle.json'] = (json.dumps(expected, sort_keys=True)+'\n').encode()
|
||||
files['SHA256SUMS'] = ''.join(f'{digest(files[n])} {n}\n' for n in sorted(PAYLOAD)).encode()
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_bytes(zip_bytes(files))
|
||||
|
||||
|
||||
def read_bundle(path, expected):
|
||||
if Path(path).stat().st_size > MAX_BYTES:
|
||||
raise ValueError('Bundle exceeds size limit')
|
||||
with zipfile.ZipFile(path) as z:
|
||||
entries = z.infolist()
|
||||
if len(entries) != len(FILES) or {i.filename for i in entries} != FILES:
|
||||
raise ValueError('Unexpected, duplicate or missing bundle files')
|
||||
if sum(i.file_size for i in entries) > MAX_BYTES:
|
||||
raise ValueError('Expanded bundle exceeds size limit')
|
||||
for i in entries:
|
||||
kind = stat.S_IFMT(i.external_attr >> 16)
|
||||
if kind not in (0, stat.S_IFREG) or i.flag_bits & 1:
|
||||
raise ValueError('Only unencrypted regular files are allowed')
|
||||
files = {i.filename: z.read(i) for i in entries}
|
||||
if json.loads(files['bundle.json']) != expected:
|
||||
raise ValueError('Bundle SHA/run/attempt/mode mismatch')
|
||||
required = ''.join(f'{digest(files[n])} {n}\n' for n in sorted(PAYLOAD)).encode()
|
||||
if files['SHA256SUMS'] != required:
|
||||
raise ValueError('Payload checksum mismatch')
|
||||
review_metadata(files['review.json'], expected)
|
||||
return files
|
||||
|
||||
|
||||
def verify_bundle(path, destination, expected):
|
||||
files = read_bundle(path, expected)
|
||||
destination = Path(destination)
|
||||
destination.mkdir(parents=True, exist_ok=False)
|
||||
for name, data in files.items():
|
||||
(destination / name).write_bytes(data)
|
||||
write_json(destination / 'verified.json', dict(**expected, bundle_sha256=digest(Path(path).read_bytes())))
|
||||
return files
|
||||
|
||||
|
||||
class SameOrigin(urllib.request.HTTPRedirectHandler):
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
from urllib.parse import urlsplit
|
||||
if urlsplit(newurl).scheme != 'https' or urlsplit(newurl).netloc != 'myfileagent.tech':
|
||||
raise ValueError('Refuse cross-origin artifact redirect')
|
||||
return super().redirect_request(req, fp, code, msg, headers, newurl)
|
||||
|
||||
|
||||
def fetch_bundle(output, expected):
|
||||
token = os.environ.get('GITEA_TOKEN', '')
|
||||
opener = urllib.request.build_opener(SameOrigin())
|
||||
headers = {'Authorization': 'token '+token} if token else {}
|
||||
def get(url, limit):
|
||||
with opener.open(urllib.request.Request(url, headers=headers), timeout=60) as response:
|
||||
raw = response.read(limit+1)
|
||||
if len(raw) > limit:
|
||||
raise ValueError('Response exceeds size limit')
|
||||
return raw
|
||||
# Server-side success is checked independently from client-supplied metadata.
|
||||
run = json.loads(get(f'{BASE}/api/v1/repos/{REPO}/actions/runs/{expected["run_id"]}', MAX_BYTES))
|
||||
if run.get('conclusion') != 'success' or run.get('head_sha') != expected['source_commit']:
|
||||
raise ValueError('Selected Actions run is not successful on the expected SHA')
|
||||
if str(run.get('run_attempt', '1')) != expected['attempt']:
|
||||
raise ValueError('Actions run attempt mismatch')
|
||||
name = bundle_name(expected)
|
||||
raw = get(f'{BASE}/{REPO}/actions/runs/{expected["run_id"]}/artifacts/{name}', MAX_BYTES)
|
||||
# upload-artifact wraps our canonical review-bundle.zip in its own ZIP.
|
||||
with zipfile.ZipFile(io.BytesIO(raw)) as outer:
|
||||
entries = outer.infolist()
|
||||
if len(entries) != 1 or entries[0].filename != 'review-bundle.zip' or entries[0].file_size > MAX_BYTES:
|
||||
raise ValueError('Unexpected Actions artifact wrapper')
|
||||
content = outer.read(entries[0])
|
||||
output = Path(output)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
with output.open('xb') as target:
|
||||
target.write(content)
|
||||
read_bundle(output, expected)
|
||||
return run
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def locked(state):
|
||||
state = Path(state)
|
||||
state.mkdir(parents=True, exist_ok=True)
|
||||
with (state / '.lock').open('a') as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX)
|
||||
yield state
|
||||
|
||||
|
||||
def release_key(meta):
|
||||
# Mode separates simulated and live reservations. Model/runtime must be pinned in the commit.
|
||||
return f"{meta['mode']}:{meta['source_commit']}"
|
||||
|
||||
|
||||
def reserve(state, meta, baseline='1.0'):
|
||||
if not re.fullmatch(r'(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)', baseline):
|
||||
raise ValueError('Baseline must be Major.Minor')
|
||||
with locked(state) as state:
|
||||
path = state / 'versions.json'
|
||||
registry = json.loads(path.read_text()) if path.exists() else {'baseline': baseline, 'next': 1, 'reservations': {}}
|
||||
if registry['baseline'] != baseline:
|
||||
raise ValueError('Baseline differs from durable registry')
|
||||
key = release_key(meta)
|
||||
if key not in registry['reservations']:
|
||||
registry['reservations'][key] = f"{baseline}.{registry['next']}"
|
||||
registry['next'] += 1
|
||||
write_json(path, registry)
|
||||
return registry['reservations'][key]
|
||||
|
||||
|
||||
def smoke(path):
|
||||
run = subprocess.run([sys.executable, str(path)], capture_output=True, text=True, timeout=10)
|
||||
if run.returncode or run.stdout != 'hello\n':
|
||||
raise ValueError('Reviewed-file smoke test failed')
|
||||
|
||||
|
||||
def test_review(verified, receipt):
|
||||
root = Path(verified)
|
||||
subprocess.run([sys.executable, '-m', 'py_compile', str(root / 'reviewed.py')], check=True, timeout=10)
|
||||
# Adopt Member 1's smoke entry point when integrated; retain the independent assertion.
|
||||
member1 = ROOT / 'tests/smoke_demo.py'
|
||||
if member1.exists():
|
||||
subprocess.run([sys.executable, str(member1), str(root/'reviewed.py')], check=True, timeout=20)
|
||||
smoke(root / 'reviewed.py')
|
||||
write_json(receipt, {'reviewed_sha256': digest((root/'reviewed.py').read_bytes()), 'result': 'passed'})
|
||||
|
||||
|
||||
def publish(bundle, expected, pdf, state, output, baseline, jenkins_build):
|
||||
files = read_bundle(bundle, expected)
|
||||
version = reserve(state, expected, baseline)
|
||||
pdf = Path(pdf)
|
||||
from pypdf import PdfReader
|
||||
reader = PdfReader(pdf)
|
||||
text = '\n'.join(p.extract_text() or '' for p in reader.pages)
|
||||
for value in [version, expected['source_commit'], 'Configuring and Running the DevOps Pipeline']:
|
||||
if value not in text:
|
||||
raise ValueError('PDF is missing release identity or final-project chapter')
|
||||
build_meta = json.loads(pdf.with_name('build-manifest.json').read_text())
|
||||
if (build_meta.get('release_version') != version or build_meta.get('commit') != expected['source_commit']
|
||||
or build_meta.get('review_sha256') != digest(files['review.json'])
|
||||
or build_meta.get('reviewed_sha256') != digest(files['reviewed.py'])
|
||||
or build_meta.get('pdf_sha256') != digest(pdf.read_bytes())
|
||||
or build_meta.get('run_id') != expected['run_id'] or build_meta.get('attempt') != expected['attempt']
|
||||
or build_meta.get('mode') != expected['mode']):
|
||||
raise ValueError('Report manifest does not match this verified bundle')
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
candidate = Path(temp)/'reviewed.py'
|
||||
candidate.write_bytes(files['reviewed.py'])
|
||||
smoke(candidate) # Publication cannot bypass the behavior gate.
|
||||
contents = {n: files[n] for n in PAYLOAD}
|
||||
contents[f'report-{version}.pdf'] = pdf.read_bytes()
|
||||
contents['README.txt'] = (f'SSW590 final project {version}\nMode: {expected["mode"]}\n'
|
||||
f'Source: {expected["source_commit"]}\nPython 3 required (tested by CI).\n'
|
||||
'Extract into a fresh directory; run: python3 reviewed.py\nExpected stdout: hello\n'
|
||||
'Compare payload SHA-256 hashes with manifest.json; compare the ZIP with its companion .sha256.\n'
|
||||
'Fixture mode is simulated evidence, not a real AI review.\n').encode()
|
||||
manifest = dict(**expected, version=version, jenkins_build=str(jenkins_build),
|
||||
payload_sha256={n:digest(b) for n,b in sorted(contents.items())})
|
||||
contents['manifest.json'] = (json.dumps(manifest, sort_keys=True, indent=2)+'\n').encode()
|
||||
archive = zip_bytes(contents)
|
||||
name = f'ssw590-{expected["mode"]}-{version}.zip'
|
||||
with locked(state) as state:
|
||||
release = state/'releases'/name
|
||||
release.parent.mkdir(exist_ok=True)
|
||||
if release.exists():
|
||||
# A published version is immutable. A new build identity/PDF cannot silently overwrite it.
|
||||
if release.read_bytes() != archive:
|
||||
previous = release.read_bytes()
|
||||
with zipfile.ZipFile(io.BytesIO(previous)) as z:
|
||||
old_manifest = json.loads(z.read('manifest.json'))
|
||||
if (old_manifest['source_commit'] != expected['source_commit']
|
||||
or old_manifest['mode'] != expected['mode']
|
||||
or any(z.read(n) != files[n] for n in PAYLOAD)):
|
||||
raise ValueError('Version already published with different reviewed payload')
|
||||
archive = previous
|
||||
manifest = old_manifest
|
||||
print('Reusing immutable release and its original build identity', file=sys.stderr)
|
||||
else:
|
||||
tmp = release.with_suffix('.tmp')
|
||||
tmp.write_bytes(archive)
|
||||
os.replace(tmp, release)
|
||||
out = Path(output)
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
(out/name).write_bytes(archive)
|
||||
(out/(name+'.sha256')).write_text(f'{digest(archive)} {name}\n')
|
||||
write_json(out/'release.json', manifest)
|
||||
return name
|
||||
|
||||
|
||||
def metrics(review, output, completed_at):
|
||||
data = json.loads(Path(review).read_text())
|
||||
if data.get('mode') != 'live' or data.get('model_id') == 'fixture-model':
|
||||
raise ValueError('Only explicitly live metadata may emit live metrics')
|
||||
rows = []
|
||||
for key in ('input_tokens', 'output_tokens'):
|
||||
value = data.get(key)
|
||||
known = type(value) is int and value >= 0
|
||||
rows += [f'review_{key}_available{{mode="live"}} {int(known)}']
|
||||
if known:
|
||||
rows += [f'review_{key}{{mode="live"}} {value}']
|
||||
if not re.fullmatch('[0-9]+', str(completed_at)):
|
||||
raise ValueError('Completion timestamp must be measured epoch seconds')
|
||||
rows += [f'review_completed_timestamp_seconds{{mode="live"}} {completed_at}']
|
||||
output = Path(output)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = output.with_suffix('.tmp')
|
||||
tmp.write_text('\n'.join(rows)+'\n')
|
||||
os.replace(tmp, output)
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('action', choices=['bundle','fetch','verify','reserve','test','publish','metrics'])
|
||||
p.add_argument('--sha'); p.add_argument('--run-id'); p.add_argument('--attempt', default='1')
|
||||
p.add_argument('--mode', choices=['fixture','live'], default='fixture')
|
||||
p.add_argument('--review-dir'); p.add_argument('--bundle'); p.add_argument('--output')
|
||||
p.add_argument('--state'); p.add_argument('--baseline', default='1.0'); p.add_argument('--pdf')
|
||||
p.add_argument('--jenkins-build', default='local'); p.add_argument('--completed-at')
|
||||
a = p.parse_args()
|
||||
if a.action == 'test':
|
||||
test_review(a.review_dir, a.output); return
|
||||
if a.action == 'metrics':
|
||||
metrics(a.review_dir+'/review.json', a.output, a.completed_at); return
|
||||
meta = identity(a.sha,a.run_id,a.attempt,a.mode)
|
||||
if a.action == 'bundle': create_bundle(a.review_dir,a.output,meta)
|
||||
elif a.action == 'fetch': print(json.dumps(fetch_bundle(a.output,meta)))
|
||||
elif a.action == 'verify': verify_bundle(a.bundle,a.output,meta)
|
||||
elif a.action == 'reserve': print(reserve(a.state,meta,a.baseline))
|
||||
elif a.action == 'publish': print(publish(a.bundle,meta,a.pdf,a.state,a.output,a.baseline,a.jenkins_build))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except Exception as exc:
|
||||
print(f'Final-project gate failed: {type(exc).__name__}: {exc}', file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
@@ -0,0 +1 @@
|
||||
print("hello"
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Standalone simulated reviewer. Does not import Member 1's code."""
|
||||
import argparse
|
||||
import ast
|
||||
import difflib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('--input', required=True)
|
||||
p.add_argument('--source-commit', required=True)
|
||||
p.add_argument('--out-dir', required=True)
|
||||
p.add_argument('--case', choices=['good', 'rejected', 'error', 'runtime'], default='good')
|
||||
a = p.parse_args()
|
||||
out = Path(a.out_dir)
|
||||
try:
|
||||
out.mkdir(parents=True, exist_ok=False)
|
||||
except OSError:
|
||||
p.exit(3, 'A fresh writable output directory is required\n')
|
||||
data = dict(source_commit=a.source_commit, model_id='fixture-model', mode='fixture',
|
||||
status='error', summary='', diff='', input_tokens=24, output_tokens=8)
|
||||
result = 3
|
||||
try:
|
||||
if not re.fullmatch('[0-9a-f]{40}', a.source_commit):
|
||||
raise ValueError('Full SHA required')
|
||||
source = Path(a.input).read_text(encoding='utf-8')
|
||||
if a.case == 'error':
|
||||
raise RuntimeError('Simulated operational error')
|
||||
if a.case == 'rejected':
|
||||
data.update(status='rejected', summary='Simulated rejected proposal')
|
||||
result = 2
|
||||
else:
|
||||
if a.case == 'runtime':
|
||||
candidate = 'raise RuntimeError("fixture")\n'
|
||||
status = 'corrected'
|
||||
else:
|
||||
try:
|
||||
ast.parse(source)
|
||||
candidate, status = source, 'unchanged'
|
||||
data.update(input_tokens=None, output_tokens=None)
|
||||
except SyntaxError:
|
||||
if source not in ['print("hello"', 'print("hello"\n']:
|
||||
data.update(status='rejected', summary='Unsupported fixture')
|
||||
(out / 'review.json').write_text(json.dumps(data, indent=2)+'\n')
|
||||
return 2
|
||||
candidate = source.rstrip('\n') + ')' + ('\n' if source.endswith('\n') else '')
|
||||
status = 'corrected'
|
||||
data.update(status=status, summary=f'SIMULATED {a.case} fixture; not live AI evidence',
|
||||
diff=''.join(difflib.unified_diff(source.splitlines(True), candidate.splitlines(True),
|
||||
fromfile='original.py', tofile='reviewed.py')))
|
||||
(out / 'reviewed.py').write_text(candidate, encoding='utf-8')
|
||||
result = 0
|
||||
except Exception as exc:
|
||||
data['summary'] = f'Simulated fixture failure: {type(exc).__name__}'
|
||||
(out / 'reviewed.py').unlink(missing_ok=True)
|
||||
(out / 'review.json').write_text(json.dumps(data, indent=2)+'\n', encoding='utf-8')
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,145 @@
|
||||
import concurrent.futures
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
from ci.final_project import identity, create_bundle, read_bundle, verify_bundle, reserve, test_review, metrics, zip_bytes
|
||||
|
||||
SHA = 'a' * 40
|
||||
META = identity(SHA, '1', '1', 'fixture')
|
||||
|
||||
|
||||
def reserve_worker(args):
|
||||
state, sha = args
|
||||
return reserve(state, identity(sha, '1', '1', 'fixture'))
|
||||
|
||||
|
||||
class PipelineTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
self.review = self.root/'review'
|
||||
self.review.mkdir()
|
||||
self.review.joinpath('reviewed.py').write_text('print("hello")\n')
|
||||
self.review.joinpath('review.json').write_text(json.dumps(dict(source_commit=SHA,
|
||||
model_id='fixture-model', mode='fixture', status='corrected', summary='SIMULATED', diff='fixture',
|
||||
input_tokens=24, output_tokens=8)))
|
||||
self.bundle = self.root/'bundle.zip'
|
||||
create_bundle(self.review, self.bundle, META)
|
||||
|
||||
def contents(self):
|
||||
with zipfile.ZipFile(self.bundle) as z:
|
||||
return {n:z.read(n) for n in z.namelist()}
|
||||
|
||||
def test_good_bundle_and_smoke(self):
|
||||
out = self.root/'verified'
|
||||
verify_bundle(self.bundle,out,META)
|
||||
test_review(out,self.root/'tested.json')
|
||||
self.assertEqual(json.loads((self.root/'tested.json').read_text())['result'],'passed')
|
||||
|
||||
def test_tampered_transfer(self):
|
||||
files=self.contents();files['reviewed.py']=b'print("changed")\n'
|
||||
self.bundle.write_bytes(zip_bytes(files))
|
||||
with self.assertRaisesRegex(ValueError,'checksum'):read_bundle(self.bundle,META)
|
||||
|
||||
def test_wrong_identity(self):
|
||||
for key,value in [('source_commit','b'*40),('run_id','2'),('attempt','2'),('mode','live')]:
|
||||
with self.subTest(key=key), self.assertRaisesRegex(ValueError,'mismatch'):
|
||||
read_bundle(self.bundle,{**META,key:value})
|
||||
|
||||
def test_unexpected_paths(self):
|
||||
for name in ['../escape','/absolute','nested/file']:
|
||||
files=self.contents();files[name]=b'bad'
|
||||
path=self.root/'bad.zip';path.write_bytes(zip_bytes(files))
|
||||
with self.subTest(name=name),self.assertRaises(ValueError):read_bundle(path,META)
|
||||
|
||||
def test_duplicate_and_symlink(self):
|
||||
files=self.contents()
|
||||
for kind in ['duplicate','symlink']:
|
||||
out=io.BytesIO()
|
||||
with zipfile.ZipFile(out,'w') as z:
|
||||
for n,b in files.items():
|
||||
info=zipfile.ZipInfo(n)
|
||||
info.external_attr=((stat.S_IFLNK|0o777) if kind=='symlink' and n=='reviewed.py' else 0o100644)<<16
|
||||
z.writestr(info,b)
|
||||
if kind=='duplicate':z.writestr('reviewed.py',b'bad')
|
||||
path=self.root/'bad.zip';path.write_bytes(out.getvalue())
|
||||
with self.subTest(kind=kind),self.assertRaises(ValueError):read_bundle(path,META)
|
||||
|
||||
def test_fresh_output_required(self):
|
||||
out=self.root/'verified';verify_bundle(self.bundle,out,META)
|
||||
with self.assertRaises(FileExistsError):verify_bundle(self.bundle,out,META)
|
||||
|
||||
def test_rejected_not_bundled(self):
|
||||
for status in ['rejected','error']:
|
||||
data=json.loads((self.review/'review.json').read_text());data['status']=status
|
||||
(self.review/'review.json').write_text(json.dumps(data))
|
||||
with self.subTest(status=status),self.assertRaises(ValueError):create_bundle(self.review,self.root/'no.zip',META)
|
||||
self.assertFalse((self.root/'no.zip').exists())
|
||||
|
||||
def test_runtime_failure_reaches_smoke(self):
|
||||
(self.review/'reviewed.py').write_text('raise RuntimeError("fixture")\n')
|
||||
path=self.root/'runtime.zip';create_bundle(self.review,path,META)
|
||||
out=self.root/'runtime';verify_bundle(path,out,META)
|
||||
with self.assertRaisesRegex(ValueError,'smoke'):test_review(out,self.root/'receipt.json')
|
||||
self.assertFalse((self.root/'receipt.json').exists())
|
||||
|
||||
def test_version_retry_and_mode(self):
|
||||
state=self.root/'state'
|
||||
self.assertEqual(reserve(state,META),'1.0.1')
|
||||
self.assertEqual(reserve(state,META),'1.0.1')
|
||||
self.assertEqual(reserve(state,{**META,'mode':'live'}),'1.0.2')
|
||||
with self.assertRaises(ValueError):reserve(state,META,'2.0')
|
||||
|
||||
def test_concurrent_reservation(self):
|
||||
state=str(self.root/'state')
|
||||
with concurrent.futures.ProcessPoolExecutor(max_workers=3) as pool:
|
||||
same=list(pool.map(reserve_worker,[(state,SHA)]*6))
|
||||
other=list(pool.map(reserve_worker,[(state,f'{i:040x}') for i in range(6)]))
|
||||
self.assertEqual(len(set(same)),1)
|
||||
self.assertEqual(len(set(other)),6)
|
||||
self.assertNotIn(same[0],other)
|
||||
|
||||
def test_metrics_reject_fixture(self):
|
||||
with self.assertRaises(ValueError):metrics(self.review/'review.json',self.root/'metrics.prom','123')
|
||||
self.assertFalse((self.root/'metrics.prom').exists())
|
||||
|
||||
def test_missing_live_counts_are_unknown(self):
|
||||
data=json.loads((self.review/'review.json').read_text())
|
||||
data.update(mode='live',model_id='real-model',input_tokens=None,output_tokens=7)
|
||||
(self.review/'review.json').write_text(json.dumps(data))
|
||||
metrics(self.review/'review.json',self.root/'metrics.prom','123')
|
||||
text=(self.root/'metrics.prom').read_text()
|
||||
self.assertIn('review_input_tokens_available{mode="live"} 0',text)
|
||||
self.assertNotIn('review_input_tokens{',text)
|
||||
self.assertIn('review_output_tokens{mode="live"} 7',text)
|
||||
|
||||
def test_fixture_cli_and_source_integrity(self):
|
||||
source=self.root/'source.py';source.write_text('print("hello"\n')
|
||||
before=source.read_bytes()
|
||||
for case,exit_code in [('good',0),('rejected',2),('error',3),('runtime',0)]:
|
||||
out=self.root/case
|
||||
run=subprocess.run([sys.executable,'ci/fixtures/reviewer_stub.py','--input',str(source),
|
||||
'--source-commit',SHA,'--out-dir',str(out),'--case',case],capture_output=True)
|
||||
self.assertEqual(run.returncode,exit_code,run.stderr)
|
||||
self.assertEqual((out/'reviewed.py').exists(),exit_code==0)
|
||||
self.assertEqual(source.read_bytes(),before)
|
||||
|
||||
def test_fixture_unchanged(self):
|
||||
source=self.root/'valid.py';source.write_text('print("hello")\n')
|
||||
out=self.root/'valid'
|
||||
subprocess.run([sys.executable,'ci/fixtures/reviewer_stub.py','--input',str(source),
|
||||
'--source-commit',SHA,'--out-dir',str(out)],check=True)
|
||||
data=json.loads((out/'review.json').read_text())
|
||||
self.assertEqual(data['status'],'unchanged');self.assertEqual(data['diff'],'')
|
||||
self.assertEqual((out/'reviewed.py').read_bytes(),source.read_bytes())
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Called on the existing trusted agent. No host socket/network enters this container.
|
||||
set -eu
|
||||
name="ssw590-final-${BUILD_NUMBER:-local}"
|
||||
image='sha256:579106aaffa81dc2436a72a5dbfc51d3590f1a97646321fd38c694aae6d7cba1'
|
||||
case "$1" in
|
||||
start)
|
||||
docker run -d --name "$name" --network none --memory 256m --memory-swap 256m --cpus .65 --pids-limit 256 \
|
||||
--mount type=volume,src=ssw590-final-project-state,dst=/state \
|
||||
--workdir /work --entrypoint sleep "$image" 3600
|
||||
docker cp . "$name:/work"
|
||||
;;
|
||||
exec) shift; docker exec "$name" "$@" ;;
|
||||
collect) mkdir -p out/collected; docker cp "$name:/work/out/." out/collected/ ;;
|
||||
stop) docker rm -f "$name" ;;
|
||||
*) echo 'Expected start, exec, collect or stop' >&2; exit 2 ;;
|
||||
esac
|
||||
@@ -13,6 +13,9 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import sys
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
from ci.final_project import identity, read_bundle, digest
|
||||
|
||||
|
||||
def build_metadata(sha, run_number, run_id, attempt):
|
||||
@@ -64,6 +67,10 @@ def main():
|
||||
parser.add_argument("--run-number", default=os.environ.get("GITEA_RUN_NUMBER", ""))
|
||||
parser.add_argument("--run-id", default=os.environ.get("GITEA_RUN_ID", ""))
|
||||
parser.add_argument("--attempt", default=os.environ.get("GITEA_RUN_ATTEMPT", "1"))
|
||||
parser.add_argument("--review-bundle")
|
||||
parser.add_argument("--release-version")
|
||||
parser.add_argument("--jenkins-build", default="local")
|
||||
parser.add_argument("--mode", choices=["fixture", "live"], default="fixture")
|
||||
args = parser.parse_args()
|
||||
metadata = build_metadata(args.sha, args.run_number, args.run_id, args.attempt)
|
||||
source = Path(__file__).resolve().parents[1]
|
||||
@@ -74,6 +81,19 @@ def main():
|
||||
if not version_match:
|
||||
raise ValueError("Human-maintained document version is missing")
|
||||
metadata["document_version"] = version_match.group(1)
|
||||
review_files = None
|
||||
if bool(args.review_bundle) != bool(args.release_version):
|
||||
raise ValueError("Review bundle and release version must be supplied together")
|
||||
if args.review_bundle:
|
||||
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", args.release_version):
|
||||
raise ValueError("Major.Minor.Changelist required")
|
||||
if not re.fullmatch(r"[A-Za-z0-9_-]{1,80}", args.jenkins_build):
|
||||
raise ValueError("Invalid Jenkins build identity")
|
||||
review_files = read_bundle(args.review_bundle, identity(args.sha, args.run_id, args.attempt, args.mode))
|
||||
metadata.update(release_version=args.release_version, mode=args.mode,
|
||||
jenkins_build=args.jenkins_build,
|
||||
review_sha256=digest(review_files["review.json"]),
|
||||
reviewed_sha256=digest(review_files["reviewed.py"]))
|
||||
output = source / "build"
|
||||
output.mkdir(exist_ok=True)
|
||||
# Remove only this build's known publish targets, so a failed rebuild cannot
|
||||
@@ -83,7 +103,24 @@ def main():
|
||||
with tempfile.TemporaryDirectory(prefix="manual-ci-") as temp:
|
||||
workspace = Path(temp)
|
||||
copy_sources(source, workspace)
|
||||
(workspace / "build-metadata.tex").write_text(latex_metadata(metadata), encoding="utf-8")
|
||||
generated = latex_metadata(metadata)
|
||||
if review_files:
|
||||
review = json.loads(review_files["review.json"])
|
||||
def tex(value):
|
||||
mapping = {"\\": r"\textbackslash{}", "{": r"\{", "}": r"\}",
|
||||
"_": r"\_", "%": r"\%", "&": r"\&", "#": r"\#", "$": r"\$",
|
||||
"^": r"\textasciicircum{}", "~": r"\textasciitilde{}"}
|
||||
return ''.join(mapping.get(c, c) for c in str(value))
|
||||
fields = {"FinalVersion": args.release_version, "FinalMode": args.mode,
|
||||
"FinalJenkinsBuild": args.jenkins_build, "FinalStatus": review["status"],
|
||||
"FinalModel": review["model_id"], "FinalInputTokens": review["input_tokens"],
|
||||
"FinalOutputTokens": review["output_tokens"]}
|
||||
generated += r"\renewcommand{\DocumentVersion}{" + args.release_version + "}\n"
|
||||
for key, value in fields.items():
|
||||
generated += "\\newcommand{\\" + key + "}{" + tex(value) + "}\n"
|
||||
(workspace / "final-reviewed.txt").write_bytes(review_files["reviewed.py"])
|
||||
(workspace / "final-diff.txt").write_text(review["diff"] or "No changes (unchanged review).", encoding="utf-8")
|
||||
(workspace / "build-metadata.tex").write_text(generated, encoding="utf-8")
|
||||
# Shell escape is needed by the current minted source. Run only trusted
|
||||
# team source in the isolated job, with no host/Docker socket mounts.
|
||||
command = ["latexmk", "-pdf", "-shell-escape", "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", "main.tex"]
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
\bottomrule
|
||||
\endlastfoot
|
||||
|
||||
November 25, 2026 / final-project draft / GDL, CDX & Implement Member 2 independently using fixture review output. & User authorized pipeline implementation on the Droplet. Codex prepared isolated source, failure tests and report integration. Human peer approval and Member 1 model evidence remain separate. \\
|
||||
|
||||
\parbox[t]{2.7cm}{\raggedright November 20, 2026\\ 1.11.1\\ NK, CDX} & Complete browser acceptance and supporting evidence for the Zammad implementation. & Codex corrected scheduler threading and derived search indexes, exercised ticket 71007 through separate TA and Customer browser sessions, captured read-only TA identity/permissions and retained the human-authenticated SSH audit. The team subsequently requested the final TikZ routing, section numbering and draft-text cleanup; these editorial changes and one Gitea manual-only verification build are recorded with version 1.11.1. \\
|
||||
|
||||
\parbox[t]{2.7cm}{\raggedright November 18, 2026\\ 1.11.0\\ NK, CDX} & Implement instruction Chapter 7 with minimal resource use and update the newest team manual source. Consolidated under the first workday; later browser workflow, read-only role/group checks, SSH audit and source reconciliation retain their actual evidence timestamps. & The user authorized SSH through \texttt{ssw590-codex}, selected the newest documentation branch rather than main, deferred its merge, upgraded the Droplet, requested lower service ceilings, approved synthetic accounts and issue 22, and later requested full ongoing documentation with actual screenshots. Codex deployed the official stack, corrected an initially excessive heap and a Puma worker-setting interpretation, staged initialization, added limits and monitoring, tested tickets/customer isolation/TA access and backup/recovery, and retained explicit evidence limits. A recovery collector was corrected to distinguish real scrape timestamps from query times. The user expressly prohibited PDF compilation until a later authorized Jenkins build. \\
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
\chapter{Configuring and Running the DevOps Pipeline}
|
||||
\ChapterLabel{ConfiguringAndRunningDevOpsPipeline}
|
||||
\index{pipeline!AI review}\index{artifact!versioned ZIP}
|
||||
|
||||
\section{Scope and current implementation boundary}
|
||||
This final project extends the existing Gitea, Jenkins, Docker, LaTeX and
|
||||
Prometheus/Grafana infrastructure. A Python syntax error is reviewed, its
|
||||
accepted output is transferred as an exact artifact, a report is built, and
|
||||
the reviewed file is tested before a versioned ZIP is published. The outdated
|
||||
Project Proposal is not the requirements source. This chapter describes the
|
||||
Member 2 implementation; fixture runs are explicitly simulated. A real model,
|
||||
its memory measurement and live token evidence remain Member 1 integration
|
||||
requirements. No fixture proves that a model meets the team's 0.25 GB target.
|
||||
|
||||
\section{Tools and architecture}
|
||||
\begin{tabularx}{\linewidth}{L{3.0cm}Y}
|
||||
\toprule Process & Tool and observable output \\ \midrule
|
||||
Issue tracking & Gitea issue and comments tied to the actual work. \\
|
||||
Source control & Git/Gitea, full source SHA and peer-reviewed changes. \\
|
||||
Forward documentation & LaTeX with the pinned existing compiler image. \\
|
||||
CI/CD & Actions produces the review artifact; Jenkins validates, builds, tests and packages. \\
|
||||
Testing & Python unittest, py\_compile and an execution/output smoke test. \\
|
||||
Deployment & Major.Minor.Changelist ZIP with reviewed code, PDF and manifest. \\
|
||||
Monitoring & Existing Prometheus/Grafana host metrics; live token adapter awaits real results. \\ \bottomrule
|
||||
\end{tabularx}
|
||||
Requirements in the issue map to acceptance checks; design maps to report and
|
||||
integration review; implementation maps to unit/syntax tests; deployment maps
|
||||
to fresh-download verification. These links connect the development and
|
||||
verification sides of the V-Curve.
|
||||
|
||||
\begin{figure}[htbp]\centering
|
||||
\begin{tikzpicture}[node distance=0.7cm, every node/.style={draw,rounded corners,align=center,font=\small,text width=10cm}, arr/.style={-{Stealth},thick}]
|
||||
\node (git) {Gitea issue and source commit};
|
||||
\node[below=of git] (action) {Actions: fixture or real reviewer; exact run/SHA bundle};
|
||||
\node[below=of action] (validate) {Jenkins: authenticated retrieval, identity and checksum validation};
|
||||
\node[below=of validate] (build) {Pinned TeX container: reserve version, compile report, run tests};
|
||||
\node[below=of build] (zip) {Immutable versioned ZIP and independent download verification};
|
||||
\draw[arr] (git)--(action);\draw[arr] (action)--(validate);\draw[arr] (validate)--(build);\draw[arr] (build)--(zip);
|
||||
\end{tikzpicture}
|
||||
\caption{Final-project artifact flow. Host monitoring observes the shared Droplet; it does not attribute every load change to one process.}
|
||||
\end{figure}
|
||||
|
||||
\section{Configuration and reproduction}
|
||||
\path{.gitea/workflows/final-project.yml} restricts execution to the Member 2
|
||||
and demo branches, uses the proven checkout/upload pins and creates a named
|
||||
ready artifact only on a successful review. The simulated input is
|
||||
\path{ci/fixtures/demo_broken.txt}. The standalone stub does not depend on
|
||||
Member 1's package. Corrected/unchanged return zero with two payload files;
|
||||
rejected returns two; operational error returns three and no reviewed file.
|
||||
|
||||
\path{ci/final_project.py} validates a bounded ZIP with exactly four files:
|
||||
\path{reviewed.py}, \path{review.json}, \path{bundle.json} and
|
||||
\path{SHA256SUMS}. It rejects duplicate entries, unexpected paths, special
|
||||
files, bad hashes and wrong SHA/run/attempt/mode before executing the payload.
|
||||
Checksums detect corruption; trusted workflow source and authenticated
|
||||
retrieval establish provenance. The download uses this Gitea server's named
|
||||
legacy artifact route, not an assumed GitHub endpoint.
|
||||
|
||||
\path{Jenkinsfile.final-project} defines separate retrieval, validation,
|
||||
reservation, report, tests and publication stages. Parameters identify the
|
||||
full SHA, Actions run and attempt; no implicit latest bundle is accepted.
|
||||
The current required Python PR check remains unchanged. The trusted agent
|
||||
creates a bounded compiler container without network or Docker socket;
|
||||
source is copied into it explicitly. The dedicated state volume preserves
|
||||
version reservations and immutable release bytes across job retries.
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
python3 -m unittest discover -s ci/tests -v
|
||||
python3 -m unittest discover -s tests -v
|
||||
python3 ci/fixtures/reviewer_stub.py --input ci/fixtures/demo_broken.txt \
|
||||
--source-commit "$SHA" --out-dir out/review
|
||||
python3 ci/final_project.py bundle --review-dir out/review \
|
||||
--sha "$SHA" --run-id "$RUN" --attempt 1 --mode fixture \
|
||||
--output out/review-bundle.zip
|
||||
\end{lstlisting}
|
||||
The operations guide records all subsequent commands and job setup. Output
|
||||
directories must be fresh. Missing counts remain unknown, never zero-filled.
|
||||
|
||||
\section{This build's verified review}
|
||||
\ifdefined\FinalVersion
|
||||
Release \texttt{\FinalVersion}; mode \textbf{\FinalMode}; Jenkins build
|
||||
\texttt{\FinalJenkinsBuild}; review status \texttt{\FinalStatus}. Source
|
||||
and Actions identity appear in this manual's Build Identity page.
|
||||
Model: \texttt{\FinalModel}. Input/output token values:
|
||||
\texttt{\FinalInputTokens}/\texttt{\FinalOutputTokens}.
|
||||
\texttt{None} means unavailable or model not invoked. Fixture counts are
|
||||
simulated and must not appear as live inference evidence.
|
||||
\subsection{Reviewed file}
|
||||
\lstinputlisting[basicstyle=\ttfamily\small,breaklines=true]{final-reviewed.txt}
|
||||
\subsection{Exact review diff}
|
||||
\lstinputlisting[basicstyle=\ttfamily\small,breaklines=true]{final-diff.txt}
|
||||
\else
|
||||
This is an ordinary manual build. No review bundle or release version was
|
||||
injected; do not treat this section as evidence of a live model execution.
|
||||
\fi
|
||||
|
||||
\section{Versioning, tests and publication gates}
|
||||
The durable registry reserves a numeric changelist under a file lock for each
|
||||
source SHA and mode. The provisional release baseline is 1.0. Fixture and
|
||||
live identities are distinct. A retry reuses the reservation; an existing
|
||||
version with different bytes cannot be overwritten. A failed build can leave
|
||||
a sequence gap. The model and runtime configuration must be pinned in source
|
||||
before live release identity is meaningful.
|
||||
|
||||
The report manifest binds source, run/attempt, mode, version, PDF hash and
|
||||
both review payload hashes. Publication verifies that binding and repeats
|
||||
the reviewed-file smoke assertion. A runtime-failure fixture is injected
|
||||
only to test downstream gates; it is not an allowed model correction.
|
||||
The ZIP contains reviewed code, the versioned PDF, review metadata, README
|
||||
and manifest. Payload hashes exclude the manifest itself; a companion digest
|
||||
covers the complete ZIP. Unit tests exercise malicious archives, wrong
|
||||
identity, corruption, runtime failure, mode separation and locked reservation.
|
||||
Build-specific results belong in retained logs, not invented static claims.
|
||||
|
||||
\section{SWOT comparison}
|
||||
\begin{tabularx}{\linewidth}{L{2.0cm}YY}
|
||||
\toprule & Gitea Actions & Jenkins \\ \midrule
|
||||
Strengths & Commit-linked review and existing artifact actions. & Visible gates, trusted agent and flexible packaging. \\
|
||||
Weaknesses & Runner constraints and legacy artifact behavior. & Additional plugin/job state and authentication. \\
|
||||
Opportunities & Automatic review metadata for every selected commit. & Central version allocation and reproducible release evidence. \\
|
||||
Threats & Incompatible action upgrades or expired artifacts. & Wrong-bundle selection, privileged agent misuse and stale output. \\ \bottomrule
|
||||
\end{tabularx}
|
||||
The team-requested AI/human SWOT comparison and measured model rationale
|
||||
will be integrated from Member 1's handoff; this tool comparison does not
|
||||
substitute for that separate work.
|
||||
|
||||
\section{Monitoring, operations and remaining evidence}
|
||||
The live-only metric adapter rejects fixture metadata, exports token counts
|
||||
as gauges, and explicitly reports count availability. A reviewed textfile
|
||||
collector integration and measured real-model samples are required before
|
||||
claiming live token monitoring. Retain samples through the 30-second scrape
|
||||
interval, and show CPU/available memory over one fixed before/during/after
|
||||
window. Existing services share this host; load correlation is not attribution.
|
||||
|
||||
Complete the issue/comment, meaningful commit, trigger, visible build, tests,
|
||||
versioned download, SWOT, configuration, history/link and cloud-load evidence
|
||||
for the ten rubric categories. Optional reverse documentation requires actual
|
||||
code-generated diagrams in the release. This implementation does not claim
|
||||
that bonus. Preserve existing production services and volumes. Cleanup removes
|
||||
only this job's temporary container/workspace; retain the dedicated state
|
||||
volume and release evidence. No paid capacity change is part of this work.
|
||||
@@ -20,6 +20,8 @@
|
||||
\bottomrule
|
||||
\endlastfoot
|
||||
|
||||
November 25, 2026 / final-project draft & GDL, CDX & Implemented Member 2 fixture pipeline, verified bundle contract, version reservation and final-project report mode. Remote CI and live-model integration require observed verification; no fixture is live AI evidence. & \ChapterRef{ConfiguringAndRunningDevOpsPipeline} \\
|
||||
|
||||
November 20, 2026 / 1.11.1 & NK, CDX & Completed TA browser create/assign/internal-note/public-reply/close on ticket 71007, verified Customer visibility, and added Agent-only role/group and privileged SSH audit evidence. Final editorial revision clarifies the vector TikZ diagram, normalizes Chapter 14 numbering and removes the closing draft-status text. & \ChapterRef{SupportTicketManagement}, \AppendixRef{AIPromptLog} \\
|
||||
|
||||
November 18, 2026 / 1.11.0 & NK, CDX & Consolidated assignment entry (first workday; evidence retains actual capture dates). Completed browser workflow and role/group evidence, privileged SSH audit, source publication, Hosts and Bitwarden credential references. Added the Support Ticket Management with Zammad chapter for instruction Chapter 7 / team Assignment 9. Recorded official revision, small per-service limits, upgraded-host observations, private HTTPS networking, synthetic accounts/tickets, least-privilege TA API tests, bidirectional issue 22 linkage, backup and isolated recovery evidence. Added actual screenshots and an explicit required-deliverable gap audit. Updated Hosts, password-store hints and AI log. Source-only draft; no PDF compilation authorized. & \ChapterRef{SupportTicketManagement}, \ChapterRef{Hosts}, \ChapterRef{Passwords} \\
|
||||
|
||||
@@ -160,6 +160,7 @@
|
||||
\include{devopsSREMonitoringReliability}
|
||||
\include{devopsSecureDeliveryRollback}
|
||||
\include{devopsSupportTicketManagement}
|
||||
\include{devopsConfiguringAndRunningDevOpsPipeline}
|
||||
|
||||
\bibliographystyle{IEEEtran}
|
||||
\bibliography{devopsReferences}
|
||||
|
||||
Reference in New Issue
Block a user