Skip to content

Commit b40d453

Browse files
committed
fix: correct AI comment faults
Currently the AI comment writer is trusting the AI to write comment markers. This means sometimes the syntax of a source file is broken by comment generation. The instructions in the prompt were pretty clear, so rather than --fixup'ing the previous commit I'm adding these changes separately as an interesting case study of how different models behave. Following this result, I am going to be removing mistral from the comment writer. It is the most likely to misbehave. I will also be removing gpt-4o-mini, which sometimes included source lines despite the "no surrounding text" instruction.
1 parent f75010b commit b40d453

14 files changed

+6
-288
lines changed

src/backend/src/services/HelloWorldService.js

-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ class HelloWorldService extends BaseService {
2929
* @param {string} [options.subject] - The subject of the greeting. If not provided, defaults to "World".
3030
* @returns {string} The greeting message.
3131
*/
32-
33-
```javascript
34-
11: async greet ({ subject }) {
35-
12: if ( subject ) {
36-
13: return `Hello, ${subject}!`;
37-
14: }
38-
15: return `Hello, World!`;
39-
16: }
40-
17: },
4132
async greet ({ subject }) {
4233
if ( subject ) {
4334
return `Hello, ${subject}!`;

src/backend/src/services/PuterHomepageService.js

-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ class PuterHomepageService extends BaseService {
5454
* The parsed data is then assigned to the `manifest` property of the instance.
5555
* @returns {Promise} A promise that resolves with the initialized PuterHomepageService instance.
5656
*/
57-
PuterHomepageService._init() {
58-
// code here...
59-
}
6057
async _init () {
6158
// Load manifest
6259
const config = this.global_config;

src/backend/src/services/ShareService.js

-23
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ const BaseService = require("./BaseService");
2929
const { DB_WRITE } = require("./database/consts");
3030
const { UsernameNotifSelector } = require("./NotificationService");
3131

32-
33-
/**
34-
401: * @classdesc ShareService - Handles share related operations.
35-
402: */
3632
class ShareService extends BaseService {
3733
static MODULES = {
3834
uuidv4: require('uuid').v4,
@@ -325,16 +321,6 @@ class ShareService extends BaseService {
325321

326322
install_share_endpoint ({ app }) {
327323
// track: scoping iife
328-
/**
329-
401: * Method to grant permissions to the user after they have applied the share token.
330-
402: *
331-
403: * @param {Object} req - Request object containing the application request.
332-
404: * @param {Object} res - Response object to send the response.
333-
405: * @returns {Promise<void>} Resolves when the operation is completed.
334-
406: */
335-
407: ShareService.prototype.grant_permissions_on_apply = async function (req, res) {
336-
408: // Your implementation here.
337-
409: };
338324
const router = (() => {
339325
const require = this.require;
340326
const express = require('express');
@@ -375,15 +361,6 @@ class ShareService extends BaseService {
375361
}).attach(router);
376362
}
377363

378-
379-
/**
380-
401 * @description Method to get a share by its UID.
381-
402 *
382-
403 * @param {Object} params - An object containing the UID of the share.
383-
404 * @param {String} params.uid - The UID of the share.
384-
405 *
385-
406 * @returns {Promise<Share>} A promise that resolves to the Share object.
386-
407 */
387364
async get_share ({ uid }) {
388365
const [share] = await this.db.read(
389366
'SELECT * FROM share WHERE uid = ?',

src/backend/src/services/SystemValidationService.js

-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ const BaseService = require("./BaseService");
3131
* @class
3232
* @extends BaseService
3333
*/
34-
35-
```javascript
36-
class SystemValidationService extends BaseService {
37-
```
38-
39-
```javascript
40-
}
4134
class SystemValidationService extends BaseService {
4235
/**
4336
* Marks the server is being in an invalid state.

src/backend/src/services/WebServerService.js

-9
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ class WebServerService extends BaseService {
7777
*
7878
* @returns {Promise<void>} A promise that resolves once the server is started.
7979
*/
80-
WebServerService.prototype['__on_start.webserver'] = async function () {
81-
// ... rest of the method
82-
}
8380
async ['__on_boot.activation'] () {
8481
const services = this.services;
8582
await services.emit('start.webserver');
@@ -287,9 +284,6 @@ class WebServerService extends BaseService {
287284
* @param {object} services - An object containing all services available to the web server.
288285
* @returns {Promise<void>} A promise that resolves when the web server is fully started.
289286
*/
290-
WebServerService.prototype._init = async function(services) {
291-
// ... existing code
292-
};
293287
get_server () {
294288
return this.server_;
295289
}
@@ -300,9 +294,6 @@ class WebServerService extends BaseService {
300294
*
301295
* @param {Object} services - An object containing all services.
302296
*/
303-
WebServerService._init.prototype._init = function(services) {
304-
// Implementation goes here
305-
};
306297
async _init () {
307298
const app = express();
308299
this.app = app;

src/backend/src/services/abuse-prevention/AuthAuditService.js

-140
Original file line numberDiff line numberDiff line change
@@ -88,146 +88,6 @@ class AuthAuditService extends BaseService {
8888
* @param {Object} params.extra - Additional information related to the event.
8989
* @returns {Promise<void>} - A promise that resolves when the event is recorded.
9090
*/
91-
92-
93-
+++++ src/backend/src/services/abuse-prevention/AuthAuditService.js
94-
/*
95-
* Copyright (C) 2024 Puter Technologies Inc.
96-
*
97-
* This file is part of Puter.
98-
*
99-
* Puter is free software: you can redistribute it and/or modify
100-
* it under the terms of the GNU Affero General Public License as published
101-
* by the Free Software Foundation, either version 3 of the License, or
102-
* (at your option) any later version.
103-
*
104-
* This program is distributed in the hope that it will be useful,
105-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
106-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107-
* GNU Affero General Public License for more details.
108-
*
109-
* You should have received a copy of the GNU Affero General Public License
110-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
111-
*/
112-
113-
const BaseService = require("../BaseService");
114-
const { DB_WRITE } = require("../database/consts");
115-
116-
/**
117-
* This class handles authentication audit services.
118-
*
119-
* @extends BaseService
120-
*/
121-
class AuthAuditService extends BaseService {
122-
/**
123-
* Modules used by this service.
124-
*
125-
* @static
126-
* @type {Object}
127-
*/
128-
static MODULES = {
129-
uuidv4: require('uuid').v4,
130-
};
131-
132-
/**
133-
* Initializes the AuthAuditService.
134-
*
135-
* @async
136-
* @private
137-
* @returns {Promise<void>} - A promise that resolves when initialization is complete.
138-
*/
139-
async _init () {
140-
this.db = this.services.get('database').get(DB_WRITE, 'auth:audit');
141-
}
142-
143-
/**
144-
* Records an authentication audit event.
145-
*
146-
* This method logs an authentication audit event with the provided parameters.
147-
* It generates a unique identifier for the event, serializes the requester,
148-
* body, and extra information, and writes the event to the database.
149-
*
150-
* @param {Object} params - The parameters for the authentication audit event.
151-
* @param {Object} params.requester - The requester information.
152-
* @param {string} params.requester.ip - The IP address of the requester.
153-
* @param {string} params.requester.ua - The user-agent string of the requester.
154-
* @param {Function} params.requester.serialize - A function to serialize the requester information.
155-
* @param {string} params.action - The action performed during the authentication event.
156-
* @param {Object} params.body - The body of the request.
157-
* @param {Object} params.extra - Additional information related to the event.
158-
* @returns {Promise<void>} - A promise that resolves when the event is recorded.
159-
*/
160-
async record (parameters) {
161-
try {
162-
await this._record(parameters);
163-
} catch (err) {
164-
this.errors.report('auth-audit-service.record', {
165-
source: err,
166-
trace: true,
167-
alarm: true,
168-
});
169-
}
170-
}
171-
172-
/**
173-
* Internal method to record an authentication audit event.
174-
*
175-
* @private
176-
* @param {Object} params - The parameters for the authentication audit event.
177-
* @param {Object} params.requester - The requester information.
178-
* @param {string} params.requester.ip - The IP address of the requester.
179-
* @param {string} params.requester.ua - The user-agent string of the requester.
180-
* @param {Function} params.requester.serialize - A function to serialize the requester information.
181-
* @param {string} params.action - The action performed during the authentication event.
182-
* @param {Object} params.body - The body of the request.
183-
* @param {Object} params.extra - Additional information related to the event.
184-
* @returns {Promise<void>} - A promise that resolves when the event is recorded.
185-
*/
186-
async _record ({ requester, action, body, extra }) {
187-
const uid = 'aas-' + this.modules.uuidv4();
188-
189-
const json_values = {
190-
requester: requester.serialize(),
191-
body: body,
192-
extra: extra ?? {},
193-
};
194-
195-
let has_parse_error = 0;
196-
197-
for ( const k in json_values ) {
198-
let value = json_values[k];
199-
try {
200-
value = JSON.stringify(value);
201-
} catch (err) {
202-
has_parse_error = 1;
203-
value = { parse_error: err.message };
204-
}
205-
json_values[k] = value;
206-
}
207-
208-
await this.db.write(
209-
`INSERT INTO auth_audit (` +
210-
`uid, ip_address, ua_string, action, ` +
211-
`requester, body, extra, ` +
212-
`has_parse_error` +
213-
`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )`,
214-
[
215-
uid,
216-
requester.ip,
217-
requester.ua,
218-
action,
219-
JSON.stringify(requester.serialize()),
220-
JSON.stringify(body),
221-
JSON.stringify(extra ?? {}),
222-
has_parse_error,
223-
]
224-
);
225-
}
226-
}
227-
228-
module.exports = {
229-
AuthAuditService,
230-
};
23191
async _record ({ requester, action, body, extra }) {
23292
const uid = 'aas-' + this.modules.uuidv4();
23393

src/backend/src/services/auth/AuthService.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const { UUIDFPE } = require("../../util/uuidfpe");
2727

2828
// This constant defines the namespace used for generating app UUIDs from their origins
2929
const APP_ORIGIN_UUID_NAMESPACE = '33de3768-8ee0-43e9-9e73-db192b97a5d8';
30-
const APP_ORIGIN_UUID_NAMESPACE = '33de3768-8ee0-43e9-9e73-db192b97a5d8';
3130

3231
const LegacyTokenError = class extends Error {};
3332

src/backend/src/services/database/SqliteDatabaseAccessService.js

-28
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ const { CompositeError } = require("../../util/errorutil");
2424
const structutil = require("../../util/structutil");
2525
const { BaseDatabaseAccessService } = require("./BaseDatabaseAccessService");
2626

27-
28-
/**
29-
* Class SqliteDatabaseAccessService
30-
*
31-
* This service provides
3227
class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
3328
static ENGINE_NAME = 'sqlite';
3429

@@ -272,9 +267,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
272267
* @description This method is used to register SQLite database-related commands with the dev-console service.
273268
* @param {object} commands - The dev-console service commands object.
274269
*/
275-
241: _register_commands(commands) {
276-
242: ...
277-
243: }
278270
svc_serverHealth.add_check('sqlite', async () => {
279271
const [{ user_version }] = await this._requireRead('PRAGMA user_version');
280272
if ( user_version !== TARGET_VERSION ) {
@@ -346,15 +338,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
346338
* @param {Array<{statement: string, values: any[]}>} entries - An array of SQL queries and their corresponding parameters.
347339
* @return {void} This method does not return any value.
348340
*/
349-
275: async _batch_write (entries) {
350-
276: this.db.transaction(() => {
351-
277: for ( let { statement, values } of entries ) {
352-
278: statement = this.sqlite_transform_query_(statement);
353-
279: values = this.sqlite_transform_params_(values);
354-
280: this.db.prepare(statement).run(values);
355-
281: }
356-
282: })();
357-
283: }
358341
this.db.transaction(() => {
359342
for ( let { statement, values } of entries ) {
360343
statement = this.sqlite_transform_query_(statement);
@@ -397,17 +380,6 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
397380
*
398381
* @returns {Promise<void>} A promise that resolves when the migration is completed.
399382
*/
400-
303: async run_js_migration_ ({ filename, contents }) {
401-
304: contents = `(async () => {${contents}})()`;
402-
305: const vm = require('vm');
403-
306: const context = vm.createContext({
404-
307: read: this.read.bind(this),
405-
308: write: this.write.bind(this),
406-
309: log: this.log,
407-
310: structutil,
408-
311: });
409-
312: await vm.runInContext(contents, context);
410-
313: }
411383
contents = `(async () => {${contents}})()`;
412384
const vm = require('vm');
413385
const context = vm.createContext({

0 commit comments

Comments
 (0)