-
Notifications
You must be signed in to change notification settings - Fork 0
feat(diagnostics): add strict writing diagnostic contract #249
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
Draft
seonghobae
wants to merge
26
commits into
design/llm-writing-diagnostics
Choose a base branch
from
feat/writing-diagnostics-contract
base: design/llm-writing-diagnostics
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9f3c6dc
test(diagnostics): define strict host diagnostic contract
seonghobae 52c1ae4
ci(diagnostics): verify contract TDD red-green cycle
seonghobae 67c5ac8
feat(diagnostics): add strict writing diagnostic contract
seonghobae 68c8665
test(diagnostics): apply stricter limit in its own assertion
seonghobae 8b60c14
test(diagnostics): require root and framework-free exports
seonghobae dfc8a8d
ci(diagnostics): verify source export contract
seonghobae 6a2cae5
feat(diagnostics): add framework-free source subpath
seonghobae bae0d55
feat(diagnostics): export host diagnostic contract
seonghobae ce38a45
ci(diagnostics): enforce exact contract coverage
seonghobae 9bb0117
ci(diagnostics): report uncovered contract paths
seonghobae 246614a
test(diagnostics): cover hostile structural boundaries
seonghobae a38d3d4
ci(diagnostics): exercise hostile contract boundaries
seonghobae 1cf16ac
refactor(diagnostics): remove unreachable validation branches
seonghobae 67b0e56
test(diagnostics): keep missing-field fixture type-safe
seonghobae 7c8dd98
ci(diagnostics): run full package acceptance
seonghobae c0baa93
docs(adr): restore canonical quality contract
seonghobae fa05e84
Merge design/llm-writing-diagnostics into feat/writing-diagnostics-co…
seonghobae 6697bfe
docs(adr): inherit strict diagnostics v1 decision
seonghobae ba37c4d
docs(plan): inherit strict diagnostics v1 errata
seonghobae 322c838
Merge design/llm-writing-diagnostics into feat/writing-diagnostics-co…
seonghobae 525400d
docs(diagnostics): reconcile contract with current design
seonghobae 0706e0d
chore(diagnostics): inherit unique ADR numbering
seonghobae 0bbd3f3
chore(diagnostics): inherit release workflow repair
seonghobae e80545e
merge(parent): synchronize writing diagnostics contract lane
seonghobae 81fbd55
test(package): require writing diagnostics subpath publication
seonghobae b878721
test(diagnostics): keep package publication on package owner
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
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,130 @@ | ||
| name: Writing Diagnostics Contract TDD | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - feat/writing-diagnostics-contract | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: writing-diagnostics-contract-tdd-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | ||
|
|
||
| jobs: | ||
| focused-contract: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.sha }} | ||
| persist-credentials: false | ||
| - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 | ||
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version: 22 | ||
| cache: pnpm | ||
| - run: pnpm install --frozen-lockfile | ||
| - name: Collect focused contract coverage | ||
| id: focused_coverage | ||
| continue-on-error: true | ||
| run: >- | ||
| pnpm exec vitest run | ||
| src/writingDiagnostics.test.ts | ||
| src/writingDiagnosticsBoundary.test.ts | ||
| src/writingDiagnosticsExports.test.ts | ||
| --coverage | ||
| --coverage.include=src/writingDiagnostics.ts | ||
| --coverage.reporter=text | ||
| --coverage.reporter=json | ||
| --coverage.reporter=json-summary | ||
| - name: Report and enforce exact contract coverage | ||
| run: | | ||
| node <<'NODE' | ||
| const { readFileSync } = require('node:fs'); | ||
| const coverage = JSON.parse(readFileSync('coverage/coverage-final.json', 'utf8')); | ||
| const [filePath, fileCoverage] = Object.entries(coverage).find( | ||
| ([candidate]) => candidate.endsWith('/src/writingDiagnostics.ts'), | ||
| ) ?? []; | ||
| if (!filePath || !fileCoverage) { | ||
| console.error('::error file=src/writingDiagnostics.ts,line=1::Focused coverage record is missing.'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const missingStatementLines = [...new Set( | ||
| Object.entries(fileCoverage.s) | ||
| .filter(([, count]) => count === 0) | ||
| .map(([id]) => fileCoverage.statementMap[id].start.line), | ||
| )].sort((a, b) => a - b); | ||
| const missingFunctionLines = [...new Set( | ||
| Object.entries(fileCoverage.f) | ||
| .filter(([, count]) => count === 0) | ||
| .map(([id]) => fileCoverage.fnMap[id].decl.start.line), | ||
| )].sort((a, b) => a - b); | ||
| const missingBranches = []; | ||
| for (const [id, counts] of Object.entries(fileCoverage.b)) { | ||
| counts.forEach((count, index) => { | ||
| if (count === 0) { | ||
| const branch = fileCoverage.branchMap[id]; | ||
| const location = branch.locations?.[index] ?? branch.loc; | ||
| missingBranches.push(`${location.start.line}:${index}`); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| const total = (values) => Object.values(values).reduce( | ||
| (sum, value) => sum + (Array.isArray(value) ? value.length : 1), | ||
| 0, | ||
| ); | ||
| const covered = (values) => Object.values(values).reduce( | ||
| (sum, value) => sum + (Array.isArray(value) | ||
| ? value.filter((count) => count > 0).length | ||
| : Number(value > 0)), | ||
| 0, | ||
| ); | ||
| const statementTotal = total(fileCoverage.s); | ||
| const statementCovered = covered(fileCoverage.s); | ||
| const functionTotal = total(fileCoverage.f); | ||
| const functionCovered = covered(fileCoverage.f); | ||
| const branchTotal = total(fileCoverage.b); | ||
| const branchCovered = covered(fileCoverage.b); | ||
| console.log( | ||
| `::notice file=src/writingDiagnostics.ts,line=1::` + | ||
| `Statements ${statementCovered}/${statementTotal}; ` + | ||
| `functions ${functionCovered}/${functionTotal}; ` + | ||
| `branches ${branchCovered}/${branchTotal}.`, | ||
| ); | ||
|
|
||
| if ( | ||
| missingStatementLines.length || | ||
| missingFunctionLines.length || | ||
| missingBranches.length || | ||
| process.env.FOCUSED_COVERAGE_OUTCOME !== 'success' | ||
| ) { | ||
| console.error( | ||
| `::error file=src/writingDiagnostics.ts,line=1::` + | ||
| `Missing statement lines: ${missingStatementLines.join(', ') || 'none'}; ` + | ||
| `missing function lines: ${missingFunctionLines.join(', ') || 'none'}; ` + | ||
| `missing branches line:index: ${missingBranches.join(', ') || 'none'}.`, | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| NODE | ||
| env: | ||
| FOCUSED_COVERAGE_OUTCOME: ${{ steps.focused_coverage.outcome }} | ||
| - name: Typecheck public source contracts | ||
| run: pnpm typecheck | ||
| - name: Run complete production coverage gate | ||
| run: pnpm coverage | ||
| - name: Build all package entrypoints | ||
| run: pnpm build | ||
| - name: Verify isolated package consumers | ||
| run: pnpm verify:package | ||
| - name: Build the demonstration application | ||
| run: pnpm build:demo |
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,19 @@ | ||
| /** | ||
| * Framework-independent public surface for host-supplied writing diagnostics. | ||
| * | ||
| * This subpath validates bounded revision-scoped diagnostic proposals. It does | ||
| * not import React, create editor instances, call models/providers or networks, | ||
| * persist authored content, infer language quality, or mutate a document. | ||
| */ | ||
| export { | ||
| DEFAULT_WRITING_DIAGNOSTIC_LIMITS, | ||
| WritingDiagnosticError, | ||
| validateWritingDiagnostics, | ||
| } from '../writingDiagnostics.js'; | ||
| export type { | ||
| CwlWritingDiagnostic, | ||
| CwlWritingDiagnosticPriority, | ||
| CwlWritingDiagnosticProvenance, | ||
| WritingDiagnosticErrorCode, | ||
| WritingDiagnosticLimits, | ||
| } from '../writingDiagnostics.js'; | ||
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.
🟡 New writing-diagnostics subpath not published in package exports
This framework-independent public surface has no matching
./writing-diagnosticsentry in package.jsonexports, no vite build config, and no verify script, unlike every sibling subpath. It is never emitted to dist, so consumers importing@contextualwisdomlab/cwl-editor/writing-diagnosticshit a module-resolution failure. The exports test passes only because it resolves source, not the packed artifact.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.
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.
Verified against current #249 head
b878721bf1c085612f8aea889081f0322e62a2aeand the existing downstream package owner #282 head03e626e57c9b85d5f6cc9b616249b09bdf1669e2.#249 is intentionally Task 1's source-level, React-free contract. Its executable export test is explicitly named
writing diagnostic public source exportsand imports./writing-diagnostics/index.jsfrom source. Package publication is not owned by this branch.Existing Draft #282 (
feat(diagnostics): publish framework-neutral package subpath) is the sole package-surface writer. On its exact current head,package.jsonalready contains./writing-diagnosticstypes/import/require exports, addsvite.writing-diagnostics.config.tstobuild, and addsverify-writing-diagnostics-subpath-package.mjstoverify:package; that PR also owns the packed-package verification/build files. Moving those package files into #249 would create a competing writer and break the accepted dependency split.Therefore the reported module-resolution problem is valid as a downstream package-publication requirement, but it is not a defect in #249's bounded source-contract scope. Package resolvability remains acceptance work on #282 and cannot be claimed from #249 alone.