-
Notifications
You must be signed in to change notification settings - Fork 10
refactor(storage): make raw query policy reviewable #2198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jurij89
merged 14 commits into
integration/2052-system-record-sync
from
refactor/2192-reviewable-raw-query-policy
Aug 9, 2026
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eee134b
refactor(storage): make raw query policy reviewable
553b03a
refactor(storage): compact raw query inventory
ab8f4aa
fix(core): recognize dot-separated SPARQL clauses
ee803e4
refactor(query): use canonical SPARQL word scanner
df90eda
refactor(query): centralize SPARQL token traversal
4f2423c
refactor(storage): expose reviewed query expressions
5c1bc94
fix(query): reject prefixed default graph patterns
d35a73e
refactor(query): expose honest scanner tokens
235733a
chore: retrigger review for raw query policy
95f98de
fix(query): centralize read-only admission policy
c4ef88f
chore: retrigger integration review
4706b8b
fix(query): terminate prefixed names before comments
4319713
fix(storage): count reviewed non-store call occurrences
837dcfe
fix(query): centralize SPARQL lexical admission
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| analyzeSparqlOperation, | ||
| readStandaloneSparqlWord, | ||
| recognizedReadOnlySparqlForm, | ||
| } from '../src/sparql-operation.js'; | ||
|
|
||
| describe('canonical standalone SPARQL word scanner', () => { | ||
| it('recognizes standalone words and rejects legal name adjacency', () => { | ||
| const standalone = ' SELECT ?s WHERE { ?s ?p ?o }'; | ||
| expect(readStandaloneSparqlWord(standalone, standalone.indexOf('SELECT'))).toEqual({ | ||
| word: 'SELECT', | ||
| start: 2, | ||
| end: 8, | ||
| }); | ||
|
|
||
| for (const source of [ | ||
| '?DELETE', | ||
| 'ex:DELETE', | ||
| 'foo\\-DELETE', | ||
| 'DELETE:value', | ||
| 'ex:foo.DELETE', | ||
| ]) { | ||
| expect(readStandaloneSparqlWord(source, source.indexOf('DELETE'))).toBeNull(); | ||
| } | ||
|
|
||
| const dotSeparated = '?s ?p ?o.GRAPH <urn:outside> {}'; | ||
|
Jurij89 marked this conversation as resolved.
|
||
| const graphStart = dotSeparated.indexOf('GRAPH'); | ||
| expect(readStandaloneSparqlWord(dotSeparated, graphStart)).toEqual({ | ||
| word: 'GRAPH', | ||
| start: graphStart, | ||
| end: graphStart + 'GRAPH'.length, | ||
| }); | ||
|
|
||
| expect(readStandaloneSparqlWord('GRAPH?g{}', 0)).toEqual({ | ||
| word: 'GRAPH', | ||
| start: 0, | ||
| end: 5, | ||
| }); | ||
| expect(analyzeSparqlOperation('SELECT * WHERE {}; DELETE?subject {}').mutatingKeyword) | ||
| .toBe('DELETE'); | ||
| }); | ||
|
|
||
| it('shares the same boundary model with operation admission', () => { | ||
| const read = 'SELECT * WHERE { BIND(ex:foo\\-DELETE AS ?value) }'; | ||
| expect(recognizedReadOnlySparqlForm(analyzeSparqlOperation(read))).toBe('SELECT'); | ||
|
|
||
| const mixed = `${read}; DELETE WHERE { ?s ?p ?o }`; | ||
| expect(recognizedReadOnlySparqlForm(analyzeSparqlOperation(mixed))).toBeNull(); | ||
|
|
||
| const dotSeparatedMutation = 'SELECT * WHERE { ?s ?p ?o.DELETE WHERE { ?x ?y ?z } }'; | ||
| expect(analyzeSparqlOperation(dotSeparatedMutation).mutatingKeyword).toBe('DELETE'); | ||
| expect(recognizedReadOnlySparqlForm(analyzeSparqlOperation(dotSeparatedMutation))).toBeNull(); | ||
|
|
||
| const prefixedName = 'SELECT * WHERE { BIND(ex:foo.DELETE AS ?value) }'; | ||
| expect(analyzeSparqlOperation(prefixedName).mutatingKeyword).toBeNull(); | ||
| expect(recognizedReadOnlySparqlForm(analyzeSparqlOperation(prefixedName))).toBe('SELECT'); | ||
| }); | ||
|
|
||
| it('has no shared regex or cursor state across interleaved calls', () => { | ||
| const update = 'SELECT * WHERE { ?s ?p ?o }; DROP ALL'; | ||
| const read = 'ASK { ?s ?p ?o }'; | ||
| for (let iteration = 0; iteration < 20; iteration++) { | ||
| expect(analyzeSparqlOperation(update).mutatingKeyword).toBe('DROP'); | ||
| expect(recognizedReadOnlySparqlForm(analyzeSparqlOperation(read))).toBe('ASK'); | ||
| } | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.