Repository navigation
feat(ai): add NVIDIA NIM live proposal conformance #117
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 9 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
40c6e25
docs(ai): design NVIDIA NIM live conformance
seonghobae 086ae5c
docs(ai): plan NVIDIA NIM live conformance
seonghobae a060db7
refactor(ai): share proposal model contract
seonghobae d557427
test(ai): verify shared proposal model contract
seonghobae a6d8761
feat(ai): add bounded live conformance model
seonghobae 1de5a35
test(ai): cover live conformance transport
seonghobae 1053bc9
feat(ai): compose live conformance evidence
seonghobae cf5c17e
test(ai): cover live conformance report
seonghobae 9f1ec1c
feat(ai): add live conformance command
seonghobae 19748de
test(ai): repair live conformance matrix typing
seonghobae 9ed7d6f
test(ai): cover live conformance command
seonghobae 9f13dd4
feat(ai): add live conformance CLI
seonghobae 8709d07
test(ai): cover live conformance CLI
seonghobae dd90463
build(ai): expose live conformance command
seonghobae 101bf36
fix(ai): type atomic live report boundary
seonghobae 13725f7
ci(ai): add hourly NVIDIA NIM conformance
seonghobae 823c76c
test(ai): verify live conformance workflow contract
seonghobae c0c0d8f
ci(ai): format live conformance slice
seonghobae 2702003
style(ai): format live conformance slice
github-actions[bot] 18c90c4
fix(ai): sanitize proposal completion parsing
seonghobae b5cdf5f
ci(ai): repair live conformance verification findings
seonghobae 0f8e954
ci(ai): use structural live conformance repairs
seonghobae 5707335
fix(ci): apply verified live conformance repairs atomically
seonghobae 9eb4d42
fix(ai): execute pinned orchestrator checkout without unpinned install
seonghobae b8a80e9
fix(ci): repair live conformance sources structurally
seonghobae 96adf5f
fix(ci): remove brittle indentation from conformance repair
seonghobae d606e80
ci(ai): centralize deterministic live conformance repair
seonghobae 15def2c
fix(ci): execute reviewed live conformance repair script
seonghobae 8b7db3b
test(ai): cover live conformance production branches
seonghobae 41f99d5
test(ai): eliminate unreachable conformance coverage branches
seonghobae bdae30b
fix(ci): verify complete live conformance coverage
seonghobae 4e08522
test(ai): cover final live conformance branches
seonghobae 4082f8e
fix(ci): verify final live conformance branch evidence
seonghobae dfad1b6
test(ai): cover null live baseline deltas
seonghobae af3f5ce
fix(ci): verify null baseline branch coverage
seonghobae ca365f3
fix(ai): harden live conformance validation
github-actions[bot] e46f4f5
chore(ci): remove temporary live conformance repair workflow
seonghobae 9f5a62b
chore(ci): remove temporary live conformance repair script
seonghobae 59ee586
docs: add executable LifeOS architecture decisions
seonghobae 49161f2
docs: add Claude repository operating contract
seonghobae 034878a
docs: establish repository-wide agent decisions
seonghobae 287ae3e
docs: record NVIDIA NIM live conformance capability
seonghobae 6d6fedf
chore(ai): enforce architecture and live conformance documentation fo…
seonghobae 1b46b39
ci(ai): finalize live conformance architecture evidence
seonghobae 1e8e4e4
docs(ai): finalize live conformance architecture evidence
github-actions[bot] 09662dd
chore(ci): remove temporary live conformance finalizer
seonghobae 0a4694e
ci(ai): stage reviewed live conformance corrections
seonghobae 62c861a
ci(ai): apply reviewed live conformance fixes
seonghobae 94f196c
test(ai): stage complete review-fix branch coverage
seonghobae ce6a8ee
ci(ai): safely apply reviewed live conformance fixes once
seonghobae 59a9edc
ci(ai): streamline one-shot exact-head review repair
seonghobae 7eb9321
ci(ai): execute deterministic review fixes once
seonghobae 723089f
ci(ai): enable pinned Node 24 action runtime
seonghobae 805d88d
ci(ai): apply reviewed fixes through exact-head validation
seonghobae 021bb27
ci(ai): separate workflow-gated review corrections
seonghobae 68570b8
test(ai): enforce live workflow security contracts
seonghobae 8e46e89
ci(ai): isolate non-workflow review corrections
seonghobae 12cdcc8
fix(ai): harden live orchestrator workflow
seonghobae 4501702
chore(ai): remove temporary repair workflow
seonghobae 5cb62ba
chore(ai): remove temporary repair script
seonghobae 56e3f36
chore(ai): remove temporary coverage repair script
seonghobae 64a16e6
ci: remove completed one-shot review repair
seonghobae 4855158
test(ai): cover live orchestration review regressions
seonghobae cb44d2b
fix(ai): validate live orchestration topology and mode
seonghobae ea96039
test(ai): require deeply immutable proposal schema
seonghobae 30239a5
style(ai): format live workflow regression paths
seonghobae b4c18e0
fix(ai): deep-freeze proposal schema contract
seonghobae e500127
test(ai): cover live report baseline and failure classification
seonghobae 9c8becb
fix(ai): preserve live failure and baseline evidence
seonghobae 3b7cf73
test(ai): validate persisted live report before rename
seonghobae 5125b1e
fix(ai): validate persisted live report before publication
seonghobae cfc541d
fix(ai): preserve legacy test seams during persisted validation
seonghobae bf2356c
test(ai): type persisted report read seam explicitly
seonghobae 84069af
docs(ai): identify orchestration evidence publication status
seonghobae b93c58f
docs(ai): include proposal contract test in implementation plan
seonghobae b5feefe
docs(ai): correct orchestration research citations and status
seonghobae 3546ca3
style(ai): format live conformance review tests
seonghobae 30a01e3
style(ai): format live workflow contract
seonghobae 27d226b
style(ai): normalize live conformance regression tests
seonghobae ca505d8
style(ai): normalize live workflow assertions
seonghobae f7e02e1
ci(ai): diagnose exact Prettier output
seonghobae 2dad293
ci(ai): publish exact Prettier diagnostic copies
seonghobae 3f9f3db
test(ai): finalize exact formatted review regressions
seonghobae 8bfdd1a
ci(ai): repair stale live conformance expectation
seonghobae 4ee3a97
fix(ci): target stale live conformance assertion precisely
seonghobae 72f74f9
fix(ci): cover live conformance configuration fallback
seonghobae 60abe10
test(ai): complete live failure classification evidence
github-actions[bot] ba5f363
test(ai): strengthen sanitized configuration fallback evidence
seonghobae 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
562 changes: 562 additions & 0 deletions
562
apps/ai-service/src/contextual-orchestrator-live-model.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
557 changes: 557 additions & 0 deletions
557
apps/ai-service/src/contextual-orchestrator-live-model.ts
Large diffs are not rendered by default.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
apps/ai-service/src/contextual-orchestrator-proposal-contract.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,84 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SCHEMA, | ||
| CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SYSTEM_INSTRUCTION, | ||
| parseContextualOrchestratorProposalCompletion, | ||
| ProposalModelTransportError, | ||
| } from './contextual-orchestrator-proposal-model'; | ||
|
|
||
| /** Wraps one candidate content value in a minimal completion envelope. */ | ||
| function completion(content: unknown): string { | ||
| return JSON.stringify({ | ||
| choices: [{ message: { content } }], | ||
| }); | ||
| } | ||
|
|
||
| describe('shared contextual-orchestrator proposal contract', () => { | ||
| it('keeps the exported instruction inert and treats user data as untrusted', () => { | ||
| expect(CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SYSTEM_INSTRUCTION).toContain( | ||
| 'untrusted data', | ||
| ); | ||
| expect(CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SYSTEM_INSTRUCTION).toContain( | ||
| 'Never execute operations', | ||
| ); | ||
| expect(CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SYSTEM_INSTRUCTION).toContain( | ||
| 'explicit user confirmation', | ||
| ); | ||
| }); | ||
|
|
||
| it('exports one closed schema containing only supported operation families', () => { | ||
| expect(CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SCHEMA).toMatchObject({ | ||
| type: 'object', | ||
| additionalProperties: false, | ||
| required: ['summary', 'rationale', 'operations'], | ||
| }); | ||
| const variants = | ||
| CONTEXTUAL_ORCHESTRATOR_PROPOSAL_SCHEMA.properties.operations.items.oneOf; | ||
| expect(variants).toHaveLength(3); | ||
| expect( | ||
| variants.map((variant) => variant.properties.kind.const), | ||
| ).toEqual(['create_task', 'prioritize_item', 'schedule_item']); | ||
| expect(variants.every((variant) => !variant.additionalProperties)).toBe( | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| it('parses one exact completion envelope into an untrusted proposal draft', () => { | ||
| const draft = { | ||
| summary: 'Review the release candidate.', | ||
| rationale: ['The active task is the current critical path.'], | ||
| operations: [ | ||
| { | ||
| kind: 'create_task', | ||
| description: 'Create a bounded verification task.', | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| expect( | ||
| parseContextualOrchestratorProposalCompletion( | ||
| completion(JSON.stringify(draft)), | ||
| ), | ||
| ).toEqual(draft); | ||
| }); | ||
|
|
||
| it.each([ | ||
| '{', | ||
| 'null', | ||
| '[]', | ||
| '{}', | ||
| JSON.stringify({ choices: [] }), | ||
| JSON.stringify({ choices: [null] }), | ||
| JSON.stringify({ choices: [{}] }), | ||
| JSON.stringify({ choices: [{ message: null }] }), | ||
| completion(undefined), | ||
| completion(' '), | ||
| completion('{'), | ||
| completion('null'), | ||
| completion('[]'), | ||
| ])('fails with the sanitized transport contract for malformed input %#', (text) => { | ||
| expect(() => parseContextualOrchestratorProposalCompletion(text)).toThrow( | ||
| ProposalModelTransportError, | ||
| ); | ||
| }); | ||
| }); |
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,221 @@ | ||
| import { randomUUID } from 'node:crypto'; | ||
| import { | ||
| mkdir, | ||
| rename, | ||
| unlink, | ||
| writeFile, | ||
| } from 'node:fs/promises'; | ||
| import { dirname, resolve } from 'node:path'; | ||
| import { | ||
| runProposalLiveConformance, | ||
| validateProposalLiveConformanceReport, | ||
| type ProposalLiveConformanceOptions, | ||
| type ProposalLiveConformanceReport, | ||
| } from './proposal-quality-live-conformance'; | ||
| import type { ContextualOrchestratorFetch } from './contextual-orchestrator-proposal-model'; | ||
|
|
||
| const MAXIMUM_REPORT_PATH_LENGTH = 4_096; | ||
| const MAXIMUM_MODEL_LIST_LENGTH = 4_096; | ||
| const MAXIMUM_MODELS = 4; | ||
| const MODEL_IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/u; | ||
|
|
||
| /** Bounded environment accepted by the live-conformance command. */ | ||
| export type ProposalLiveCommandEnvironment = Readonly< | ||
| Record<string, string | undefined> | ||
| >; | ||
|
|
||
| /** Narrow file-system seam used for atomic-publication tests. */ | ||
| export interface ProposalLiveCommandFileSystem { | ||
| /** Creates the report directory when absent. */ | ||
| readonly mkdir: typeof mkdir; | ||
| /** Writes the complete temporary report with restrictive permissions. */ | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| readonly writeFile: typeof writeFile; | ||
| /** Atomically replaces the final report after validation. */ | ||
| readonly rename: typeof rename; | ||
| /** Removes incomplete temporary evidence on failure. */ | ||
| readonly unlink: typeof unlink; | ||
| } | ||
|
|
||
| /** Deterministic dependencies used by the command and its tests. */ | ||
| export interface ProposalLiveCommandDependencies { | ||
| readonly fetcher?: ContextualOrchestratorFetch; | ||
| readonly monotonicClock?: () => number; | ||
| readonly evaluationClock?: () => Date; | ||
| readonly uuidFactory?: () => string; | ||
| readonly fileSystem?: ProposalLiveCommandFileSystem; | ||
| readonly runConformance?: typeof runProposalLiveConformance; | ||
| } | ||
|
|
||
| /** Stable command failure that never retains provider, file, or response details. */ | ||
| export class ProposalLiveCommandError extends Error { | ||
| /** Creates one credential-free live-command failure. */ | ||
| constructor() { | ||
| super('Proposal live conformance command failed'); | ||
| this.name = 'ProposalLiveCommandError'; | ||
| } | ||
| } | ||
|
|
||
| /** Raises the stable command failure. */ | ||
| function invalid(): never { | ||
| throw new ProposalLiveCommandError(); | ||
| } | ||
|
|
||
| /** Requires one exact boolean marker. */ | ||
| function enabled(value: string | undefined): boolean { | ||
| return value === 'true'; | ||
| } | ||
|
|
||
| /** Parses a bounded comma-separated explicit model inventory. */ | ||
| export function parseProposalLiveModelInventory( | ||
| value: string | undefined, | ||
| ): readonly string[] { | ||
| if (value === undefined || value.trim() === '') { | ||
| return Object.freeze([]); | ||
| } | ||
| if ( | ||
| value.length > MAXIMUM_MODEL_LIST_LENGTH || | ||
| /[\r\n\u0000]/u.test(value) | ||
| ) { | ||
| return invalid(); | ||
| } | ||
| const models = value.split(',').map((item) => item.trim()); | ||
| if ( | ||
| models.length > MAXIMUM_MODELS || | ||
| models.some( | ||
| (model) => model === '' || !MODEL_IDENTIFIER_PATTERN.test(model), | ||
| ) || | ||
| new Set(models).size !== models.length | ||
| ) { | ||
| return invalid(); | ||
| } | ||
| return Object.freeze(models); | ||
| } | ||
|
|
||
| /** Requires one bounded absolute report path. */ | ||
| function reportPath(value: string | undefined): string { | ||
| if ( | ||
| typeof value !== 'string' || | ||
| value.trim() !== value || | ||
| value === '' || | ||
| value.length > MAXIMUM_REPORT_PATH_LENGTH || | ||
| /[\r\n\u0000]/u.test(value) | ||
| ) { | ||
| return invalid(); | ||
| } | ||
| const absolute = resolve(value); | ||
| if (absolute !== value) { | ||
| return invalid(); | ||
| } | ||
| return absolute; | ||
| } | ||
|
|
||
| /** Creates the complete report options from validated command input. */ | ||
| function conformanceOptions( | ||
| environment: ProposalLiveCommandEnvironment, | ||
| dependencies: ProposalLiveCommandDependencies, | ||
| ): ProposalLiveConformanceOptions { | ||
| const liveEnabled = enabled(environment.AI_NIM_LIVE_CONFORMANCE_ENABLED); | ||
| const providerCredentialAvailable = | ||
| liveEnabled && enabled(environment.NVIDIA_NIM_API_KEY_AVAILABLE); | ||
| return { | ||
| lifeOsCommitSha: environment.LIFE_OS_COMMIT_SHA ?? '', | ||
| contextualOrchestratorCommitSha: | ||
| environment.CONTEXTUAL_ORCHESTRATOR_COMMIT_SHA ?? '', | ||
| modelInventory: liveEnabled | ||
| ? parseProposalLiveModelInventory(environment.NVIDIA_NIM_CHAT_MODELS) | ||
| : Object.freeze([]), | ||
| evaluatedAt: | ||
| dependencies.evaluationClock?.() ?? | ||
| (environment.PROPOSAL_LIVE_EVALUATED_AT | ||
| ? new Date(environment.PROPOSAL_LIVE_EVALUATED_AT) | ||
| : new Date()), | ||
| environment, | ||
| providerCredentialAvailable, | ||
| fetcher: dependencies.fetcher, | ||
| monotonicClock: dependencies.monotonicClock, | ||
| }; | ||
| } | ||
|
|
||
| /** Returns the production file-system implementation. */ | ||
| function productionFileSystem(): ProposalLiveCommandFileSystem { | ||
| return Object.freeze({ mkdir, writeFile, rename, unlink }); | ||
| } | ||
|
|
||
| /** Removes one temporary path while ignoring an absent file only. */ | ||
| async function removeTemporary( | ||
| fileSystem: ProposalLiveCommandFileSystem, | ||
| path: string, | ||
| ): Promise<void> { | ||
| try { | ||
| await fileSystem.unlink(path); | ||
| } catch (error) { | ||
| if ( | ||
| typeof error !== 'object' || | ||
| error === null || | ||
| !('code' in error) || | ||
| error.code !== 'ENOENT' | ||
| ) { | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** Atomically validates and publishes one credential-free JSON report. */ | ||
| export async function publishProposalLiveConformanceReport( | ||
| report: ProposalLiveConformanceReport, | ||
| finalPath: string, | ||
| fileSystem: ProposalLiveCommandFileSystem = productionFileSystem(), | ||
| uuidFactory: () => string = randomUUID, | ||
| ): Promise<void> { | ||
| const validated = validateProposalLiveConformanceReport(report); | ||
| const temporaryPath = `${finalPath}.temporary-${uuidFactory()}`; | ||
| const payload = `${JSON.stringify(validated, null, 2)}\n`; | ||
| await fileSystem.mkdir(dirname(finalPath), { recursive: true }); | ||
| try { | ||
| await fileSystem.writeFile(temporaryPath, payload, { | ||
| encoding: 'utf8', | ||
| mode: 0o600, | ||
| flag: 'wx', | ||
| }); | ||
| const decoded = JSON.parse(payload) as unknown; | ||
| validateProposalLiveConformanceReport(decoded); | ||
| await fileSystem.rename(temporaryPath, finalPath); | ||
| } catch { | ||
| try { | ||
| await removeTemporary(fileSystem, temporaryPath); | ||
| } catch { | ||
| // Cleanup is best-effort; the public error remains credential-free. | ||
| } | ||
| return invalid(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Runs the live conformance matrix or an explicit no-result preflight and | ||
| * atomically publishes only validated credential-free evidence. | ||
| */ | ||
| export async function runProposalQualityLiveCommand( | ||
| environment: ProposalLiveCommandEnvironment = process.env, | ||
| dependencies: ProposalLiveCommandDependencies = {}, | ||
| ): Promise<ProposalLiveConformanceReport> { | ||
| try { | ||
| const finalPath = reportPath(environment.PROPOSAL_LIVE_REPORT_PATH); | ||
| const runConformance = | ||
| dependencies.runConformance ?? runProposalLiveConformance; | ||
| const report = await runConformance( | ||
| conformanceOptions(environment, dependencies), | ||
| ); | ||
| await publishProposalLiveConformanceReport( | ||
| report, | ||
| finalPath, | ||
| dependencies.fileSystem, | ||
| dependencies.uuidFactory, | ||
| ); | ||
| return report; | ||
| } catch (error) { | ||
| if (error instanceof ProposalLiveCommandError) { | ||
| throw error; | ||
| } | ||
| return invalid(); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.