refactor(web): start Go ABI rewrite of plugins/web (W-G0)
Archive the Rust web plugin and add a Go c-shared skeleton with ABI v2 bridge, build script, design doc/ADR, and smoke test so multi-language plugins and full web parity can proceed wave by wave. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fb6254e501
commit
ca40c698a2
42 files changed
+955
-3
No files matched your search
@@ -0,0 +1,55 @@
|
||||
/* Marqdo plugin ABI v2 — C contract (source of truth).
|
||||
*
|
||||
* Plugins are optional shared libraries (.dll / .so / .dylib), never linked
|
||||
* into the marqdo binary. Values cross the boundary as UTF-8 JSON.
|
||||
*
|
||||
* v1: register_fn, alloc, free
|
||||
* v2: + host_query (allowlisted host introspection for plugins)
|
||||
*/
|
||||
#ifndef MARQDO_ABI_H
|
||||
#define MARQDO_ABI_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MARQDO_ABI_VERSION 2u
|
||||
#define MARQDO_ABI_VERSION_MIN 1u
|
||||
|
||||
/* Plugin function: args_json is a UTF-8 JSON object whose keys are param names.
|
||||
* On success: return 0, set *out_json to a heap string (host frees via free).
|
||||
* On failure: return non-zero; optional *err_msg heap string (host frees).
|
||||
* out_json / err_msg may be left NULL.
|
||||
*/
|
||||
typedef int (*MarqdoPluginFn)(const char *args_json, char **out_json, char **err_msg);
|
||||
|
||||
/* Host → plugin query (v2). `name` is an allowlisted query id.
|
||||
* Same success/failure convention as MarqdoPluginFn.
|
||||
*/
|
||||
typedef int (*MarqdoHostQueryFn)(void *userdata, const char *name, const char *args_json,
|
||||
char **out_json, char **err_msg);
|
||||
|
||||
typedef struct MarqdoHostApi {
|
||||
void *userdata;
|
||||
/* params: comma-separated param names in order, e.g. "a,b". May be "". */
|
||||
int (*register_fn)(void *userdata, const char *name, const char *params,
|
||||
MarqdoPluginFn fn);
|
||||
void *(*alloc)(size_t n);
|
||||
void (*free)(void *p);
|
||||
/* v2: NULL for hosts that only speak v1; required when plugin abi >= 2 */
|
||||
MarqdoHostQueryFn host_query;
|
||||
} MarqdoHostApi;
|
||||
|
||||
/* Required exports from every plugin shared library. */
|
||||
uint32_t marqdo_plugin_abi_version(void);
|
||||
int marqdo_plugin_init(const MarqdoHostApi *host);
|
||||
void marqdo_plugin_shutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MARQDO_ABI_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Go/cgo local ABI view — same layout as include/marqdo_abi.h.
|
||||
* cgo //export cannot emit `const` on parameters; this header matches
|
||||
* the generated prototypes so -buildmode=c-shared links cleanly.
|
||||
* Wire format & semantics remain ABI v2 (see include/marqdo_abi.h).
|
||||
*/
|
||||
#ifndef MARQDO_ABI_CGO_H
|
||||
#define MARQDO_ABI_CGO_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MARQDO_ABI_VERSION 2u
|
||||
#define MARQDO_ABI_VERSION_MIN 1u
|
||||
|
||||
typedef int (*MarqdoPluginFn)(char *args_json, char **out_json, char **err_msg);
|
||||
|
||||
typedef int (*MarqdoHostQueryFn)(void *userdata, char *name, char *args_json,
|
||||
char **out_json, char **err_msg);
|
||||
|
||||
typedef struct MarqdoHostApi {
|
||||
void *userdata;
|
||||
int (*register_fn)(void *userdata, char *name, char *params, MarqdoPluginFn fn);
|
||||
void *(*alloc)(size_t n);
|
||||
void (*free)(void *p);
|
||||
MarqdoHostQueryFn host_query;
|
||||
} MarqdoHostApi;
|
||||
|
||||
uint32_t marqdo_plugin_abi_version(void);
|
||||
int marqdo_plugin_init(MarqdoHostApi *host);
|
||||
void marqdo_plugin_shutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MARQDO_ABI_CGO_H */
|
||||
Reference in new issue
Block a user