Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
…PMessage.ts and utils.ts
|
I think, before merging this, we should pass every single file through an LLM comparing it to the original file and ask the LLM if there are any differences between the files unrelated to type signature changes. |
taoeffect
left a comment
There was a problem hiding this comment.
I ran this amazing script that @corrideat wrote:
Details
#!/bin/sh
git clone https://github.com/okTurtles/group-income.git
git clone https://github.com/okTurtles/libcheloniajs.git
( cd libcheloniajs; git checkout initial )
cwd=$CWD
(
cp -Ra group-income/shared/domains/chelonia/ gi && \
cp group-income/shared/functions.js group-income/shared/pubsub.js gi && \
rm -rf gi/*.test.js && \
rm -rf group-income
) || exit 1
(
cp -Ra libcheloniajs/src/ lc && \
mv lc/local-selectors/index.ts lc/localSelectors.ts && \
mv lc/pubsub/index.ts lc/pubsub.ts && \
rm -rf lc/local-selectors lc/pubsub lc/*.test.ts lc/index.ts lc/types.ts && \
rm -rf libcheloniajs
) || exit 1
X=$(cd gi; find . -type f|sort) Y=$(cd lc; find . -type f|sort|sed -e 's/.ts$/.js/g'); [ x"$X" = x"$Y" ] || ( echo "File list does not match" >&2; exit 1)
mkdir -p 'dist'
yes '' | npm init
npm install --save-dev 'esbuild' 'eslint@8' 'eslint-config-standard' 'flow-remove-types'
cat >index.mjs <<-EOF
import * as esbuild from 'esbuild'
import { loadESLint } from 'eslint'
import flowRemoveTypes from 'flow-remove-types'
const EslintConstructor = await loadESLint()
const eslint = new EslintConstructor({ fix: true })
const extractSource = async (source, isFlow) => {
const elideTypes = isFlow ? flowRemoveTypes : (v) => v
return (await eslint.lintText(esbuild.transformSync(elideTypes(source, { all: true }).toString(), { loader: 'ts' }).code
))[0].output
}
(() => {
const data = []
process.stdin.on('readable', () => {
let chunk
while ((chunk = process.stdin.read()) !== null) {
data.push(chunk)
}
})
process.stdin.on('end', () => {
extractSource(Buffer.concat(data).toString(), process.argv[2] === 'flow').then((v) => {
v && process.stdout.write(v)
})
})
})()
EOF
cat >.eslintrc.json <<-EOF
{"extends":"standard"}
EOF
for i in gi lc; do
flow=''
[ x"$i" = x'gi' ] && flow='flow'
find $i -type f '(' -name '*.js' -o -name '*.ts' ')' | while read line; do
mkdir -p 'dist/'"$(dirname "$line")"
node index.mjs "$flow" < "$line" > 'dist/'"${line%.*}.js"
done
done
(
( cd gi && find . -type f ) | while read i; do diff -up "dist/gi/$i" "dist/lc/$i"; done
)And then ran the diff through a few different LLMs with this prompt:
Please review the following diff and let me know if you see any changes that affect any logic:
Here are the things it noticed that I think need to be addressed or might need to be addressed:
o4-mini
-
Function Parameter Changes:
- In
chelonia.js, the function signature foreventsBetweenhas changed from:to:'chelonia/out/eventsBetween': function (contractID, startHash, endHeight, offset = 0, { stream } = { stream: true }) {
This change encapsulates'chelonia/out/eventsBetween': function (contractID, { startHash, endHeight, offset = 0, limit = 0, stream = true }) {
startHash,endHeight,offset,limit, andstreaminto a single object. This could impact how this function is called elsewhere in the code, requiring updates to the function calls to match the new parameter structure.
- In
-
Logic Changes in Event Handling:
- The logic for calculating the
limithas been changed:This could affect how many events are returned by theconst ourLimit = limit ? Math.min(endHeight - startOffset + 1, limit) : endHeight - startOffset + 1
eventsBetweenfunction, particularly iflimitis not passed or is zero. Ensure that this logic aligns with the intended behavior.
- The logic for calculating the
-
Error Handling:
- The addition of
handleFetchResultinfunctions.jsintroduces a new utility function for handling fetch results, which could centralize error handling for network requests. This is a positive change, but make sure that all places where fetch results are handled are updated to use this new function.
- The addition of
Opus 4
1. chelonia/out/eventsBetween signature change (Critical)
- 'chelonia/out/eventsBetween': function (contractID, startHash, endHeight, offset = 0, { stream } = { stream: true }) {
+ 'chelonia/out/eventsBetween': function (contractID, { startHash, endHeight, offset = 0, limit = 0, stream = true }) {This is a breaking API change. The function now expects an object as the second parameter instead of individual parameters. Any code calling this function with the old signature will break.
2. New limit parameter logic in eventsBetween
- const limit = endHeight - startOffset + 1
- if (limit < 1) {
+ const ourLimit = limit ? Math.min(endHeight - startOffset + 1, limit) : endHeight - startOffset + 1
+ if (ourLimit < 1) {The function now supports a limit parameter that can cap the number of events returned. When limit is provided and non-zero, it will return at most limit events instead of all events in the range.
7. Removed 'use strict' directives
Multiple files had 'use strict' removed, suggesting the code is now ES modules by default.
Note: I'm not sure about 'use script'. Also not sure handleFetchResult. Those might be fine, but please double-check.
Also found an issue in ci.yml (see comment below).
And finally, please make sure that if there are any types that need to be updated (e.g. for chelonia/out/eventsBetween signature), that they're updated too because I don't think those are included in the diff.
|
Regarding the rest of the feedback: The changes to The The |
src/chelonia.ts
Outdated
| controller.close() | ||
| return | ||
| } | ||
| reader = sbp('chelonia/out/eventsAfter', contractID, startOffset, limit).getReader() |
There was a problem hiding this comment.
In your other PR this line has been changed to:
reader = sbp('chelonia/out/eventsAfter', contractID, startOffset, ourLimit).getReader()Did you forget to update it here?
There was a problem hiding this comment.
It looks like I forgot. Good catch.
src/chelonia.ts
Outdated
| 'chelonia/out/eventsAfter': eventsAfter, | ||
| 'chelonia/out/eventsBefore': function (this: CheloniaContext, contractID: string, beforeHeight: number, limit: number, options: { stream: boolean }) { |
There was a problem hiding this comment.
These two APIs are now inconsistent with the API of eventsBetween.
When I made my comment here, I thought you would only move the optional parameters into the object, but you moved almost all of them.
I have no problem with that, I actually prefer that all parameters be named, but then these two APIs, 'chelonia/out/eventsAfter', and 'chelonia/out/eventsBefore', need to be updated to be consistent with how 'chelonia/out/eventsBetween' is structured too.
In otherwords, everything after contractID needs to be moved into an object.
There was a problem hiding this comment.
This would be a more involved change, as those functions are used in other places besides ChatMain.vue (in particular, eventsAfter is used in Chelonia itself). Should I go ahead with making the change to named parameters, or should I partially revert the changes to eventsBetween (and if the latter, please provide the desired signature)?
There was a problem hiding this comment.
The APIs should be consistent... so I don't know what you mean by "revert". The problem with eventsBetween before was a real problem. One solution to it would be to move those optional params into an options object like eventsBefore has. Another solution (that you picked) would be to move all of them (except contractID) into an object.
Reverting to how it was before isn't an option because it was really poorly designed before... So if by "revert" you mean "go with the solution where optional params are placed in an options object", that's fine too. But if by "revert" you mean, "undo our improvement"... I don't think that's a good idea.
There was a problem hiding this comment.
I'm agreeing with that they should ideally be consistent. OTOH, it looks like I was overzealous with the way I implemented named parameters.
So, there are two ways I see to address the inconsistency issue:
- Make the same change to
eventsAfterandeventsBefore, i.e., making everything aftercontractIDa named parameter. - Partially revert the change to
eventsBetween. This would in practice mean keeping some arguments positional (as they were) and some named (other thanstream)
Both alternatives are pretty simple, but the first option (making everything named) will require more care to ensure no mistakes are introduced (e.g., by forgetting to update a call to the new signature).
There was a problem hiding this comment.
Another question (I guess it applies to either option, since both are breaking changes):
Would you rather I update the code here (in this repo) and in okTurtles/group-income#2825, or that I make a separate PR to https://github.com/okTurtles/group-income with the same API changes (this way, okTurtles/group-income#2825 will continue to have just import-related changes)?
There was a problem hiding this comment.
Would you rather I update the code here (in this repo) and in okTurtles/group-income#2825, or that I make a separate PR to https://github.com/okTurtles/group-income with the same API changes (this way, okTurtles/group-income#2825 will continue to have just import-related changes)?
It sounds to me like the latter aligns closer with being script-friendly. I think as a matter of principle and due-diligence on both of our parts to avoid headaches for both of us and our users we should only merge this PR (and PR okTurtles/group-income#2825), after all Chelonia changes have been merged into master in Group Income, so that we can run a final diff on the files and be 100% sure we haven't accidentally missed something.
There was a problem hiding this comment.
* initial files * Add pubsub * Add local selectors, events, Secret, functions, constants * Add errors * Updated types * Types for all files except chelonia.ts, functions.ts, internals.ts, SPMessage.ts and utils.ts * Fix types * Types * Fix types in chelonia.js * Internals types * Fix all types * GI changes * Tests & exports * Port changes * Port KV change * Empty * Almost final changes * Add build helper * Stdio * Port GI PR 2833 * Add missing skipDecryptionAttempts * Add missing deserialize param * GI consistency * Consisency feedback * Add dist files * Remove uses of global Buffer * Port eventsBetween changes * Fix CI file * events API consistency Co-authored-by: Greg Slepak <contact@taoeffect.com>
No description provided.