@sushanglewis/lincoln 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +3 -0
- package/dist/main.js +1231 -906
- package/dist/main.js.map +1 -1
- package/dist/postinstall.d.ts +3 -0
- package/dist/postinstall.js +18 -0
- package/dist/postinstall.js.map +1 -0
- package/framework/.claude/agents/_contract.md +79 -0
- package/framework/.claude/agents/architect.md +31 -0
- package/framework/.claude/agents/default.md +151 -0
- package/framework/.claude/agents/designer.md +33 -0
- package/framework/.claude/agents/engineer.md +42 -0
- package/framework/.claude/agents/external/NOTICES.md +12 -0
- package/framework/.claude/agents/external/everything-claude-code.manifest.yaml +23 -0
- package/framework/.claude/agents/external/oh-my-claudecode.manifest.yaml +26 -0
- package/framework/.claude/agents/external/wshobson-agents.manifest.yaml +23 -0
- package/framework/.claude/agents/frontend-engineer.md +32 -0
- package/framework/.claude/agents/knowledge-curator.md +28 -0
- package/framework/.claude/agents/pm.md +38 -0
- package/framework/.claude/agents/qa.md +28 -0
- package/framework/.claude/agents/release-coordinator.md +25 -0
- package/framework/.claude/agents/researcher.md +41 -0
- package/framework/.claude/harnesses/claude-code.yaml +15 -0
- package/framework/.claude/harnesses/codex.yaml +40 -0
- package/framework/.claude/harnesses/command-map.yaml +255 -0
- package/framework/.claude/harnesses/opencode.yaml +32 -0
- package/framework/.claude/harnesses/scenarios.yaml +45 -0
- package/framework/.claude/hooks/on-pr-event.sh +69 -0
- package/framework/.claude/hooks/on-session-start.sh +427 -0
- package/framework/.claude/hooks/on-stop.sh +104 -0
- package/framework/.claude/hooks/post-tool-use.sh +161 -0
- package/framework/.claude/hooks/pre-tool-use.sh +246 -0
- package/framework/.claude/schemas/agent-definition.schema.json +35 -0
- package/framework/.claude/schemas/benchmark-report.schema.json +148 -0
- package/framework/.claude/schemas/pm-to-ux-handoff.schema.yaml +128 -0
- package/framework/.claude/schemas/stage-definition.schema.json +233 -0
- package/framework/.claude/schemas/workflow-stage.schema.json +86 -0
- package/framework/.claude/schemas/workflow-template.schema.json +88 -0
- package/framework/.claude/settings.json +14 -0
- package/framework/.claude/skills/build-product-prototype/SKILL.md +35 -0
- package/framework/.claude/skills/build-product-prototype/prompts/main.md +78 -0
- package/framework/.claude/skills/clarify-requirements/SKILL.md +32 -0
- package/framework/.claude/skills/clarify-requirements/prompts/main.md +81 -0
- package/framework/.claude/skills/dependencies.yaml +139 -0
- package/framework/.claude/skills/draft-product-design/SKILL.md +40 -0
- package/framework/.claude/skills/draft-product-design/prompts/main.md +47 -0
- package/framework/.claude/skills/lc-analyze-frameworks/SKILL.md +43 -0
- package/framework/.claude/skills/lc-analyze-frameworks/prompts/main.md +95 -0
- package/framework/.claude/skills/lc-benchmark/SKILL.md +61 -0
- package/framework/.claude/skills/lc-build-codebase-knowledge/SKILL.md +38 -0
- package/framework/.claude/skills/lc-build-codebase-knowledge/prompts/build-codebase-knowledge.md +61 -0
- package/framework/.claude/skills/lc-collect-intelligence/SKILL.md +43 -0
- package/framework/.claude/skills/lc-collect-intelligence/prompts/main.md +72 -0
- package/framework/.claude/skills/lc-competitive-analysis/SKILL.md +43 -0
- package/framework/.claude/skills/lc-competitive-analysis/prompts/main.md +70 -0
- package/framework/.claude/skills/lc-explore-opensource/SKILL.md +36 -0
- package/framework/.claude/skills/lc-explore-opensource/prompts/explore-opensource.md +77 -0
- package/framework/.claude/skills/lc-first-principles/SKILL.md +43 -0
- package/framework/.claude/skills/lc-first-principles/prompts/main.md +73 -0
- package/framework/.claude/skills/lc-handoff/SKILL.md +34 -0
- package/framework/.claude/skills/lc-init-branch/SKILL.md +52 -0
- package/framework/.claude/skills/lc-market-research/SKILL.md +43 -0
- package/framework/.claude/skills/lc-market-research/prompts/main.md +79 -0
- package/framework/.claude/skills/lc-product-research/SKILL.md +43 -0
- package/framework/.claude/skills/lc-product-research/prompts/main.md +80 -0
- package/framework/.claude/skills/lc-research-report/SKILL.md +43 -0
- package/framework/.claude/skills/lc-research-report/prompts/main.md +90 -0
- package/framework/.claude/skills/lc-research-scope/SKILL.md +43 -0
- package/framework/.claude/skills/lc-research-scope/prompts/main.md +82 -0
- package/framework/.claude/skills/lc-setup/SKILL.md +68 -0
- package/framework/.claude/skills/lc-setup/prompts/main.md +88 -0
- package/framework/.claude/skills/lc-stage/SKILL.md +45 -0
- package/framework/.claude/skills/lc-stakeholder-research/SKILL.md +43 -0
- package/framework/.claude/skills/lc-stakeholder-research/prompts/main.md +65 -0
- package/framework/.claude/skills/lc-status/SKILL.md +25 -0
- package/framework/.claude/skills/lc-storytelling/SKILL.md +43 -0
- package/framework/.claude/skills/lc-storytelling/prompts/main.md +77 -0
- package/framework/.claude/skills/lc-wf/SKILL.md +54 -0
- package/framework/.claude/skills/lc-workflow/SKILL.md +48 -0
- package/framework/.claude/skills/lc-workflow/validators/validate.py +755 -0
- package/framework/.claude/skills/lc-workflow-router/SKILL.md +41 -0
- package/framework/.claude/skills/lc-workflow-router/prompts/intake-prompt.md +91 -0
- package/framework/.claude/skills/lc-workflow-router/prompts/router-prompt.md +44 -0
- package/framework/.claude/skills/plan-tdd-development/SKILL.md +31 -0
- package/framework/.claude/skills/plan-tdd-development/prompts/main.md +44 -0
- package/framework/.claude/skills/process-interview/SKILL.md +32 -0
- package/framework/.claude/skills/process-interview/prompts/main.md +47 -0
- package/framework/.claude/skills/propose-with-openspec/SKILL.md +37 -0
- package/framework/.claude/skills/propose-with-openspec/prompts/main.md +53 -0
- package/framework/.claude/skills/split-to-github/SKILL.md +32 -0
- package/framework/.claude/skills/split-to-github/prompts/main.md +42 -0
- package/framework/.claude/skills/sync-to-knowledge/SKILL.md +35 -0
- package/framework/.claude/skills/sync-to-knowledge/prompts/main.md +54 -0
- package/framework/.claude/skills/workflow-continue/SKILL.md +24 -0
- package/framework/.claude/skills/workflow-continue/prompts/main.md +25 -0
- package/framework/.claude/stages/build-codebase-knowledge.yaml +42 -0
- package/framework/.claude/stages/clarify.yaml +59 -0
- package/framework/.claude/stages/explore-opensource.yaml +40 -0
- package/framework/.claude/stages/implement.yaml +60 -0
- package/framework/.claude/stages/ingest.yaml +40 -0
- package/framework/.claude/stages/lc-analyze-frameworks.yaml +37 -0
- package/framework/.claude/stages/lc-collect-intelligence.yaml +37 -0
- package/framework/.claude/stages/lc-competitive-analysis.yaml +37 -0
- package/framework/.claude/stages/lc-first-principles.yaml +37 -0
- package/framework/.claude/stages/lc-market-research.yaml +37 -0
- package/framework/.claude/stages/lc-product-research.yaml +37 -0
- package/framework/.claude/stages/lc-research-report.yaml +38 -0
- package/framework/.claude/stages/lc-research-scope.yaml +38 -0
- package/framework/.claude/stages/lc-stakeholder-research.yaml +37 -0
- package/framework/.claude/stages/lc-storytelling.yaml +37 -0
- package/framework/.claude/stages/product-design-docs.yaml +66 -0
- package/framework/.claude/stages/product-prototype.yaml +53 -0
- package/framework/.claude/stages/propose.yaml +45 -0
- package/framework/.claude/stages/split.yaml +41 -0
- package/framework/.claude/stages/sync-knowledge.yaml +49 -0
- package/framework/.claude/stages/tdd-development-plan.yaml +43 -0
- package/framework/.claude/stages/workflow-router.yaml +45 -0
- package/framework/.claude/templates/solo-workflow-context.yaml +23 -0
- package/framework/.claude/workflows/README.md +93 -0
- package/framework/.claude/workflows/bug-fix.yaml +81 -0
- package/framework/.claude/workflows/design-spike.yaml +55 -0
- package/framework/.claude/workflows/existing-project-iteration.yaml +106 -0
- package/framework/.claude/workflows/interview-to-knowledge.yaml +189 -0
- package/framework/.claude/workflows/oss-first-design.yaml +100 -0
- package/framework/.claude/workflows/pm-research.yaml +115 -0
- package/framework/.claude-plugin/hooks.json +6 -0
- package/framework/.claude-plugin/marketplace.json +32 -0
- package/framework/.claude-plugin/plugin.json +57 -0
- package/framework/.version-bump.json +43 -0
- package/framework/CLAUDE.md +140 -0
- package/framework/CONTRIBUTING.md +219 -0
- package/framework/LICENSE +21 -0
- package/framework/README.en.md +139 -0
- package/framework/README.md +139 -0
- package/framework/RELEASE.md +334 -0
- package/framework/SKILL.md +24 -0
- package/framework/USAGE.md +356 -0
- package/framework/manifest.json +1214 -0
- package/framework/requirements.txt +4 -0
- package/framework/scripts/__init__.py +0 -0
- package/framework/scripts/build_codebase_knowledge.py +76 -0
- package/framework/scripts/bump_version.py +181 -0
- package/framework/scripts/check-dependency-drift.py +69 -0
- package/framework/scripts/check-harness-drift.sh +57 -0
- package/framework/scripts/check-main-merge-hygiene.py +128 -0
- package/framework/scripts/check-skill-dependencies.sh +124 -0
- package/framework/scripts/init-lincoln-branch.sh +300 -0
- package/framework/scripts/init-project.sh +184 -0
- package/framework/scripts/lc-benchmark-cli.py +66 -0
- package/framework/scripts/lincoln-audit.py +288 -0
- package/framework/scripts/lincoln-setup.py +651 -0
- package/framework/scripts/lincoln-status.py +448 -0
- package/framework/scripts/lincoln_benchmark.py +224 -0
- package/framework/scripts/lincoln_benchmark_eval.py +104 -0
- package/framework/scripts/lincoln_benchmark_metrics.py +818 -0
- package/framework/scripts/lincoln_benchmark_report.py +141 -0
- package/framework/scripts/lincoln_command_map.py +289 -0
- package/framework/scripts/lincoln_dependency_manager.py +335 -0
- package/framework/scripts/lincoln_documents.py +175 -0
- package/framework/scripts/lincoln_harness_adapter.py +319 -0
- package/framework/scripts/lincoln_index.py +255 -0
- package/framework/scripts/lincoln_paths.py +198 -0
- package/framework/scripts/lincoln_prd.py +227 -0
- package/framework/scripts/lincoln_role.py +46 -0
- package/framework/scripts/lincoln_scenario.py +59 -0
- package/framework/scripts/lincoln_session_start_metrics.py +71 -0
- package/framework/scripts/lincoln_skill_prompt.py +48 -0
- package/framework/scripts/lincoln_trace.py +335 -0
- package/framework/scripts/lincoln_workflow.py +199 -0
- package/framework/scripts/list-active-lincoln-branches.sh +87 -0
- package/framework/scripts/package-lincoln-plugin.py +340 -0
- package/framework/scripts/run-infrastructure-tests.py +84 -0
- package/framework/scripts/stage_loader.py +1071 -0
- package/framework/scripts/static-check.sh +356 -0
- package/framework/scripts/sync-external-agents.sh +210 -0
- package/framework/scripts/sync-framework-package.mjs +218 -0
- package/framework/scripts/task_tool_guard.py +213 -0
- package/framework/scripts/track-artifacts.py +140 -0
- package/framework/scripts/validate_stage.py +350 -0
- package/{README.md → framework/tools/lincoln/README.md} +4 -4
- package/framework/tools/lincoln/package-lock.json +3349 -0
- package/framework/tools/lincoln/package.json +48 -0
- package/framework/tools/lincoln/src/cli.tsx +60 -0
- package/framework/tools/lincoln/src/components/AudioMeter.tsx +34 -0
- package/framework/tools/lincoln/src/components/CancelledScreen.tsx +11 -0
- package/framework/tools/lincoln/src/components/DevicesMenu.tsx +79 -0
- package/framework/tools/lincoln/src/components/HintBar.tsx +25 -0
- package/framework/tools/lincoln/src/components/LogView.tsx +36 -0
- package/framework/tools/lincoln/src/components/ModelMenu.tsx +122 -0
- package/framework/tools/lincoln/src/components/ReadyScreen.tsx +54 -0
- package/framework/tools/lincoln/src/components/RecordingApp.tsx +211 -0
- package/framework/tools/lincoln/src/components/RecordingScreen.tsx +41 -0
- package/framework/tools/lincoln/src/components/SelectMenu.tsx +53 -0
- package/framework/tools/lincoln/src/components/StatusPanel.tsx +52 -0
- package/framework/tools/lincoln/src/components/StopConfirmation.tsx +32 -0
- package/framework/tools/lincoln/src/config/args.ts +35 -0
- package/framework/tools/lincoln/src/config/loadConfig.ts +81 -0
- package/framework/tools/lincoln/src/config/resolveConfig.ts +85 -0
- package/framework/tools/lincoln/src/devices/listDevices.ts +11 -0
- package/framework/tools/lincoln/src/devices/parseDevices.ts +25 -0
- package/framework/tools/lincoln/src/hooks/useKeyHandler.ts +63 -0
- package/framework/tools/lincoln/src/main.tsx +4 -0
- package/framework/tools/lincoln/src/models/models.ts +34 -0
- package/framework/tools/lincoln/src/models/runWarmup.ts +46 -0
- package/framework/tools/lincoln/src/models/warmupProgress.ts +30 -0
- package/framework/tools/lincoln/src/recording/spawnRecorder.ts +127 -0
- package/framework/tools/lincoln/src/recording/useRecorder.ts +146 -0
- package/framework/tools/lincoln/src/utils/amplitudeToMeter.ts +4 -0
- package/framework/tools/lincoln/src/utils/formatDuration.ts +6 -0
- package/framework/tools/lincoln/src/utils/sessionId.ts +25 -0
- package/framework/tools/lincoln/tests/cli.test.tsx +52 -0
- package/framework/tools/lincoln/tests/components/AudioMeter.test.tsx +31 -0
- package/framework/tools/lincoln/tests/components/CancelledScreen.test.tsx +12 -0
- package/framework/tools/lincoln/tests/components/ReadyScreen.test.tsx +68 -0
- package/framework/tools/lincoln/tests/components/RecordingApp.menus.test.tsx +158 -0
- package/framework/tools/lincoln/tests/components/RecordingApp.test.tsx +248 -0
- package/framework/tools/lincoln/tests/components/RecordingScreen.test.tsx +37 -0
- package/framework/tools/lincoln/tests/components/SelectMenu.test.tsx +59 -0
- package/framework/tools/lincoln/tests/components/StopConfirmation.test.tsx +38 -0
- package/framework/tools/lincoln/tests/config/args.test.ts +49 -0
- package/framework/tools/lincoln/tests/config/loadConfig.test.ts +59 -0
- package/framework/tools/lincoln/tests/config/resolveConfig.test.ts +72 -0
- package/framework/tools/lincoln/tests/devices/parseDevices.test.ts +21 -0
- package/framework/tools/lincoln/tests/hooks/useKeyHandler.enabled.test.tsx +44 -0
- package/framework/tools/lincoln/tests/hooks/useKeyHandler.test.tsx +130 -0
- package/framework/tools/lincoln/tests/models/models.test.ts +27 -0
- package/framework/tools/lincoln/tests/models/warmupProgress.test.ts +25 -0
- package/framework/tools/lincoln/tests/recording/spawnRecorder.test.ts +85 -0
- package/framework/tools/lincoln/tests/recording/useRecorder.test.tsx +172 -0
- package/framework/tools/lincoln/tests/utils/amplitudeToMeter.test.ts +22 -0
- package/framework/tools/lincoln/tests/utils/formatDuration.test.ts +11 -0
- package/framework/tools/lincoln/tests/utils/sessionId.test.ts +30 -0
- package/framework/tools/lincoln/tsconfig.json +22 -0
- package/framework/tools/lincoln/tsconfig.tests.json +10 -0
- package/framework/tools/lincoln/tsup.config.ts +17 -0
- package/framework/tools/lincoln/vitest.config.ts +20 -0
- package/framework/tools/lincoln-installer/package-lock.json +3611 -0
- package/framework/tools/lincoln-installer/package.json +53 -0
- package/framework/tools/lincoln-installer/src/cli.tsx +63 -0
- package/framework/tools/lincoln-installer/src/components/HarnessSelectScreen.tsx +43 -0
- package/framework/tools/lincoln-installer/src/components/InstallerApp.tsx +98 -0
- package/framework/tools/lincoln-installer/src/components/OptionsScreen.tsx +56 -0
- package/framework/tools/lincoln-installer/src/components/ProgressScreen.tsx +25 -0
- package/framework/tools/lincoln-installer/src/components/ResultScreen.tsx +40 -0
- package/framework/tools/lincoln-installer/src/components/SelectMenu.tsx +73 -0
- package/framework/tools/lincoln-installer/src/components/SummaryScreen.tsx +49 -0
- package/framework/tools/lincoln-installer/src/components/UpdateApp.tsx +135 -0
- package/framework/tools/lincoln-installer/src/components/WelcomeScreen.tsx +22 -0
- package/framework/tools/lincoln-installer/src/config/args.ts +76 -0
- package/framework/tools/lincoln-installer/src/config/resolveConfig.ts +33 -0
- package/framework/tools/lincoln-installer/src/config/updateArgs.ts +67 -0
- package/framework/tools/lincoln-installer/src/hooks/useSetup.ts +149 -0
- package/framework/tools/lincoln-installer/src/main.tsx +11 -0
- package/framework/tools/lincoln-installer/src/types.ts +19 -0
- package/framework/tools/lincoln-installer/src/update-main.tsx +11 -0
- package/framework/tools/lincoln-installer/src/update.tsx +90 -0
- package/framework/tools/lincoln-installer/src/utils/detectHarness.ts +51 -0
- package/framework/tools/lincoln-installer/src/utils/runSetup.ts +62 -0
- package/framework/tools/lincoln-installer/src/utils/updateRelease.ts +454 -0
- package/framework/tools/lincoln-installer/tests/components/InstallerApp.test.tsx +88 -0
- package/framework/tools/lincoln-installer/tests/components/SelectMenu.test.tsx +26 -0
- package/framework/tools/lincoln-installer/tests/components/UpdateApp.test.tsx +170 -0
- package/framework/tools/lincoln-installer/tests/components/screens.test.tsx +310 -0
- package/framework/tools/lincoln-installer/tests/config/args.test.ts +66 -0
- package/framework/tools/lincoln-installer/tests/config/resolveConfig.test.ts +75 -0
- package/framework/tools/lincoln-installer/tests/config/updateArgs.test.ts +52 -0
- package/framework/tools/lincoln-installer/tests/hooks/useSetup.test.tsx +213 -0
- package/framework/tools/lincoln-installer/tests/update.test.tsx +108 -0
- package/framework/tools/lincoln-installer/tests/utils/detectHarness.test.ts +40 -0
- package/framework/tools/lincoln-installer/tests/utils/runSetup.test.ts +45 -0
- package/framework/tools/lincoln-installer/tests/utils/updateRelease.test.ts +559 -0
- package/framework/tools/lincoln-installer/tsconfig.json +22 -0
- package/framework/tools/lincoln-installer/tsconfig.tests.json +8 -0
- package/framework/tools/lincoln-installer/tsup.config.ts +17 -0
- package/framework/tools/lincoln-installer/vitest.config.ts +20 -0
- package/framework/tools/lincoln-record/Cargo.lock +1896 -0
- package/framework/tools/lincoln-record/Cargo.toml +24 -0
- package/framework/tools/lincoln-record/diarize/diarize.py +117 -0
- package/framework/tools/lincoln-record/diarize/merge.py +55 -0
- package/framework/tools/lincoln-record/src/audio/capture/microphone.rs +194 -0
- package/framework/tools/lincoln-record/src/audio/capture/mod.rs +1 -0
- package/framework/tools/lincoln-record/src/audio/devices.rs +20 -0
- package/framework/tools/lincoln-record/src/audio/mod.rs +5 -0
- package/framework/tools/lincoln-record/src/audio/resampler.rs +44 -0
- package/framework/tools/lincoln-record/src/audio/saver.rs +87 -0
- package/framework/tools/lincoln-record/src/audio/source.rs +104 -0
- package/framework/tools/lincoln-record/src/cli.rs +96 -0
- package/framework/tools/lincoln-record/src/config.rs +135 -0
- package/framework/tools/lincoln-record/src/lib.rs +6 -0
- package/framework/tools/lincoln-record/src/main.rs +242 -0
- package/framework/tools/lincoln-record/src/model/mod.rs +248 -0
- package/framework/tools/lincoln-record/src/output/metadata.rs +30 -0
- package/framework/tools/lincoln-record/src/output/mod.rs +2 -0
- package/framework/tools/lincoln-record/src/output/transcript.rs +42 -0
- package/framework/tools/lincoln-record/src/transcription/diarization.rs +64 -0
- package/framework/tools/lincoln-record/src/transcription/mod.rs +3 -0
- package/framework/tools/lincoln-record/src/transcription/provider.rs +43 -0
- package/framework/tools/lincoln-record/src/transcription/whisper.rs +176 -0
- package/framework/tools/lincoln-record/tests/cli_args.rs +103 -0
- package/framework/tools/lincoln-record/tests/config_test.rs +70 -0
- package/framework/tools/lincoln-record/tests/devices_test.rs +23 -0
- package/framework/tools/lincoln-record/tests/diarization_tests.rs +101 -0
- package/framework/tools/lincoln-record/tests/integration_tests.rs +44 -0
- package/framework/tools/lincoln-record/tests/model_test.rs +68 -0
- package/framework/tools/lincoln-record/tests/transcription_tests.rs +73 -0
- package/package.json +19 -13
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Lincoln workflow health auditor.
|
|
4
|
+
|
|
5
|
+
Runs a set of audit rules against the workflow state and reports PASS/WARN/FAIL.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
python scripts/lincoln-audit.py [--format json|markdown]
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import json
|
|
15
|
+
import sys
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
20
|
+
from scripts.stage_loader import ( # noqa: E402
|
|
21
|
+
PROJECT_ROOT,
|
|
22
|
+
compute_next_stage,
|
|
23
|
+
find_stage,
|
|
24
|
+
get_latest_node_for_stage,
|
|
25
|
+
get_nodes,
|
|
26
|
+
get_variables,
|
|
27
|
+
interpolate_artifact,
|
|
28
|
+
load_stage_yaml,
|
|
29
|
+
load_state,
|
|
30
|
+
load_workflow,
|
|
31
|
+
resolve_state_path,
|
|
32
|
+
)
|
|
33
|
+
from scripts.lincoln_paths import get_process_slug, process_package_root
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _parse_iso(ts: str | None) -> Any:
|
|
37
|
+
"""Parse ISO timestamp string to datetime, or None."""
|
|
38
|
+
if not ts:
|
|
39
|
+
return None
|
|
40
|
+
from datetime import datetime
|
|
41
|
+
try:
|
|
42
|
+
return datetime.fromisoformat(ts.replace("Z", "+00:00"))
|
|
43
|
+
except ValueError:
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _get_stage_status(state: dict[str, Any], stage_id: str) -> str | None:
|
|
48
|
+
node = get_latest_node_for_stage(state, stage_id)
|
|
49
|
+
if node is not None:
|
|
50
|
+
return node.get("status")
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def audit_state_consistency(state: dict[str, Any], workflow: dict[str, Any]) -> dict[str, Any]:
|
|
55
|
+
"""Check that current_stage is consistent with completed stages sequence."""
|
|
56
|
+
step_ids = [s["id"] for s in workflow.get("steps", [])]
|
|
57
|
+
current_stage = state.get("current_run", {}).get("current_stage")
|
|
58
|
+
|
|
59
|
+
if not current_stage:
|
|
60
|
+
run_status = state.get("current_run", {}).get("status")
|
|
61
|
+
if run_status == "completed":
|
|
62
|
+
return {"check": "state_consistency", "status": "PASS", "message": "Workflow completed; no current stage."}
|
|
63
|
+
return {"check": "state_consistency", "status": "WARN", "message": "No current stage and workflow not marked completed."}
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
current_idx = step_ids.index(current_stage)
|
|
67
|
+
except ValueError:
|
|
68
|
+
return {"check": "state_consistency", "status": "FAIL", "message": f"Current stage '{current_stage}' not found in workflow."}
|
|
69
|
+
|
|
70
|
+
issues = []
|
|
71
|
+
for sid in step_ids[:current_idx]:
|
|
72
|
+
status = _get_stage_status(state, sid)
|
|
73
|
+
if status != "completed":
|
|
74
|
+
issues.append(f"Stage '{sid}' (before current) has status '{status}' not 'completed'")
|
|
75
|
+
|
|
76
|
+
if issues:
|
|
77
|
+
return {"check": "state_consistency", "status": "FAIL", "message": "; ".join(issues)}
|
|
78
|
+
return {"check": "state_consistency", "status": "PASS", "message": "Stage sequence is consistent."}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def audit_artifact_completeness(state: dict[str, Any], workflow: dict[str, Any], state_file: Path | None = None) -> dict[str, Any]:
|
|
82
|
+
"""Check that required artifacts exist for current and completed stages."""
|
|
83
|
+
step_ids = [s["id"] for s in workflow.get("steps", [])]
|
|
84
|
+
current_stage = state.get("current_run", {}).get("current_stage")
|
|
85
|
+
state_file = state_file or resolve_state_path(None)
|
|
86
|
+
|
|
87
|
+
check_stages = [sid for sid in step_ids if _get_stage_status(state, sid) in ("completed", "in_progress")]
|
|
88
|
+
if current_stage and current_stage not in check_stages:
|
|
89
|
+
check_stages.append(current_stage)
|
|
90
|
+
|
|
91
|
+
missing = []
|
|
92
|
+
for sid in check_stages:
|
|
93
|
+
try:
|
|
94
|
+
stage = load_stage_yaml(sid)
|
|
95
|
+
except Exception:
|
|
96
|
+
continue
|
|
97
|
+
artifacts = stage.get("artifacts", {}).get("required", [])
|
|
98
|
+
node = get_latest_node_for_stage(state, sid)
|
|
99
|
+
produced = node.get("artifacts", []) if node else []
|
|
100
|
+
for art in artifacts:
|
|
101
|
+
resolved = interpolate_artifact(str(art), state, state_file)
|
|
102
|
+
art_path = PROJECT_ROOT / resolved
|
|
103
|
+
if not art_path.exists() and resolved not in produced:
|
|
104
|
+
missing.append(f"{sid}: {resolved}")
|
|
105
|
+
|
|
106
|
+
if missing:
|
|
107
|
+
return {"check": "artifact_completeness", "status": "WARN", "message": f"Missing artifacts: {', '.join(missing)}"}
|
|
108
|
+
return {"check": "artifact_completeness", "status": "PASS", "message": "All required artifacts present or recorded."}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def audit_human_gate_compliance(state: dict[str, Any], workflow: dict[str, Any]) -> dict[str, Any]:
|
|
112
|
+
"""Completed stages with human_gate=true must have gate_passed=true."""
|
|
113
|
+
violations = []
|
|
114
|
+
for sid in [s["id"] for s in workflow.get("steps", [])]:
|
|
115
|
+
status = _get_stage_status(state, sid)
|
|
116
|
+
if status != "completed":
|
|
117
|
+
continue
|
|
118
|
+
try:
|
|
119
|
+
stage = load_stage_yaml(sid)
|
|
120
|
+
except Exception:
|
|
121
|
+
continue
|
|
122
|
+
node = get_latest_node_for_stage(state, sid)
|
|
123
|
+
if stage.get("human_gate", False) and (node is None or not node.get("gate_passed")):
|
|
124
|
+
violations.append(sid)
|
|
125
|
+
|
|
126
|
+
if violations:
|
|
127
|
+
return {"check": "human_gate_compliance", "status": "FAIL", "message": f"Stages missing human gate approval: {', '.join(violations)}"}
|
|
128
|
+
return {"check": "human_gate_compliance", "status": "PASS", "message": "All human-gated stages have approval."}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def audit_entry_exit_compliance(state: dict[str, Any], workflow: dict[str, Any]) -> dict[str, Any]:
|
|
132
|
+
"""Completed stages should have entry and exit checks passed."""
|
|
133
|
+
violations = []
|
|
134
|
+
for sid in [s["id"] for s in workflow.get("steps", [])]:
|
|
135
|
+
status = _get_stage_status(state, sid)
|
|
136
|
+
if status != "completed":
|
|
137
|
+
continue
|
|
138
|
+
node = get_latest_node_for_stage(state, sid)
|
|
139
|
+
if node is None:
|
|
140
|
+
continue
|
|
141
|
+
if not node.get("entry_checks_passed"):
|
|
142
|
+
violations.append(f"{sid}: entry checks not passed")
|
|
143
|
+
if not node.get("exit_checks_passed"):
|
|
144
|
+
violations.append(f"{sid}: exit checks not passed")
|
|
145
|
+
|
|
146
|
+
if violations:
|
|
147
|
+
return {"check": "entry_exit_compliance", "status": "WARN", "message": f"Check issues: {', '.join(violations)}"}
|
|
148
|
+
return {"check": "entry_exit_compliance", "status": "PASS", "message": "All completed stages have entry/exit checks passed."}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def audit_skill_coverage(state: dict[str, Any]) -> dict[str, Any]:
|
|
152
|
+
"""Current stage should have at least one skill invoked."""
|
|
153
|
+
current_stage = state.get("current_run", {}).get("current_stage")
|
|
154
|
+
if not current_stage:
|
|
155
|
+
return {"check": "skill_coverage", "status": "PASS", "message": "No current stage; skipping skill coverage check."}
|
|
156
|
+
|
|
157
|
+
node = get_latest_node_for_stage(state, current_stage)
|
|
158
|
+
skills_invoked = node.get("skills_invoked", []) if node else []
|
|
159
|
+
if not skills_invoked:
|
|
160
|
+
return {"check": "skill_coverage", "status": "WARN", "message": f"No skills recorded for current stage '{current_stage}'."}
|
|
161
|
+
return {"check": "skill_coverage", "status": "PASS", "message": f"{len(skills_invoked)} skill(s) recorded for current stage."}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def audit_anomaly_detection(state: dict[str, Any]) -> dict[str, Any]:
|
|
165
|
+
"""Detect anomalies: retry_count > 1 or validation_failed stages."""
|
|
166
|
+
anomalies = []
|
|
167
|
+
for node in get_nodes(state):
|
|
168
|
+
sid = node.get("stage_id", "unknown")
|
|
169
|
+
retry = node.get("retry_count", 0)
|
|
170
|
+
if retry > 1:
|
|
171
|
+
anomalies.append(f"{sid}: retry_count={retry}")
|
|
172
|
+
if node.get("status") == "validation_failed":
|
|
173
|
+
anomalies.append(f"{sid}: status=validation_failed")
|
|
174
|
+
|
|
175
|
+
if anomalies:
|
|
176
|
+
return {"check": "anomaly_detection", "status": "WARN", "message": f"Anomalies detected: {', '.join(anomalies)}"}
|
|
177
|
+
return {"check": "anomaly_detection", "status": "PASS", "message": "No anomalies detected."}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def audit_handoff_file(state: dict[str, Any], state_file: Path | None = None) -> dict[str, Any]:
|
|
181
|
+
"""Check handoff file exists if current stage is waiting_for_human."""
|
|
182
|
+
current_stage = state.get("current_run", {}).get("current_stage")
|
|
183
|
+
if not current_stage:
|
|
184
|
+
return {"check": "handoff_file", "status": "PASS", "message": "No current stage; skipping handoff check."}
|
|
185
|
+
|
|
186
|
+
node = get_latest_node_for_stage(state, current_stage)
|
|
187
|
+
if node is None or node.get("status") != "waiting_for_human":
|
|
188
|
+
return {"check": "handoff_file", "status": "PASS", "message": "Current stage not waiting for human; handoff file optional."}
|
|
189
|
+
|
|
190
|
+
handoff_file = node.get("handoff_file")
|
|
191
|
+
if handoff_file and (PROJECT_ROOT / handoff_file).exists():
|
|
192
|
+
return {"check": "handoff_file", "status": "PASS", "message": "Handoff file exists."}
|
|
193
|
+
|
|
194
|
+
state_file = state_file or resolve_state_path(None)
|
|
195
|
+
process_slug = get_process_slug(state, state_file)
|
|
196
|
+
handoff_dir = process_package_root(process_slug=process_slug) / "handoffs"
|
|
197
|
+
latest = None
|
|
198
|
+
if handoff_dir.exists():
|
|
199
|
+
candidates = sorted(handoff_dir.glob("*.md"), key=lambda p: p.stat().st_mtime, reverse=True)
|
|
200
|
+
if candidates:
|
|
201
|
+
latest = candidates[0]
|
|
202
|
+
|
|
203
|
+
if latest and latest.exists():
|
|
204
|
+
try:
|
|
205
|
+
display = str(latest.relative_to(PROJECT_ROOT))
|
|
206
|
+
except ValueError:
|
|
207
|
+
display = str(latest)
|
|
208
|
+
return {"check": "handoff_file", "status": "PASS", "message": f"Handoff file exists: {display}"}
|
|
209
|
+
|
|
210
|
+
return {"check": "handoff_file", "status": "WARN", "message": f"Stage waiting for human but handoff file missing in {handoff_dir}"}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def run_all_audits(state: dict[str, Any], state_file: Path | None = None) -> list[dict[str, Any]]:
|
|
214
|
+
"""Run all audit rules and return results."""
|
|
215
|
+
template_name = state.get("workflow", {}).get("template")
|
|
216
|
+
workflow = load_workflow(template_name)
|
|
217
|
+
|
|
218
|
+
results = [
|
|
219
|
+
audit_state_consistency(state, workflow),
|
|
220
|
+
audit_artifact_completeness(state, workflow, state_file),
|
|
221
|
+
audit_human_gate_compliance(state, workflow),
|
|
222
|
+
audit_entry_exit_compliance(state, workflow),
|
|
223
|
+
audit_skill_coverage(state),
|
|
224
|
+
audit_anomaly_detection(state),
|
|
225
|
+
audit_handoff_file(state, state_file),
|
|
226
|
+
]
|
|
227
|
+
return results
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def compute_overall_status(results: list[dict[str, Any]]) -> str:
|
|
231
|
+
statuses = [r["status"] for r in results]
|
|
232
|
+
if "FAIL" in statuses:
|
|
233
|
+
return "FAIL"
|
|
234
|
+
if "WARN" in statuses:
|
|
235
|
+
return "WARN"
|
|
236
|
+
return "PASS"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def format_json(results: list[dict[str, Any]], overall: str) -> str:
|
|
240
|
+
return json.dumps({"overall_status": overall, "checks": results}, ensure_ascii=False, indent=2)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def format_markdown(results: list[dict[str, Any]], overall: str) -> str:
|
|
244
|
+
lines = []
|
|
245
|
+
lines.append("# Lincoln Workflow Audit Report")
|
|
246
|
+
lines.append("")
|
|
247
|
+
status_emoji = {"PASS": "✅", "WARN": "⚠️", "FAIL": "❌"}
|
|
248
|
+
lines.append(f"**Overall Status:** {status_emoji.get(overall, '')} {overall}")
|
|
249
|
+
lines.append("")
|
|
250
|
+
lines.append("| Check | Status | Message |")
|
|
251
|
+
lines.append("|-------|--------|---------|")
|
|
252
|
+
for r in results:
|
|
253
|
+
emoji = status_emoji.get(r["status"], "")
|
|
254
|
+
lines.append(f"| {r['check']} | {emoji} {r['status']} | {r['message']} |")
|
|
255
|
+
return "\n".join(lines)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def main() -> int:
|
|
259
|
+
parser = argparse.ArgumentParser(description="Lincoln workflow health auditor")
|
|
260
|
+
parser.add_argument(
|
|
261
|
+
"--format",
|
|
262
|
+
choices=["json", "markdown"],
|
|
263
|
+
default="markdown",
|
|
264
|
+
help="Output format (default: markdown)",
|
|
265
|
+
)
|
|
266
|
+
parser.add_argument(
|
|
267
|
+
"--state-file",
|
|
268
|
+
type=Path,
|
|
269
|
+
default=None,
|
|
270
|
+
help="Path to workflow-stage.yaml",
|
|
271
|
+
)
|
|
272
|
+
args = parser.parse_args()
|
|
273
|
+
|
|
274
|
+
state_file = resolve_state_path(args.state_file)
|
|
275
|
+
state = load_state(state_file)
|
|
276
|
+
results = run_all_audits(state, state_file)
|
|
277
|
+
overall = compute_overall_status(results)
|
|
278
|
+
|
|
279
|
+
if args.format == "json":
|
|
280
|
+
print(format_json(results, overall))
|
|
281
|
+
else:
|
|
282
|
+
print(format_markdown(results, overall))
|
|
283
|
+
|
|
284
|
+
return 0 if overall != "FAIL" else 1
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
if __name__ == "__main__":
|
|
288
|
+
sys.exit(main())
|