diff --git a/.github/workflows/project-inheritance.yml b/.github/workflows/project-inheritance.yml new file mode 100644 index 0000000..df13278 --- /dev/null +++ b/.github/workflows/project-inheritance.yml @@ -0,0 +1,47 @@ +name: project-inheritance + +on: + workflow_dispatch: + schedule: + - cron: '23 9 * * 1' + pull_request: + paths: + - 'scripts/collect-projects.py' + - 'src/data/project-sources.json' + - '.github/workflows/project-inheritance.yml' + +permissions: + contents: read + +jobs: + observe: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Collect public repository observations + env: + GH_TOKEN: ${{ github.token }} + run: python3 scripts/collect-projects.py --output observations/project-observations.json + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - name: Validate observations at the application boundary + env: + STELE_OBSERVATIONS: observations/project-observations.json + run: pnpm exec vitest run src/lib/__tests__/project-observations.test.ts + - name: Record collection scope + run: | + { + echo 'Public repository metadata and revision-pinned source links for philosopher-scribe review.' + echo 'Download the artifact and load project-observations.json in the Collaborator panel.' + echo 'Repository descriptions are author statements. Applying a draft requires session review.' + sha256sum observations/project-observations.json + } >> "$GITHUB_STEP_SUMMARY" + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: stele-project-observations + path: observations/project-observations.json + if-no-files-found: error diff --git a/docs/research/project-inheritance/README.md b/docs/research/project-inheritance/README.md new file mode 100644 index 0000000..0861256 --- /dev/null +++ b/docs/research/project-inheritance/README.md @@ -0,0 +1,62 @@ +# Osmotic project context + +The philosopher-scribe introduced in `42978c5` and narrative export introduced +in `93fd122` provide the session review and export path. This extension supplies +repository observations to that path and distributes the authority lesson from +Stratum ADR-003 and the tor-reference incident in compiled integration context. + +## Refresh and use + +Run `python3 scripts/collect-projects.py` from a checkout with the GitHub CLI +signed in. Collection reads the public repositories listed in +`src/data/project-sources.json`. The output replaces +`src/data/project-observations.json` atomically after all repositories respond. +Review that diff through the normal pull-request process to update the bundled +catalog. Existing IDs continue to select the same projects. + +In Stele, select projects in the rail and open Collaborator. Choose an observed +project, inspect its commit and source links, edit its identity draft, then +apply it to the session. The draft is gated before application and produces a +TSUGI audit event. Narrative export retains the reviewed text and its observed +source citation. All three compilation targets include repository provenance +and reviewed session context. EPOCHÉ continues to replace normal output. + +The optional model-assisted philosopher-scribe receives the bundled structural +context and observations. Calling it requires the existing session API key. +The offline review path works directly from collected repository descriptions. + +## CI + +`project-inheritance.yml` runs weekly, manually and when its collector changes. +It collects public metadata at default-branch revisions, validates the report +through the same application parser and uploads `stele-project-observations`. +Download the artifact, extract `project-observations.json`, and load it through +Collaborator's file input. A scheduled collection becomes available after this +workflow lands on the default branch. + +CI uses read-only repository permissions. It produces a review artifact. Applying +observations to a session and updating the bundled catalog use the review paths +above. Repository descriptions are author statements. Source links and Git blob +identities locate source material but do not prove the descriptions' claims. +The collector records source identities without executing repository code or +reading private repositories. It makes no model calls. + +## Boundaries + +The report schema accepts repository identity, revision, observation time, +description, language and fixed source-file identities. It refuses governance +fields, unknown projects, duplicate projects and source-link substitution. +The existing TOBIRA gate screens description content and edited identity drafts. +Its lexical coverage retains the limitations in the Stele threat model. + +This work leaves existing hard stops and posture as authored configuration. +The five newly registered integration projects have explicit initial posture +choices and empty project-specific hard stops. Their catalog entries require +ongoing review as their repositories evolve. Legacy projects without a configured +source remain authored entries. + +The tor-reference case study and TESTAMENT are first-party incident records. +Their shared-credential and signing observations inform the compiled authority +context. The raw MCP transcripts have not been independently audited here. +Stratum authority-registry design and deployed ingress behavior retain their +recorded implementation boundaries. This refresh does not attest a human act. diff --git a/scripts/collect-projects.py b/scripts/collect-projects.py new file mode 100644 index 0000000..0927485 --- /dev/null +++ b/scripts/collect-projects.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 +"""Collect public repository observations for Stele's philosopher-scribe.""" +import argparse +import hashlib +import json +import os +import re +from pathlib import Path +import subprocess +import tempfile +from datetime import datetime, timezone + +ROOT = Path(__file__).resolve().parents[1] + + +def github(path): + result = subprocess.run(['gh', 'api', path], capture_output=True, text=True) + if result.returncode: + raise RuntimeError('GitHub observation unavailable for ' + path.split('/contents/')[0]) + return json.loads(result.stdout) + + +def collect(): + projects = [] + seen = set() + for target in json.loads((ROOT / 'src/data/project-sources.json').read_text()): + repository = target['repository'] + if not re.fullmatch(r'mazze93/[A-Za-z0-9_.-]+', repository) or target['projectId'] in seen: + raise ValueError('Invalid or repeated project source') + seen.add(target['projectId']) + metadata = github('repos/' + repository) + if metadata['visibility'] != 'public': + raise ValueError('Only public repositories may enter the distributed catalog') + commit = github('repos/' + repository + '/commits/' + metadata['default_branch']) + sha = commit['sha'] + tree = github('repos/' + repository + '/git/trees/' + commit['commit']['tree']['sha']) + files = {entry['path']: entry for entry in tree['tree'] if entry['type'] == 'blob'} + sources = [] + for name in ['README.md', 'CLAUDE.md', 'AGENTS.md', 'package.json', 'pyproject.toml', 'Cargo.toml', 'Package.swift', 'AUTHORITY.md']: + if name in files: + sources.append({'path': name, 'gitBlob': files[name]['sha'], + 'url': 'https://github.com/' + repository + '/blob/' + sha + '/' + name}) + observation = { + 'projectId': target['projectId'], 'repository': repository, + 'commit': sha, 'observedAt': datetime.now(timezone.utc).isoformat(), + 'description': metadata['description'] or '', + 'language': metadata['language'] or 'Unspecified', + 'sources': sources, + } + projects.append(observation) + return {'schemaVersion': 1, 'kind': 'stele-project-observations', 'projects': projects} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--output', type=Path, default=ROOT / 'src/data/project-observations.json') + args = parser.parse_args() + report = collect() # Fetch everything before replacing the last complete snapshot. + args.output.parent.mkdir(parents=True, exist_ok=True) + content = json.dumps(report, ensure_ascii=False, indent=2) + '\n' + with tempfile.NamedTemporaryFile(mode='w', dir=args.output.parent, delete=False) as stream: + stream.write(content) + temporary = stream.name + os.replace(temporary, args.output) + print(f"Observed {len(report['projects'])} public repositories; sha256 {hashlib.sha256(content.encode()).hexdigest()}") + + +if __name__ == '__main__': + main() diff --git a/src/components/panels/CollaboratorPanel.tsx b/src/components/panels/CollaboratorPanel.tsx index a357570..b895aed 100644 --- a/src/components/panels/CollaboratorPanel.tsx +++ b/src/components/panels/CollaboratorPanel.tsx @@ -1,3 +1,4 @@ +import { ProjectObservationPanel } from './ProjectObservationPanel' import { useState } from 'react' import type { DirectiveState } from '@/lib/types' import type { IntegrityState } from '@/lib/integrity' @@ -30,7 +31,18 @@ type Props = { onAuditEntry: (action: AuditAction, extras?: AuditExtras) => void } -export function CollaboratorPanel({ +export function CollaboratorPanel(props: Props) { + return
+ { + props.onApplyNarrative(projectId, narrative) + props.onAuditEntry('tsugi-applied', { fieldsExtracted: ['identity'] }) + }} /> +

Optional model-assisted narrative

+ +
+} + +function ModelCollaboratorPanel({ state, integrityState, apiKey, onSetApiKey, onGateResult, onApplyNarrative, onAuditEntry, }: Props) { const activeProjects = PROJECTS.filter(p => state.activeProjectIds.includes(p.id)) @@ -112,6 +124,7 @@ export function CollaboratorPanel({ compliance: selectedProject.compliance, tesserae: (selectedProject.tesserae ?? []).map(t => ({ module: t.module, missingHalf: t.missingHalf, group: t.group })), openQuestions: selectedProject.openQuestions, + observation: selectedProject.observation, }) const result = gate(serialized) @@ -133,6 +146,7 @@ export function CollaboratorPanel({ hardStops: selectedProject.hardStops, tesserae: (selectedProject.tesserae ?? []).map(t => ({ module: t.module, missingHalf: t.missingHalf, group: t.group })), openQuestions: selectedProject.openQuestions, + observation: selectedProject.observation, } try { @@ -159,6 +173,13 @@ export function CollaboratorPanel({ buildSequencing: fields.buildSequencing, unstatedConstraints: fields.unstatedConstraints, } + const result = gate(JSON.stringify(narrative)) + setGateResult(result) + onGateResult(result) + if (result.blocked) { + setStatus('blocked') + return + } onApplyNarrative(selectedId, narrative) onAuditEntry('tsugi-applied', { fieldsExtracted: ['identity', 'philosophy', 'buildSequencing', 'unstatedConstraints'] }) setStatus('applied') diff --git a/src/components/panels/ProjectObservationPanel.tsx b/src/components/panels/ProjectObservationPanel.tsx new file mode 100644 index 0000000..d8bc8a1 --- /dev/null +++ b/src/components/panels/ProjectObservationPanel.tsx @@ -0,0 +1,89 @@ +import { useState } from 'react' +import type { DirectiveState } from '@/lib/types' +import type { NarrativeFields } from '@/lib/extractor' +import { gate } from '@/lib/security' +import type { GateResult } from '@/lib/security' +import { INTEGRITY_STATES } from '@/lib/integrity' +import { parseProjectObservations } from '@/lib/project-observations' +import type { ProjectObservation } from '@/lib/project-observations' +import report from '@/data/project-observations.json' +import { buildProjectNarrativeExport, downloadNarrativeExport } from '@/lib/narrativeExport' +import { PROJECTS } from '@/data/projects' + +const bundled = parseProjectObservations(JSON.stringify(report)) + +type Props = { + state: DirectiveState + onGateResult: (result: GateResult) => void + onApply: (projectId: string, narrative: NarrativeFields) => void +} + +export function ProjectObservationPanel({ state, onApply, onGateResult }: Props) { + const [observations, setObservations] = useState(bundled) + const [selected, setSelected] = useState(null) + const [draft, setDraft] = useState('') + const [message, setMessage] = useState('') + const active = observations.filter(project => state.activeProjectIds.includes(project.projectId)) + const allowed = INTEGRITY_STATES[state.integrityState].allowsPatchApplication + + async function load(file: File | undefined) { + if (!file) return + try { + if (file.size > 100_000) throw new Error('Observation file exceeds 100,000 bytes') + const next = parseProjectObservations(await file.text()) + setObservations(next) + setSelected(null) + setDraft('') + setMessage('Repository observations loaded for review.') + } catch { + setMessage('KIRI — observation file rejected. Use an unmodified Stele CI observation artifact.') + } + } + + function review(observation: ProjectObservation) { + setSelected(observation) + setDraft(observation.description) + setMessage('') + } + + function apply() { + if (!selected || !allowed || !state.activeProjectIds.includes(selected.projectId)) return + const result = gate(draft) + onGateResult(result) + if (result.blocked) { + setMessage('KIRI — TOBIRA blocked the identity draft.') + return + } + const project = PROJECTS.find(item => item.id === selected.projectId) + if (!project) return + const current = state.projectNarratives[selected.projectId] + onApply(project.id, { + identity: `${draft}\n\nRepository description observed ${selected.observedAt} at https://github.com/${selected.repository}/tree/${selected.commit}. Session-applied identity draft.`, + philosophy: current?.philosophy ?? project.philosophy ?? '', + buildSequencing: current?.buildSequencing ?? project.buildSequencing ?? '', + unstatedConstraints: current?.unstatedConstraints ?? project.unstatedConstraints ?? '', + }) + setMessage('TSUGI — reviewed identity applied to this session. Export the narrative to retain it.') + } + + return
+

Osmotic project context

+

Review revision-pinned repository observations before applying an identity draft. Repository descriptions are author statements. The recorded commit identifies the observed source.

+ + {active.length === 0 &&

Select a project in Config to review its repository context.

} +
{active.map(item => )}
+ {selected &&
+

{selected.repository} · {selected.language}

+

Observed {selected.observedAt} · {selected.commit.slice(0, 12)}

+ +