mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Every harness package declares cordis as a peer dependency, so publishing the harness publishes the vendored framework layer too; under the upstream names that publication would squat them on the registry. scripts/rescope-vendor.ts owns the rename: the nine-package mapping, a delimited-token rule that leaves cordis.yml, the Loader's cordis: builtins and vendor directory names alone, per-file exemptions where a name is a directory or an upstream runtime identifier, and the exact edits for sites a token rule cannot express — dot-notation lookups, unquoted manifest keys, a regex literal whose failure would make every Context-merge scan silently find nothing, the vendored-manifest table, and the contracts that told readers vendored packages keep their upstream names. Markdown follows the rename inside every fence, because a fence is code a reader copies or configuration they mount, and in `docs/` prose as well, where a sentence quoting a name teaches something this repository no longer resolves. Prose elsewhere records what was true when it was written, and the same spelling can mean something else: the Python SDK's `cordis` option, or the unvendored `@cordisjs/plugin-http`. `docs/rescope.md` states both names on purpose and is exempt. exactEditState() classifies every exact edit as pending, applied, or invalid. An insertion keeps its anchor and a deletion keeps its remainder, so each side counts the form that survives: a duplicated insertion, a half-applied replacement, and a deletion whose remainder moved are all invalid. The run classifies every edit before writing anything and aborts on the first invalid one, so a disagreement between the mapping and the tree cannot leave a half-rescoped checkout; each write re-reads its file, because two edits can target one. rescope-vendor.spec.ts pins those rejections, and --check asserts the whole post-state from the hygiene gate, so CI owns the invariant. --reverse restores the upstream names, verified as a round trip: reverse, then apply, reproduces this tree byte for byte. docs/rescope.md is the consumer-facing reference: the old-name/new-name table with each package's role, what the rename deliberately leaves alone, the sites callers must change, and the commands to apply, verify, and revert. The Agent Note carries the decision and its consequences. The rename itself lands in the next commit, produced by running the script.
42 lines
2.1 KiB
TypeScript
42 lines
2.1 KiB
TypeScript
/**
|
|
* Acceptance-path coverage for the rescope codemod's exact-edit classifier: a
|
|
* duplicated insertion — what a non-idempotent apply produces — must be
|
|
* rejected rather than applied again.
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import { exactEditState } from './rescope-vendor.ts'
|
|
|
|
const ANCHOR = '\n## Sync procedure'
|
|
const INSERTED = `\n15. **rescope**: one log entry.\n${ANCHOR}`
|
|
|
|
describe('exactEditState', () => {
|
|
it('classifies an insertion by its target form, so a duplicate is invalid', () => {
|
|
expect(exactEditState(`log\n${ANCHOR}\n`, ANCHOR, INSERTED, 1)).toBe('pending')
|
|
expect(exactEditState(`log${INSERTED}\n`, ANCHOR, INSERTED, 1)).toBe('applied')
|
|
// The anchor survives an insertion, so counting the source form would have
|
|
// called this pending and inserted the entry a second time.
|
|
expect(exactEditState(`log${INSERTED}${INSERTED}\n`, ANCHOR, INSERTED, 1)).toBe('invalid')
|
|
expect(exactEditState('log\n', ANCHOR, INSERTED, 1)).toBe('invalid')
|
|
})
|
|
|
|
it('classifies a deletion by its source form, and requires its remainder to survive', () => {
|
|
const remainder = 'exclude:\n'
|
|
const withEntries = 'exclude:\n - cordis@4\n'
|
|
expect(exactEditState(withEntries, withEntries, remainder, 1)).toBe('pending')
|
|
expect(exactEditState(remainder, withEntries, remainder, 1)).toBe('applied')
|
|
// Upstream dropped the whole field: the source form is gone, but so is the
|
|
// remainder, so this is a moved site rather than a completed deletion.
|
|
expect(exactEditState('unrelated:\n', withEntries, remainder, 1)).toBe('invalid')
|
|
})
|
|
|
|
it('requires a replacement to leave no source form and the exact target count', () => {
|
|
expect(exactEditState('a = 1\n', 'a = 1', 'b = 2', 1)).toBe('pending')
|
|
expect(exactEditState('b = 2\n', 'a = 1', 'b = 2', 1)).toBe('applied')
|
|
expect(exactEditState('b = 2\nb = 2\n', 'a = 1', 'b = 2', 1)).toBe('invalid')
|
|
// A moved or partially applied site: neither state is complete.
|
|
expect(exactEditState('a = 1\nb = 2\n', 'a = 1', 'b = 2', 1)).toBe('invalid')
|
|
expect(exactEditState('x\n', 'a = 1', 'b = 2', 1)).toBe('invalid')
|
|
})
|
|
})
|