Skip to content

feat: added config proxy#2246

Merged
bajrangCoder merged 5 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:main
Jun 16, 2026
Merged

feat: added config proxy#2246
bajrangCoder merged 5 commits into
Acode-Foundation:mainfrom
RohitKushvaha01:main

Conversation

@RohitKushvaha01

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hardens the plugin-facing config API by wrapping the config object in a Proxy before exposing it through acode.require("config"). Internal code continues to import config directly and retains full access (including the HAS_PRO setter), while plugin code receives a read-only view that silently blocks all mutation traps.

  • The Proxy correctly returns true from all mutation traps (set, defineProperty, deleteProperty, setPrototypeOf), which is the right behaviour for silent rejection in strict-mode ES modules.
  • SKU_LIST is now Object.freeze()'d at the source, closing the by-reference mutation loophole for that array.
  • No get trap is present, so accessor properties like HAS_PRO and PLAY_STORE_URL continue to be forwarded to the underlying getters correctly.

Confidence Score: 5/5

Safe to merge — the proxy correctly silences all mutation traps with return true, internal Acode code retains direct mutable access to config, and the SKU_LIST freeze closes the only by-reference array loophole.

All mutation traps return true (correct for strict-mode modules), no get trap means accessor properties like HAS_PRO and PLAY_STORE_URL forward to their underlying getters without issue, and the Object.freeze on SKU_LIST addresses the one concrete mutable nested value. Previously raised issues (false-returning traps, redundant get trap) are not present in this version of the code.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/acode.js Wraps the exported config object in a Proxy that silently blocks all mutation operations (set, defineProperty, deleteProperty, setPrototypeOf) before registering it with this.define("config", configProxy) — guards plugin-facing access while leaving internal direct imports of config unaffected.
src/lib/config.js Converts SKU_LIST from a plain array to an Object.freeze()'d array, preventing in-place mutation of that array even when accessed by reference through the proxy.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Plugin
    participant ConfigProxy as Proxy(config)
    participant Config as config (config.js)

    Note over Plugin,Config: Plugin access via acode.require("config")

    Plugin->>ConfigProxy: read prop (e.g. SKU_LIST, HAS_PRO)
    ConfigProxy->>Config: Reflect.get(config, prop, receiver)
    Config-->>Plugin: value (frozen array / getter result)

    Plugin->>ConfigProxy: "write prop (e.g. HAS_PRO = true)"
    ConfigProxy-->>Plugin: console.warn + return true (silent block)

    Plugin->>ConfigProxy: delete prop
    ConfigProxy-->>Plugin: console.warn + return true (silent block)

    Note over Config: Internal Acode code imports config directly

    Config->>Config: "config.HAS_PRO = true (unblocked)"
    Config->>Config: config.SKU_LIST[0] (frozen array)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Plugin
    participant ConfigProxy as Proxy(config)
    participant Config as config (config.js)

    Note over Plugin,Config: Plugin access via acode.require("config")

    Plugin->>ConfigProxy: read prop (e.g. SKU_LIST, HAS_PRO)
    ConfigProxy->>Config: Reflect.get(config, prop, receiver)
    Config-->>Plugin: value (frozen array / getter result)

    Plugin->>ConfigProxy: "write prop (e.g. HAS_PRO = true)"
    ConfigProxy-->>Plugin: console.warn + return true (silent block)

    Plugin->>ConfigProxy: delete prop
    ConfigProxy-->>Plugin: console.warn + return true (silent block)

    Note over Config: Internal Acode code imports config directly

    Config->>Config: "config.HAS_PRO = true (unblocked)"
    Config->>Config: config.SKU_LIST[0] (frozen array)
Loading

Reviews (4): Last reviewed commit: "fix: resolved concerns" | Re-trigger Greptile

Comment thread src/lib/acode.js
Comment thread src/lib/acode.js Outdated
Comment thread src/lib/acode.js Outdated
@RohitKushvaha01 RohitKushvaha01 marked this pull request as draft June 15, 2026 12:44
@RohitKushvaha01 RohitKushvaha01 marked this pull request as draft June 15, 2026 12:44
@RohitKushvaha01

Copy link
Copy Markdown
Member Author

@greptileai

Comment thread src/lib/acode.js
@RohitKushvaha01

Copy link
Copy Markdown
Member Author

@greptileai

@RohitKushvaha01 RohitKushvaha01 marked this pull request as ready for review June 16, 2026 09:50
@RohitKushvaha01 RohitKushvaha01 self-assigned this Jun 16, 2026
@bajrangCoder bajrangCoder merged commit 9c91302 into Acode-Foundation:main Jun 16, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants