-
Notifications
You must be signed in to change notification settings - Fork 0
Add Factory historian PR reviewer #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { defineReviewAgent, gitHistory, prDiff } from '@agentworkforce/review-kit'; | ||
|
|
||
| /** | ||
| * Factory's maintainability historian, cloud surface. | ||
| * | ||
| * Review-kit owns the shared PR plumbing: event parsing, repository scoping, | ||
| * draft and skip-label gates, checkout execution, output normalization, and | ||
| * once-per-revision delivery. This file declares only the repository-specific | ||
| * review doctrine and evidence. | ||
| * | ||
| * The doctrine lives in the checked-out repository rather than this handler. | ||
| * That keeps the cloud reviewer aligned with Factory's versioned critical-path | ||
| * catalog and lets a charter change take effect without duplicating it here. | ||
| */ | ||
| export default defineReviewAgent({ | ||
| repo: 'AgentWorkforce/factory', | ||
| charter: '.agentworkforce/workforce/personas/maintainability.md', | ||
| lens: 'maintainability', | ||
|
|
||
| // A historian needs both the proposed change and the decisions that produced | ||
| // the current design. The persona therefore requests the complete history. | ||
| evidence: [prDiff(), gitHistory()], | ||
| }); |
46 changes: 46 additions & 0 deletions
46
.agentworkforce/agents/factory-maintainability/persona.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| { | ||
| "id": "factory-maintainability", | ||
| "intent": "review", | ||
| "tags": [ | ||
| "review" | ||
| ], | ||
| "description": "Reviews AgentWorkforce/factory pull requests through the maintainability lens. Comments only; never edits.", | ||
| "cloud": true, | ||
| "sandbox": true, | ||
| "useSubscription": true, | ||
| "capabilities": { | ||
| "pullRequest": { | ||
| "enabled": true, | ||
| "writeback": false, | ||
| "fetchDepth": "full" | ||
| } | ||
| }, | ||
| "integrations": { | ||
| "github": { | ||
| "scope": { | ||
| "repo": "AgentWorkforce/factory" | ||
| }, | ||
| "relayfileMount": { | ||
| "requiredReadPaths": [ | ||
| "/github/repos/AgentWorkforce/factory/issues/**" | ||
| ], | ||
| "writeOnlyPaths": [] | ||
| } | ||
| } | ||
| }, | ||
| "inputs": { | ||
| "SKIP_LABELS": { | ||
| "description": "Comma-separated PR labels that disable the maintainability reviewer.", | ||
| "env": "SKIP_LABELS", | ||
| "optional": true | ||
| } | ||
| }, | ||
| "harness": "claude", | ||
| "model": "claude-opus-4-8", | ||
| "systemPrompt": "You are the maintainability historian for this repository. You review on one axis: whether a future agent can understand and safely change this code. Your operating doctrine is the charter checked into the repo — read it and follow it exactly, including its output contract. Cite git history as evidence. You are read-only: recommend fix direction, never edit.", | ||
| "harnessSettings": { | ||
| "reasoning": "high", | ||
| "timeoutSeconds": 2400 | ||
| }, | ||
| "onEvent": "./agent.ts" | ||
| } |
123 changes: 123 additions & 0 deletions
123
.agentworkforce/agents/factory-maintainability/persona.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| import { readFileSync } from 'node:fs'; | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import agent from './agent.js'; | ||
| import persona from './persona.js'; | ||
|
|
||
| type RelayfileMount = { | ||
| requiredReadPaths: string[]; | ||
| writeOnlyPaths: string[]; | ||
| }; | ||
|
|
||
| type CompiledPersona = { | ||
| id: string; | ||
| capabilities?: { | ||
| pullRequest?: { | ||
| enabled?: boolean; | ||
| writeback?: boolean; | ||
| fetchDepth?: number | 'full'; | ||
| }; | ||
| }; | ||
| integrations: { | ||
| github: { | ||
| scope?: { repo?: string }; | ||
| relayfileMount?: RelayfileMount; | ||
| }; | ||
| }; | ||
| onEvent?: string; | ||
| }; | ||
|
|
||
| const agentworkforceRoot = new URL('../../', import.meta.url); | ||
| const expectedAuthority = '/github/repos/AgentWorkforce/factory/issues/**'; | ||
|
|
||
| function githubMount(value: typeof persona): RelayfileMount { | ||
| const integrations = value.integrations as Record< | ||
| string, | ||
| { relayfileMount?: RelayfileMount } | ||
| >; | ||
| const mount = integrations.github?.relayfileMount; | ||
| expect(mount).toBeDefined(); | ||
| return mount as RelayfileMount; | ||
| } | ||
|
|
||
| function terminalTreeContains(authority: string, path: string): boolean { | ||
| expect(authority).toMatch(/^\/[^*?\[\]{}]+\/\*\*$/u); | ||
| const root = authority.slice(0, -3); | ||
| return path === root || path.startsWith(`${root}/`); | ||
| } | ||
|
|
||
| describe('factory maintainability reviewer contract', () => { | ||
| it('is repository-qualified, read-only, and backed by full git history', () => { | ||
| expect(persona.id).toBe('factory-maintainability'); | ||
| expect(persona.integrations.github.scope).toEqual({ | ||
| repo: 'AgentWorkforce/factory', | ||
| }); | ||
| expect(persona.capabilities.pullRequest).toEqual({ | ||
| enabled: true, | ||
| writeback: false, | ||
| fetchDepth: 'full', | ||
| }); | ||
| expect(persona).not.toHaveProperty('memory'); | ||
| }); | ||
|
|
||
| it('wakes only for Factory PR revisions and carries the issue-comment companion', () => { | ||
| const triggers = agent.triggers as Record< | ||
| string, | ||
| Array<{ on: string; paths?: string[] }> | ||
| >; | ||
| const expectedPaths = [ | ||
| '/github/repos/AgentWorkforce/factory/pulls/**', | ||
| expectedAuthority, | ||
| ]; | ||
|
|
||
| expect(triggers.github).toEqual([ | ||
| { on: 'pull_request.opened', paths: expectedPaths, maxConcurrency: 1 }, | ||
| { on: 'pull_request.synchronize', paths: expectedPaths, maxConcurrency: 1 }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('uses one terminal issue-tree authority for idempotency and review delivery', () => { | ||
| const mount = githubMount(persona); | ||
| expect(mount).toEqual({ | ||
| requiredReadPaths: [expectedAuthority], | ||
| writeOnlyPaths: [], | ||
| }); | ||
|
|
||
| const reviewPath = | ||
| '/github/repos/AgentWorkforce/factory/issues/180/comments/review-maintainability-deadbeef.json'; | ||
| expect(terminalTreeContains(expectedAuthority, reviewPath)).toBe(true); | ||
| expect(new Set([...mount.requiredReadPaths, ...mount.writeOnlyPaths]).size).toBe(1); | ||
| }); | ||
|
|
||
| it('ships a Factory-specific charter and compiled deployment manifest', () => { | ||
| const charter = readFileSync( | ||
| new URL('workforce/personas/maintainability.md', agentworkforceRoot), | ||
| 'utf8', | ||
| ); | ||
| const compiled = JSON.parse( | ||
| readFileSync( | ||
| new URL('agents/factory-maintainability/persona.json', agentworkforceRoot), | ||
| 'utf8', | ||
| ), | ||
| ) as CompiledPersona; | ||
|
|
||
| expect(charter).toContain('# The Factory Maintainability Charter'); | ||
| expect(charter).toContain('.agentworkforce/features/critical-paths.md'); | ||
| expect(charter).not.toContain('HoopSheet'); | ||
| expect(compiled.id).toBe('factory-maintainability'); | ||
| expect(compiled.integrations.github.scope).toEqual({ | ||
| repo: 'AgentWorkforce/factory', | ||
| }); | ||
| expect(compiled.integrations.github.relayfileMount).toEqual({ | ||
| requiredReadPaths: [expectedAuthority], | ||
| writeOnlyPaths: [], | ||
| }); | ||
| expect(compiled.capabilities?.pullRequest).toEqual({ | ||
| enabled: true, | ||
| writeback: false, | ||
| fetchDepth: 'full', | ||
| }); | ||
| expect(compiled.onEvent).toBe('./agent.ts'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { defineReviewPersona } from '@agentworkforce/review-kit'; | ||
|
|
||
| /** | ||
| * Factory's maintainability historian, deployment surface. | ||
| * | ||
| * Review-kit supplies the read-only pull-request capability and exact GitHub | ||
| * trigger paths. GitHub represents PR comments under the issue tree, so the | ||
| * issues mount below is required both for revision idempotency and for posting | ||
| * the review. Pull hydration remains tied to the exact delivered event. | ||
| */ | ||
| const persona = defineReviewPersona({ | ||
| repo: 'AgentWorkforce/factory', | ||
| lens: 'maintainability', | ||
|
|
||
| // Preserve a repository-qualified deployment identity in a workspace that | ||
| // hosts reviewers for multiple projects. | ||
| id: 'factory-maintainability', | ||
|
|
||
| systemPrompt: | ||
| 'You are the maintainability historian for this repository. You review on one axis: whether a future agent can understand and safely change this code. Your operating doctrine is the charter checked into the repo — read it and follow it exactly, including its output contract. Cite git history as evidence. You are read-only: recommend fix direction, never edit.', | ||
|
|
||
| // Foundational safety decisions are older than the default shallow window; | ||
| // silently truncating them would make historical claims unreliable. | ||
| fetchDepth: 'full', | ||
|
|
||
| model: 'claude-opus-4-8', | ||
| harnessSettings: { reasoning: 'high', timeoutSeconds: 2400 }, | ||
| }); | ||
|
|
||
| export default { | ||
| ...persona, | ||
| integrations: { | ||
| ...persona.integrations, | ||
| github: { | ||
| ...persona.integrations.github, | ||
| relayfileMount: { | ||
| requiredReadPaths: ['/github/repos/AgentWorkforce/factory/issues/**'], | ||
| writeOnlyPaths: [], | ||
| }, | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Cover the charter’s bounded output contract.
The verification procedure requires the verdict-first, 150-word, four-finding contract, but this test only checks the title, catalog link, and absence of “HoopSheet.” Add assertions for the required verdict template and bounded-output rules.
🤖 Prompt for AI Agents