-
Notifications
You must be signed in to change notification settings - Fork 36
feat: document and test daily civic intelligence refinement engine #567
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
base: main
Are you sure you want to change the base?
Changes from all commits
fb5895e
c7f552e
1169add
eb4b8e3
43c86dd
9c8b68c
ac6eb66
0482109
acdaeed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [build] | ||
| publish = "dist" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /* | ||
| X-Frame-Options: DENY | ||
| X-Content-Type-Options: nosniff | ||
| X-XSS-Protection: 1; mode=block | ||
| Referrer-Policy: strict-origin-when-cross-origin |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /* /index.html 200 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,19 @@ import { Issue, ModelWeights } from "./types"; | |||||||||
| import * as fs from "fs"; | ||||||||||
| import * as path from "path"; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * AdaptiveWeights: Dynamically tunes category priorities based on historical | ||||||||||
| * critical assignments, storing previous states for full auditability. | ||||||||||
| * | ||||||||||
| * Algorithm and Evolution Logic: | ||||||||||
| * If a particular category (like "Pothole" or "Flooding") is frequently marked Critical manually | ||||||||||
| * or resolved (> 5 times), this engine increases the internal category weight by +0.5, | ||||||||||
|
Comment on lines
+10
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The new algorithm documentation is inaccurate: weight increases are triggered by resolved/assigned issues, not by manually marking issues as Critical. Prompt for AI agents
Suggested change
|
||||||||||
| * capping at 10 to auto-prioritize it going forward. | ||||||||||
| * It also intelligently manipulates the Duplicate Pattern detection threshold: | ||||||||||
| * Tightening (+0.01 to 0.95 max) when platform usage > 100, and relaxing (-0.01 to 0.70 min) | ||||||||||
| * on slower days to adaptively manage noise filtering. | ||||||||||
| * Saves an explicit snapshot history within modelWeights.json for complete AI model audibility. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This documentation overstates retention/audit behavior; history is capped to 30 entries, so it is not a complete record. Prompt for AI agents |
||||||||||
| */ | ||||||||||
| export class AdaptiveWeights { | ||||||||||
| private configPath: string; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,17 @@ import { Issue, DailySnapshot } from "./types"; | |||||
| import * as fs from "fs"; | ||||||
| import * as path from "path"; | ||||||
|
|
||||||
| /** | ||||||
| * IntelligenceIndex: Produces a daily Civic Intelligence snapshot, aggregating | ||||||
| * system performance metrics to capture overall municipal health and activity. | ||||||
| * | ||||||
| * Algorithm and Evolution Logic: | ||||||
| * Starts at a 50.0 Index Baseline. | ||||||
| * Increases (+): Base score raises by ratio of resolved civic issues (high resolutions = better performance). | ||||||
| * Minor Bonus (+): If top keywords contain rich descriptions, minor bump (+0.5 per keyword). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The new JSDoc describes a conditional keyword bonus that the code does not implement, which can mislead future changes and tests. Prompt for AI agents
Suggested change
|
||||||
| * Penalizes (-): Immediate penalty per significant Category Spikes (-1.5 per concern) to represent unmet issues. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The JSDoc now claims spike penalties apply only to significant spikes, but the current logic penalizes all spikes equally. Prompt for AI agents
Suggested change
|
||||||
| * Stores a JSON snapshot daily (e.g. data/dailySnapshots/YYYY-MM-DD.json) comparing delta changes. | ||||||
| */ | ||||||
| export class IntelligenceIndex { | ||||||
| private snapshotsDir: string; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,16 @@ | ||||||
| import { Issue } from "./types"; | ||||||
|
|
||||||
| /** | ||||||
| * TrendAnalyzer: Performs local pattern detection, finding emerging keywords, | ||||||
| * significant category volume spikes, and geographical clustering of issues. | ||||||
| * | ||||||
| * Algorithm and Evolution Logic: | ||||||
| * 1. Trend detection extracts the top 5 most common keywords (>= 3 chars) after filtering stop-words. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: JSDoc states a fixed top-5 keyword limit, but the method supports a configurable Prompt for AI agents
Suggested change
|
||||||
| * 2. It compares the last 24h category distribution with the previous 24h. | ||||||
| * If an issue spikes > 50% and exceeds a baseline of 5, it's flagged as an "Emerging Concern". | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Spike-rule documentation is inaccurate: baseline >5 applies only when previous count is zero, and the threshold check is Prompt for AI agents
Suggested change
|
||||||
| * 3. Uses rounded coordinate boundaries (approx. 1.1km) to locate geographical clusters | ||||||
| * and determine the region with the highest concentration of issues. | ||||||
| */ | ||||||
| export class TrendAnalyzer { | ||||||
| public getTopKeywords(issues: Issue[], limit: number = 5): string[] { | ||||||
| const wordCounts: Record<string, number> = {}; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest-utilis pinned as a direct devDependency at major v30 whilejestis v29, and it doesn’t appear to be imported/used anywhere in the repo. This introduces an additional major version of Jest internals (and pulls in@jest/typesv30) which can cause subtle incompatibilities. Consider removing the directjest-utildependency (let Jest manage its internal deps) or pin it to a compatible v29.x version if it’s truly needed.