Skip to content

Commit d7679f5

Browse files
authored
Release v2.4.2+0.2.2+8.19
Merge pull request #53 from JetBrains-Research/v2.5.0-dev
2 parents 641a277 + d567004 commit d7679f5

File tree

16 files changed

+224
-20
lines changed

16 files changed

+224
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.4.2
4+
5+
- Fix premise selection bug in benchmarks: in `v2.4.1`, a theorem for which the completion was issued was accidentally added to the list of premises. This was fixed in this release.
6+
We encountered difficulty setting the correct `coq-lsp` path in the settings, both for the `coq-lsp` plugin itself and for `coqpilot`. When using the `nix` environment, it is common for the path to be updated by hand, and it is not always done correctly. Therefore, we added a warning message to the user, which is shown when `coqpilot` suspects that the build of `coq-lsp` on the given path is not the expected one.
7+
38
## 2.4.1
49

510
Hot fix with update of dependencies to fix the issue on extension activation.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# CoqPilot ![Version](https://img.shields.io/badge/version-v2.4.1-blue?style=flat-square)
1+
# CoqPilot ![Version](https://img.shields.io/badge/version-v2.4.2-blue?style=flat-square)
22

33
*Authors:* Andrei Kozyrev, Gleb Solovev, Nikita Khramov, and Anton Podkopaev, [Programming Languages and Tools Lab](https://lp.jetbrains.com/research/plt_lab/) at JetBrains Research.
44

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/JetBrains-Research/coqpilot"
99
},
1010
"publisher": "JetBrains-Research",
11-
"version": "2.4.1",
11+
"version": "2.4.2",
1212
"engines": {
1313
"vscode": "^1.95.0"
1414
},

src/benchmark/framework/benchmarkingCore/executeBenchmarkingTask.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export async function executeBenchmarkingTask(
5151
try {
5252
const generationArgs = {
5353
completionContext: task.getCompletionContext(),
54+
sourceTheorem: task.sourceTheorem,
5455
sourceFileEnvironment: task.getSourceFileEnvironment(),
5556
benchmarkingModelParams: params,
5657
llmService: llmService,

src/benchmark/framework/benchmarkingCore/singleCompletionGeneration/benchmarkSingleCompletionGeneration.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
} from "../../structures/benchmarkingResults/benchmarkedItem";
4545
import { WorkspaceRoot } from "../../structures/common/workspaceRoot";
4646
import { ParsedCoqFileData } from "../../structures/parsedCoqFile/parsedCoqFileData";
47+
import { TheoremData } from "../../structures/parsedCoqFile/theoremData";
4748
import { throwOnAbort } from "../../utils/asyncUtils/abortUtils";
4849
import { AsyncScheduler } from "../../utils/asyncUtils/asyncScheduler";
4950
import { reduceToMap } from "../../utils/collectionUtils/mapUtils";
@@ -65,6 +66,7 @@ export interface CompletionGenerationBenchmarkArgs<
6566
LLMServiceType extends LLMService<any, ResolvedModelParams>,
6667
> {
6768
completionContext: CompletionContext;
69+
sourceTheorem: TheoremData;
6870
sourceFileEnvironment: SourceFileEnvironment;
6971
benchmarkingModelParams: BenchmarkingModelParams<ResolvedModelParams>;
7072
llmService: LLMServiceType;
@@ -242,6 +244,7 @@ async function generateProofWithRetriesExclusively<
242244
() =>
243245
generateProofWithRetriesMeasured(
244246
generationArgs.completionContext,
247+
generationArgs.sourceTheorem.name,
245248
generationArgs.sourceFileEnvironment,
246249
generationArgs.benchmarkingModelParams,
247250
generationArgs.llmService,
@@ -258,6 +261,7 @@ async function generateProofWithRetriesMeasured<
258261
ResolvedModelParams extends ModelParams,
259262
>(
260263
completionContext: CompletionContext,
264+
sourceTheoremName: string,
261265
sourceFileEnvironment: SourceFileEnvironment,
262266
benchmarkingModelParams: BenchmarkingModelParams<ResolvedModelParams>,
263267
llmService: LLMService<any, any>,
@@ -286,6 +290,7 @@ async function generateProofWithRetriesMeasured<
286290
const proofGenerationContext = buildProofGenerationContext(
287291
completionContext,
288292
sourceFileEnvironment.fileTheorems,
293+
sourceTheoremName,
289294
benchmarkingModelParams.theoremRanker
290295
);
291296

@@ -395,14 +400,24 @@ async function generateProofWithRetriesMeasured<
395400
}
396401
}
397402

403+
/**
404+
* _Important:_ this function is the one responsbile for **removing
405+
* the target theorem from the context** (i.e. file theorems) if it is present there.
406+
*/
398407
function buildProofGenerationContext(
399408
completionContext: CompletionContext,
400409
fileTheorems: Theorem[],
410+
targetTheoremName: string,
401411
theoremRanker?: ContextTheoremsRanker
402412
): ProofGenerationContext {
413+
const contextTheorems = fileTheorems.filter(
414+
(theorem) => theorem.name !== targetTheoremName
415+
);
403416
const rankedTheorems =
404-
theoremRanker?.rankContextTheorems(fileTheorems, completionContext) ??
405-
fileTheorems;
417+
theoremRanker?.rankContextTheorems(
418+
contextTheorems,
419+
completionContext
420+
) ?? fileTheorems;
406421
return {
407422
contextTheorems: rankedTheorems,
408423
completionTarget: goalToTargetLemma(completionContext.proofGoal),

src/benchmark/framework/experiment/abstractExperiment.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export abstract class AbstractExperiment {
108108
);
109109
}
110110

111+
// TODO: support absolute `artifactsDirPath`
111112
/**
112113
* The core method that executes the benchmarking experiment.
113114
*
@@ -280,10 +281,21 @@ export abstract class AbstractExperiment {
280281
optionsAfterStartupResolution: ExperimentRunOptions.AfterStartupResolution,
281282
requestedWorkspaces: string[]
282283
): ExperimentRunOptions {
284+
// So far `coqLspServerPath` is applied to the benchmarking system
285+
// by storing it into `process.env.COQ_LSP_PATH`.
286+
// TODO: pass it through the system explicitly (!)
287+
const customCoqLspServerPath =
288+
optionsAfterStartupResolution.coqLspServerPath;
289+
if (customCoqLspServerPath !== undefined) {
290+
process.env.COQ_LSP_PATH = customCoqLspServerPath;
291+
}
292+
283293
return {
284294
loggerSeverity: optionsAfterStartupResolution.loggerSeverity,
285295
logsFilePath: optionsAfterStartupResolution.logsFilePath,
286296

297+
coqLspServerPath: undefined, // TODO: is passed through `process.env.COQ_LSP_PATH` above
298+
287299
datasetCacheUsage: optionsAfterStartupResolution.datasetCacheUsage,
288300
datasetCacheDirectoryPath:
289301
optionsAfterStartupResolution.datasetCacheDirectoryPath,

src/benchmark/framework/structures/inputParameters/experimentRunOptions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ export interface ExperimentRunOptions extends BenchmarkingOptions {
1111
*/
1212
logsFilePath: string | undefined;
1313

14+
/**
15+
* Path to the coq-lsp server. Currently, it **must be set up properly**;
16+
* otherwise, proof checking always suceeds even for the invalid proofs.
17+
*
18+
* Notes on the coq-lsp server path resolution.
19+
* - If `coqLspServerPath` is set, it will be used.
20+
* - Otherwise, the one stored in the `COQ_LSP_PATH` environment variable will be selected.
21+
* - Finally, if none of them are set, coq-lsp will search for the server path automatically.
22+
*/
23+
coqLspServerPath: string | undefined;
24+
1425
datasetCacheUsage: DatasetCacheUsageMode;
1526
/**
1627
* Path relative to the root directory. If it is not set, a `dataset/.parsingCache` will be used.

src/coqLsp/coqLspClient.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Position,
1515
ProtocolNotificationType,
1616
PublishDiagnosticsNotification,
17+
PublishDiagnosticsParams,
1718
RequestType,
1819
TextDocumentIdentifier,
1920
VersionedTextDocumentIdentifier,
@@ -111,6 +112,7 @@ export class CoqLspClientImpl implements CoqLspClient {
111112
public readonly abortSignal?: AbortSignal
112113
) {
113114
this.client = coqLspConnector;
115+
this.trackSuspiciousLspErrors();
114116
}
115117

116118
static async create(
@@ -123,7 +125,8 @@ export class CoqLspClientImpl implements CoqLspClient {
123125
const connector = new CoqLspConnector(
124126
serverConfig,
125127
clientConfig,
126-
logOutputChannel
128+
logOutputChannel,
129+
eventLogger
127130
);
128131
await connector.start().catch((error) => {
129132
throw new CoqLspStartupError(
@@ -242,6 +245,49 @@ export class CoqLspClientImpl implements CoqLspClient {
242245
.trim();
243246
}
244247

248+
trackSuspiciousLspErrors() {
249+
this.client.onNotification(
250+
PublishDiagnosticsNotification.type,
251+
(params: PublishDiagnosticsParams) => {
252+
function filterIncorrectLspSuspectedDiagnostics(
253+
diagnostic: Diagnostic
254+
): boolean {
255+
const errorSubstrings = [
256+
"Cannot find a physical path bound to logical path",
257+
"Dynlink error: error loading shared library",
258+
];
259+
260+
return errorSubstrings.some(
261+
(substr) =>
262+
diagnostic.message.includes(substr) &&
263+
diagnostic.severity === 1
264+
);
265+
}
266+
267+
const suspectedDiagnostics = params.diagnostics.filter(
268+
filterIncorrectLspSuspectedDiagnostics
269+
);
270+
if (suspectedDiagnostics.length > 0) {
271+
const data = {
272+
uri: params.uri.toString(),
273+
version: params.version,
274+
diagnosticMessage: suspectedDiagnostics.map(
275+
(d) => d.message
276+
),
277+
};
278+
const firstErrorMessage =
279+
suspectedDiagnostics[0].message.split("\n")[0];
280+
281+
this.eventLogger?.log(
282+
CoqLspConnector.wrongServerSuspectedEvent,
283+
firstErrorMessage,
284+
data
285+
);
286+
}
287+
}
288+
);
289+
}
290+
245291
filterDiagnostics(
246292
diagnostics: Diagnostic[],
247293
position: Position

src/coqLsp/coqLspConnector.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { EventLogger } from "../logging/eventLogger";
1111
import { CoqLspClientConfig, CoqLspServerConfig } from "./coqLspConfig";
1212

1313
export class CoqLspConnector extends LanguageClient {
14+
static wrongServerSuspectedEvent = "wrong-lsp-server-suspected";
15+
1416
constructor(
1517
serverConfig: CoqLspServerConfig,
1618
clientConfig: CoqLspClientConfig,
@@ -63,20 +65,27 @@ export class CoqLspConnector extends LanguageClient {
6365
super.setTrace(Trace.Verbose);
6466
await super
6567
.start()
66-
.then(this.logStatusUpdate.bind(this, "started"))
68+
.then()
6769
.catch((error) => {
6870
let emsg = error.toString();
6971
this.eventLogger?.log("coq-lsp-start-error", emsg);
70-
this.logStatusUpdate("stopped");
7172
throw error;
7273
});
7374
}
7475

75-
override async stop(): Promise<void> {
76-
super.stop().then(this.logStatusUpdate.bind(this, "stopped"));
76+
private isVersioningError(message: string): boolean {
77+
return message.includes("Incorrect client version");
7778
}
7879

79-
private logStatusUpdate = (status: "started" | "stopped") => {
80-
this.eventLogger?.log("coq-lsp-status-change", status);
81-
};
80+
override error(message: string, data: any, showNotification = true) {
81+
if (this.isVersioningError(message)) {
82+
this.eventLogger?.log(
83+
CoqLspConnector.wrongServerSuspectedEvent,
84+
message
85+
);
86+
} else {
87+
this.eventLogger?.log("coq-lsp-error", message);
88+
}
89+
super.error(message, data, showNotification);
90+
}
8291
}

0 commit comments

Comments
 (0)