Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
sudo apt-get update
sudo apt-get install -y --no-install-recommends subversion
svn --version --quiet
- name: Read pinned host revision
- name: Resolve latest host preview with structured logging
id: core
run: node -e 'const s=require("./sdk.lock.json").source; console.log(`repository=${new URL(s.repository).pathname.slice(1)}\nrevision=${s.revision}`)' >> "$GITHUB_OUTPUT"
run: node -e 'const s=require("./sdk.lock.json").coreSource; console.log(`repository=${new URL(s.repository).pathname.slice(1)}\nrevision=${s.ref}`)' >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
repository: ${{ steps.core.outputs.repository }}
Expand All @@ -31,7 +31,7 @@ jobs:
rust
shared
persist-credentials: false
- name: Build test-only bridge to the pinned Core
- name: Verify host prerequisite and build Core bridge
run: node scripts/prepare-core.mjs
- name: Verify SDK and run offline integration
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends subversion
- name: Read pinned host revision
- name: Resolve latest host preview with structured logging
id: core
if: hashFiles('scripts/prepare-core.mjs') != ''
run: node -e 'const s=require("./sdk.lock.json").source; console.log(`repository=${new URL(s.repository).pathname.slice(1)}\nrevision=${s.revision}`)' >> "$GITHUB_OUTPUT"
run: node -e 'const s=require("./sdk.lock.json").coreSource; console.log(`repository=${new URL(s.repository).pathname.slice(1)}\nrevision=${s.ref}`)' >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
if: steps.core.outputs.revision != ''
with:
Expand All @@ -41,7 +41,7 @@ jobs:
rust
shared
persist-credentials: false
- name: Build test-only bridge to the pinned Core
- name: Verify host prerequisite and build Core bridge
if: steps.core.outputs.revision != ''
run: node scripts/prepare-core.mjs
- name: Verify, test and package
Expand Down
3 changes: 2 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Subversion plugin for Lithe
Copyright 2026 Lithe contributors

This project includes the Apache-2.0 licensed Lithe Node plugin SDK and
test support from 1lck/Lithe-IDEA. Exact upstream paths, Git revision
test support. The SDK comes from Lithe-IDEA/lithe-plugin-docs; historical
test support comes from 1lck/Lithe-IDEA. Exact upstream paths, Git revisions
and SHA-256 hashes are recorded in sdk.lock.json. The SDK's runtime
modules are copied into the plugin at build time; test support is never
shipped in the package.
Expand Down
72 changes: 62 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ copies in an open project: status, diff against the base, history, annotate,
check-in, rollback, update, conflict resolution, and moves through svn.

**0.1.0 is unreleased preview source.** There is no published release yet.
Automated tests run the package against a pinned Lithe Core and a real `svn`
Automated tests run the package against the selected latest Lithe Core and a real `svn`
client in this repository's CI; native installation and full UI acceptance
are still pending.

Expand Down Expand Up @@ -77,6 +77,28 @@ root shown relative to it.
Not in this version: Subversion locks, properties, changelists as groups,
branches/switch, relocate, and merge tracking.

## Diagnostic logs

This branch requires a host offering `litheLogging: 1`. The vendored official
Node SDK sends typed `lithe/log` notifications to the host's v2 catalog and
writer, in the current session's `plugins/io.github.lithe-idea.svn-support/host`
channel. Provider process and protocol facts remain in `vcs/svn`. The SDK owns each request's
terminal event: meaningful success is INFO, failed operations are ERROR, and
cancelled requests are not errors. Repeated background status/base-content
successes are suppressed; their failures remain visible.

A recovered annotation-history failure records one WARN `degraded` fact with
a stable code and still returns the annotation without messages. It never
copies history XML, source, command arguments, repository addresses or credentials
into diagnostics. VCS console output remains separate from logs. The SDK does
not print raw exception messages or stack traces for failed requests.

Use Lithe's log window and diagnostic export. The SDK source base revision
and local logging changes are identified by `sdk.lock.json`, with exact
per-file hashes and no claim of a released artifact. No plugin writer,
log directory or idle task is added. Windows still uses v1 logging;
no Windows v2 acceptance is claimed.

## Development

```sh
Expand All @@ -91,9 +113,10 @@ upgrade, re-record with `scripts/record-fixtures.sh` and review the diff.

The scenario test runs the assembled package through Lithe Core's public JSON
API, exactly as the host starts it, against a throwaway `file://` repository.
It needs svn, Rust, and a checkout of the Lithe revision pinned in
`sdk.lock.json` at `.artifacts/lithe-core` (CI does this with a sparse
checkout of `rust` and `shared`):
It needs svn, Rust, and the selected host preview checked out at
`.artifacts/lithe-core`; the companion `litheLogging: 1` host change must land
first. See **Core integration source** below for strict source verification,
local unpublished working-tree validation and the full command.

```sh
node scripts/prepare-core.mjs
Expand All @@ -106,12 +129,41 @@ session and Core process even when an assertion fails.

## Updating the SDK

The Node plugin SDK and test support are vendored from
[1lck/Lithe-IDEA](https://github.com/1lck/Lithe-IDEA) at the exact revision in
`sdk.lock.json`, with a SHA-256 per file; `scripts/verify-sdk.mjs` rejects
changed or unpinned files. To update, copy the files from the new revision,
update the lock, and run `node scripts/prepare-core.mjs` so the scenario runs
against the same Core.
The Node SDK is vendored from
[Lithe-IDEA/lithe-plugin-docs](https://github.com/Lithe-IDEA/lithe-plugin-docs).
`sdk.lock.json.sdkSource` records its true upstream base revision and the local
structured logging changes; each SDK file has a SHA-256 and explicit source
identity. The original `source` identifies historical test-support files;
`coreSource` independently selects the integration host (see **Core
integration source** below). Update the official SDK production inputs, review
the diff, update every changed hash, and run `node scripts/verify-sdk.mjs`.
Unpinned or changed vendor files are rejected before testing and packaging.

## Core integration source

CI and release verification explicitly check out `sdk.lock.json.coreSource.ref`
(`preview`) from the verified host repository. **Merge the companion host
structured logging change into preview before this plugin change**; preparation
rejects a host missing the typed operation catalog rather than attempting an
old-protocol fallback. It records the resolved commit and exact source SHA-256;
this moving test ref is not presented as a pinned release artifact. SDK vendor
hashes and the historical test-support source remain independently pinned.

Local validation can select a particular real host checkout and revision:

```sh
node scripts/prepare-core.mjs --source /path/to/Lithe-IDEA --ref HEAD --working-tree --target-dir /path/to/Lithe-IDEA/rust/target
LITHE_SVN_INTEGRATION=1 node scripts/test.mjs
```

`--working-tree` is a deliberate opt-in for local unpublished host changes;
without it, dirty sources are rejected. The origin must still match the host
repository and HEAD must resolve to the selected ref. The source remains
unchanged: a test-only Rust executable links the built Core library in the
plugin's private `.artifacts/core-target/`. Preparation records tracked and
untracked `rust/` and `shared/` bytes, the harness and executable hashes;
tests reject any drift after preparation. A caller may reuse an existing
Cargo target with `--target-dir`, but never shares plugin state or log files.

## License

Expand Down
12 changes: 10 additions & 2 deletions io.github.lithe-idea.svn-support/provider/svn-provider.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,20 @@ async function addMessages(params, context, revisions) {
const result = await svn(params, context, ['log', '--xml', '-r', range, '--', target(params.path)], {
maxOutputBytes: XML_OUTPUT_LIMIT,
});
if (result.exitCode !== 0 || result.truncated) return;
if (result.exitCode !== 0 || result.truncated) {
// The annotation is usable without messages; keep this recovered failure
// separate from the SDK-owned failed-request boundary and omit svn output.
context.diagnostics.degraded('lithe/vcs/annotate', result.truncated
? 'svn.annotation.historyTruncated' : 'svn.annotation.historyUnavailable');
return;
}
try {
for (const entry of parseLog(result.stdout, null)) {
const blamed = revisions.get(entry.revision.id);
if (blamed) blamed.message = entry.message;
}
} catch {
// Unreadable log output leaves the messages out.
context.diagnostics.degraded('lithe/vcs/annotate', 'svn.annotation.historyInvalid');
}
}

Expand Down Expand Up @@ -437,6 +443,8 @@ async function cleanup(params, context) {
}

createBackend({ name: 'svn-support', version: '0.1.0' })
.suppressSuccessDiagnostics('lithe/vcs/status')
.suppressSuccessDiagnostics('lithe/vcs/baseContent')
.vcs('svn', {
status,
baseContent,
Expand Down
44 changes: 44 additions & 0 deletions scripts/core-source.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { createHash } from 'node:crypto';
import { readFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { runProcess } from '../vendor/lithe-plugin-sdk/src/index.mjs';
import { repository } from './verify-sdk.mjs';

export const target = join(repository, '.artifacts/core-target');
export const digest = async (file) => createHash('sha256').update(await readFile(file)).digest('hex');
export async function git(source, args) {
const result = await runProcess('git', ['-C', source, ...args], { signal: AbortSignal.timeout(15000), maxOutputBytes: 8 * 1024 * 1024 });
if (result.exitCode !== 0 || result.truncated) throw new Error(`Core source verification failed: ${result.stderr}`);
return result.stdout.trim();
}

/** A source identity includes dirty bytes only when the caller explicitly opted in. */
export async function identifyCore(source, ref, workingTree, expectedRepository) {
const remote = (await git(source, ['remote', 'get-url', 'origin'])).replace(/\.git$/, '');
if (remote !== expectedRepository) throw new Error('Core source has an unexpected origin repository.');
const revision = await git(source, ['rev-parse', 'HEAD']);
if (revision !== await git(source, ['rev-parse', `${ref}^{commit}`])) throw new Error('Core source HEAD does not match the explicitly selected ref.');
const dirty = Boolean(await git(source, ['status', '--porcelain', '--untracked-files=normal', '--', 'rust', 'shared']));
if (dirty && !workingTree) throw new Error('Core source is dirty; explicitly select --working-tree for local validation.');
const paths = (await git(source, ['ls-files', '--cached', '--others', '--exclude-standard', '--', 'rust', 'shared'])).split('\n').filter(Boolean).sort();
const hash = createHash('sha256');
for (const path of [...new Set(paths)]) {
hash.update(path + '\n');
try { hash.update(await readFile(join(source, path))); }
catch (error) { if (error.code === 'ENOENT') hash.update('<deleted>'); else throw error; }
}
const catalog = JSON.parse(await readFile(join(source, 'shared/logging/events/plugins.json'), 'utf8'));
if (!catalog.events.some((event) => event.id === 'plugins.operation.finished')) {
throw new Error('Selected Core lacks litheLogging:1. Merge the companion host logging change into preview first.');
}
return { source: resolve(source), ref, revision, workingTree, dirty, sourceSha256: hash.digest('hex'), repository: remote };
}

/** Revalidate source and binary identity before any integration request. */
export async function verifyPreparedCore(binary, harness) {
const prepared = JSON.parse(await readFile(join(target, 'prepared.json'), 'utf8'));
const lock = JSON.parse(await readFile(join(repository, 'sdk.lock.json'), 'utf8'));
const current = await identifyCore(prepared.source, prepared.ref, prepared.workingTree, lock.coreSource.repository);
if (JSON.stringify(current) !== JSON.stringify(prepared.identity)) throw new Error('Core source changed after preparation; run prepare-core again.');
if (prepared.harnessSha256 !== await digest(harness) || prepared.binarySha256 !== await digest(binary)) throw new Error('Core harness or binary changed after preparation.');
}
69 changes: 34 additions & 35 deletions scripts/prepare-core.mjs
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
#!/usr/bin/env node
import { createHash } from 'node:crypto';
import { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { repository } from './verify-sdk.mjs';
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { repository, verifySdk } from './verify-sdk.mjs';
import { runProcess } from '../vendor/lithe-plugin-sdk/src/index.mjs';
import { digest, identifyCore, target } from './core-source.mjs';

const checkout = join(repository, '.artifacts/lithe-core');
const target = join(repository, '.artifacts/core-target');
const stamp = join(target, 'prepared.json');
await verifySdk();
const lock = JSON.parse(await readFile(join(repository, 'sdk.lock.json'), 'utf8'));
const harness = join(repository, 'test/core-harness.rs');
const digest = async (file) => createHash('sha256').update(await readFile(file)).digest('hex');
let source = join(repository, '.artifacts/lithe-core');
let ref = lock.coreSource.ref;
let workingTree = false;
let buildTarget = join(target, 'build');
for (let index = 2; index < process.argv.length; index++) {
const option = process.argv[index];
if (option === '--source') { const value = process.argv[++index]; if (!value || value.startsWith('--')) throw new Error('--source requires a path.'); source = resolve(value); }
else if (option === '--ref') ref = process.argv[++index];
else if (option === '--target-dir') { const value = process.argv[++index]; if (!value || value.startsWith('--')) throw new Error('--target-dir requires a path.'); buildTarget = resolve(value); }
else if (option === '--working-tree') workingTree = true;
else throw new Error(`Unknown preparation option: ${option}`);
}
if (!ref || ref.startsWith('-')) throw new Error('A real source ref is required.');
const before = await identifyCore(source, ref, workingTree, lock.coreSource.repository);
await mkdir(target, { recursive: true });
await rm(stamp, { force: true });

async function git(args) {
const result = await runProcess('git', ['-C', checkout, ...args], { signal: AbortSignal.timeout(15000) });
if (result.exitCode !== 0 || result.truncated) throw new Error(`Core checkout verification failed: ${result.stderr}`);
return result.stdout.trim();
await rm(join(target, 'prepared.json'), { force: true });
const harness = join(repository, 'test/core-harness.rs');
const binary = join(target, 'svn-plugin-harness');
const logs = [];
async function run(command, args) {
const result = await runProcess(command, args, { signal: AbortSignal.timeout(600000), maxOutputBytes: 4 * 1024 * 1024 });
logs.push(result.stdout + result.stderr);
await writeFile(join(target, 'build.log'), logs.join('\n'));
if (result.exitCode !== 0 || result.truncated) throw new Error(`Core bridge build failed; see ${join(target, 'build.log')}`);
}

if (await git(['rev-parse', 'HEAD']) !== lock.source.revision) throw new Error('Core checkout must match sdk.lock.json source revision.');
const remote = (await git(['remote', 'get-url', 'origin'])).replace(/\.git$/, '');
if (remote !== lock.source.repository) throw new Error('Core checkout must originate from sdk.lock.json source repository.');
if (await git(['status', '--porcelain', '--untracked-files=no'])) throw new Error('Core checkout has tracked modifications.');
const examples = join(checkout, 'rust/lithe-core/examples');
await mkdir(examples, { recursive: true });
await copyFile(harness, join(examples, 'svn-plugin-harness.rs'));
const result = await runProcess('cargo', [
'build', '--locked', '--manifest-path', join(checkout, 'rust/Cargo.toml'),
'-p', 'lithe-core', '--example', 'svn-plugin-harness', '--target-dir', target
], { signal: AbortSignal.timeout(600000), maxOutputBytes: 4 * 1024 * 1024 });
await writeFile(join(target, 'build.log'), result.stdout + result.stderr);
if (result.exitCode !== 0 || result.truncated) throw new Error(`Core bridge build failed; see ${join(target, 'build.log')}`);
await writeFile(stamp, JSON.stringify({
revision: lock.source.revision,
harnessSha256: await digest(harness),
binarySha256: await digest(join(target, 'debug/examples/svn-plugin-harness'))
}, null, 2) + '\n');
console.log(`Prepared Core ${lock.source.revision}`);
await run('cargo', ['build', '--locked', '--manifest-path', join(source, 'rust/Cargo.toml'), '-p', 'lithe-core', '--lib', '--target-dir', buildTarget]);
await run('rustc', ['--edition=2021', harness, '--extern', `lithe_core=${join(buildTarget, 'debug/liblithe_core.rlib')}`, '-L', `dependency=${join(buildTarget, 'debug/deps')}`, '-o', binary]);
const after = await identifyCore(source, ref, workingTree, lock.coreSource.repository);
if (JSON.stringify(before) !== JSON.stringify(after)) throw new Error('Core source changed while building; prepare it again.');
await writeFile(join(target, 'prepared.json'), JSON.stringify({ ...before, identity: before, harnessSha256: await digest(harness), binarySha256: await digest(binary) }, null, 2) + '\n');
console.log(`Prepared Core ${before.revision} ref=${ref} dirty=${before.dirty} sha256=${before.sourceSha256}`);
6 changes: 4 additions & 2 deletions scripts/verify-sdk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export const repository = resolve(dirname(fileURLToPath(import.meta.url)), '..')
/** Verify vendored upstream inputs before testing or assembling a release. */
export async function verifySdk(root = repository) {
const lock = JSON.parse(await readFile(join(root, 'sdk.lock.json'), 'utf8'));
if (lock.schemaVersion !== 1 || !/^[0-9a-f]{40}$/.test(lock.source?.revision) || !Array.isArray(lock.files)) {
if (lock.schemaVersion !== 1 || !/^[0-9a-f]{40}$/.test(lock.source?.revision) || !Array.isArray(lock.files) || !/^[0-9a-f]{40}$/.test(lock.sdkSource?.revision) || lock.sdkSource?.repository !== 'https://github.com/Lithe-IDEA/lithe-plugin-docs') {
throw new Error('sdk.lock.json must pin an exact upstream Git revision and file hashes.');
}
const expected = new Set();
for (const entry of lock.files) {
if (!entry.path?.startsWith('vendor/') || isAbsolute(entry.path) || entry.path.split('/').some(part => !part || part === '.' || part === '..')
|| entry.path.includes('\\') || !/^[0-9a-f]{64}$/.test(entry.sha256) || expected.has(entry.path)) {
|| entry.path.includes('\\') || !/^[0-9a-f]{64}$/.test(entry.sha256) || expected.has(entry.path)
|| (entry.path.startsWith('vendor/lithe-plugin-sdk/src/') && entry.source !== 'sdkSource')
|| (entry.localChanges === true && (!Object.hasOwn(entry, 'upstreamSha256') || (entry.upstreamSha256 !== null && !/^[0-9a-f]{64}$/.test(entry.upstreamSha256))))) {
throw new Error('Invalid or duplicate SDK lock entry.');
}
expected.add(entry.path);
Expand Down
Loading
Loading